shill: Accept --portal-list command line option

This option is used from the init scripts to override the startup
value of the portal list.  This is not meant to override the profile
value, but simply to mask that value until the user has completed
OOBE.

BUG=chromium-os:28424
TEST=New unit tests, plus manual:
 - Reboot -- test that system starts up with machine default
   (get-portal-list => ethernet,wifi,cellular)
 - rm /home/chronos/.oobe_completed
 - Restart shill and test that get-portal-list => ""
 - Run "set-portal-list wifi,ethernet,cellular", and ensure we can read
   this back.
 - Reboot (on test machines, this repopulates .oobe_completed on boot)
   ensure that we return to the profile-stored value.

Change-Id: I8c6427d89087d6e8a611e407b93e4082300ddf03
Reviewed-on: https://gerrit.chromium.org/gerrit/21295
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Brian Harring <ferringb@chromium.org>
diff --git a/manager.h b/manager.h
index e2daef0..a3962ee 100644
--- a/manager.h
+++ b/manager.h
@@ -152,6 +152,11 @@
                          const ResultCallback &callback);
   // Return whether a technology is marked as enabled for portal detection.
   virtual bool IsPortalDetectionEnabled(Technology::Identifier tech);
+  // Set the start-up value for the portal detection list.  This list will
+  // be used until a value set explicitly over the control API.  Until
+  // then, we ignore but do not overwrite whatever value is stored in the
+  // profile.
+  void SetStartupPortalList(const std::string &portal_list);
 
   std::string CalculateState(Error *error);
 
@@ -197,6 +202,7 @@
   FRIEND_TEST(ManagerTest, PopProfileWithUnload);
   FRIEND_TEST(ManagerTest, SortServices);
   FRIEND_TEST(ManagerTest, SortServicesWithConnection);
+  FRIEND_TEST(ManagerTest, StartupPortalList);
 
   static const char kErrorNoDevice[];
   static const char kErrorTypeRequired[];
@@ -215,6 +221,8 @@
   // TODO(cmasone): This should be implemented by filtering |services_|.
   std::vector<std::string> EnumerateWatchedServices(Error *error);
   std::string GetActiveProfileRpcIdentifier(Error *error);
+  std::string GetCheckPortalList(Error *error);
+  void SetCheckPortalList(const std::string &portal_list, Error *error);
   void EmitDeviceProperties();
 
   // Unload a service while iterating through |services_|.  Returns true if
@@ -277,6 +285,13 @@
   // The priority order of technologies
   std::vector<Technology::Identifier> technology_order_;
 
+  // Manager can be optionally configured with a list of technologies to
+  // do portal detection on at startup.  We need to keep track of that list
+  // as well as a flag that tells us whether we should continue using it
+  // instead of the configured portal list.
+  std::string startup_portal_list_;
+  bool use_startup_portal_list_;
+
   // Properties to be get/set via PropertyStore calls.
   Properties props_;
   PropertyStore store_;