shill: service: Do active checks on PortalCheck and ProxyConfig

Change both properties to be derived strings.  Validate the various
values of the PortalCheck parameter.  Force a restart of portal
detection if either parameter changes, so that we can switch from
Portal to Online or vice vesa if by changing this parameter we are
changing the behavior of portal check.

BUG=chromium-os:29745
TEST=New unit tests.  Manual: Set Proxy configuration on a service
in portal state while on the login screen.

Change-Id: I86c386e61396a23103f99382c568372b4774f452
Reviewed-on: https://gerrit.chromium.org/gerrit/21027
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/manager_unittest.cc b/manager_unittest.cc
index dd3faaf..281147a 100644
--- a/manager_unittest.cc
+++ b/manager_unittest.cc
@@ -1860,6 +1860,29 @@
   manager()->RecheckPortal(NULL);
 }
 
+TEST_F(ManagerTest, RecheckPortalOnService) {
+  MockServiceRefPtr service = new NiceMock<MockService>(control_interface(),
+                                                        dispatcher(),
+                                                        metrics(),
+                                                        manager());
+  EXPECT_CALL(*mock_devices_[0].get(),
+              IsConnectedToService(IsRefPtrTo(service)))
+      .WillOnce(Return(false));
+  EXPECT_CALL(*mock_devices_[1].get(),
+              IsConnectedToService(IsRefPtrTo(service)))
+      .WillOnce(Return(true));
+  EXPECT_CALL(*mock_devices_[1].get(), RestartPortalDetection())
+      .WillOnce(Return(true));
+  EXPECT_CALL(*mock_devices_[2].get(), IsConnectedToService(_))
+      .Times(0);
+
+  manager()->RegisterDevice(mock_devices_[0]);
+  manager()->RegisterDevice(mock_devices_[1]);
+  manager()->RegisterDevice(mock_devices_[2]);
+
+  manager()->RecheckPortalOnService(service);
+}
+
 TEST_F(ManagerTest, GetDefaultService) {
   EXPECT_FALSE(manager()->GetDefaultService().get());