shill: Add option to push profiles on shill startup

When re-started after a user has logged in (say, due to a crash), we need a
way to tell shill to load the logged in user's profile. Normally, you would
do this by having the respawning entity (upstart, usually) to re-send a dbus-
message to load a profile.

Due to the machinations of how process tracking works, it's sometimes better
to do the startup and profile load in a single step. Hence, this new option
similar to flimflam.

BUG=chromium-os:23492
TEST=none

Change-Id: I2f66ebd726fa678468b4ad01a57c21ebf42784aa
Reviewed-on: https://gerrit.chromium.org/gerrit/12179
Tested-by: Gaurav Shah <gauravsh@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Gaurav Shah <gauravsh@chromium.org>
diff --git a/shill_main.cc b/shill_main.cc
index 71ea271..cdf241f 100644
--- a/shill_main.cc
+++ b/shill_main.cc
@@ -37,6 +37,8 @@
 static const char kDefaultConfigDir[] = "default-config-dir";
 // Don't attempt to manage these devices.
 static const char kDeviceBlackList[] = "device-black-list";
+// Flag to specify specific profiles to be pushed.
+static const char kPushProfiles[] = "push";
 // Flag that causes shill to show the help message and exit.
 static const char kHelp[] = "help";
 // LOG() level. 0 = INFO, 1 = WARNING, 2 = ERROR.
@@ -57,6 +59,8 @@
     "    Do not manage devices named device1 or device2\n"
     "  --log-level=N\n"
     "    LOG() level. 0 = INFO, 1 = WARNING, 2 = ERROR.\n"
+    "  --push=profile1,profile2\n"
+    "    Specify profiles to push on startup.\n"
     "  --use-flimflam-profiles\n"
     "    Use the same directories flimflam uses for global, user profiles.\n"
     "  --v=N\n"
@@ -136,6 +140,13 @@
 
   shill::Daemon daemon(&config, dbus_control);
 
+  if (cl->HasSwitch(switches::kPushProfiles)) {
+    vector<string> profile_list;
+    base::SplitString(cl->GetSwitchValueASCII(switches::kPushProfiles),
+                      ',', &profile_list);
+    daemon.SetStartupProfiles(profile_list);
+  }
+
   if (cl->HasSwitch(switches::kDeviceBlackList)) {
     vector<string> device_list;
     base::SplitString(cl->GetSwitchValueASCII(switches::kDeviceBlackList),