Index: components/policy/core/browser/browser_policy_connector.cc |
diff --git a/components/policy/core/browser/browser_policy_connector.cc b/components/policy/core/browser/browser_policy_connector.cc |
index 109121ee1681bf13797ebf00e168819a09715648..9956e410cc8fc49c8535c01328d85651f6a7ab89 100644 |
--- a/components/policy/core/browser/browser_policy_connector.cc |
+++ b/components/policy/core/browser/browser_policy_connector.cc |
@@ -31,8 +31,13 @@ namespace policy { |
namespace { |
-// The URL for the device management server. |
-const char kDefaultDeviceManagementServerUrl[] = |
+// The URL for the enterprise device management server. |
+const char kDefaultEnterpriseDeviceManagementServerUrl[] = |
+ "https://m.google.com/devicemanagement/data/api"; |
+ |
+// TODO(davidyu): use the right URL once the server is ready. |
+// The URL for the consumer device management server. |
+const char kDefaultConsumerDeviceManagementServerUrl[] = |
"https://m.google.com/devicemanagement/data/api"; |
// Used in BrowserPolicyConnector::SetPolicyProviderForTesting. |
@@ -85,10 +90,10 @@ BrowserPolicyConnector::~BrowserPolicyConnector() { |
void BrowserPolicyConnector::Init( |
PrefService* local_state, |
scoped_refptr<net::URLRequestContextGetter> request_context, |
- scoped_ptr<DeviceManagementService> device_management_service) { |
+ ScopedVector<DeviceManagementService> device_management_services) { |
DCHECK(!is_initialized()); |
- device_management_service_ = device_management_service.Pass(); |
+ device_management_services_ = device_management_services.Pass(); |
if (g_testing_provider) |
g_testing_provider->Init(GetSchemaRegistry()); |
@@ -116,7 +121,7 @@ void BrowserPolicyConnector::Shutdown() { |
// Drop g_testing_provider so that tests executed with --single_process can |
// call SetPolicyProviderForTesting() again. It is still owned by the test. |
g_testing_provider = NULL; |
- device_management_service_.reset(); |
+ device_management_services_.clear(); |
} |
PolicyService* BrowserPolicyConnector::GetPolicyService() { |
@@ -154,8 +159,12 @@ void BrowserPolicyConnector::ScheduleServiceInitialization( |
int64 delay_milliseconds) { |
// Skip device initialization if the BrowserPolicyConnector was never |
bartfab (slow)
2014/04/23 12:17:18
Nit: That comment is no longer necessary. If |devi
davidyu
2014/04/23 12:56:58
Code reverted.
|
// initialized (unit tests). |
- if (device_management_service_) |
- device_management_service_->ScheduleInitialization(delay_milliseconds); |
+ for (ScopedVector<DeviceManagementService>::const_iterator i = |
bartfab (slow)
2014/04/23 12:17:18
Nit: The most common variable name for iterators i
davidyu
2014/04/23 12:56:58
Code removed.
|
+ device_management_services_.begin(); |
+ i != device_management_services_.end(); |
+ ++i) { |
+ (*i)->ScheduleInitialization(delay_milliseconds); |
+ } |
} |
const ConfigurationPolicyHandlerList* |
@@ -163,6 +172,11 @@ const ConfigurationPolicyHandlerList* |
return handler_list_.get(); |
} |
+DeviceManagementService* BrowserPolicyConnector::GetDeviceManagementService( |
+ ManagementMode management_mode) { |
+ return device_management_services_[management_mode]; |
bartfab (slow)
2014/04/23 12:17:18
Nit: Add DCHECKs to verify that we were not given
davidyu
2014/04/23 12:56:58
Done.
|
+} |
+ |
// static |
void BrowserPolicyConnector::SetPolicyProviderForTesting( |
ConfigurationPolicyProvider* provider) { |
@@ -208,12 +222,27 @@ bool BrowserPolicyConnector::IsNonEnterpriseUser(const std::string& username) { |
} |
// static |
-std::string BrowserPolicyConnector::GetDeviceManagementUrl() { |
+std::string BrowserPolicyConnector::GetDeviceManagementUrl( |
+ ManagementMode management_mode) { |
CommandLine* command_line = CommandLine::ForCurrentProcess(); |
- if (command_line->HasSwitch(switches::kDeviceManagementUrl)) |
- return command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl); |
- else |
- return kDefaultDeviceManagementServerUrl; |
+ switch (management_mode) { |
+ case ENTERPRISE_MANAGED: |
+ if (command_line->HasSwitch(switches::kDeviceManagementUrl)) |
+ return command_line->GetSwitchValueASCII( |
+ switches::kDeviceManagementUrl); |
+ else |
+ return kDefaultEnterpriseDeviceManagementServerUrl; |
+ |
+ case CONSUMER_MANAGED: |
+ if (command_line->HasSwitch(switches::kConsumerDeviceManagementUrl)) |
+ return command_line->GetSwitchValueASCII( |
+ switches::kConsumerDeviceManagementUrl); |
+ else |
+ return kDefaultConsumerDeviceManagementServerUrl; |
+ |
+ default: |
+ return std::string(); |
bartfab (slow)
2014/04/23 12:17:18
Nit: Add a NOTREACHED().
davidyu
2014/04/23 12:56:58
Done.
|
+ } |
} |
// static |