| 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..893d7b36cfed62281ffd962a0e23da54cc1a2bc5 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,14 @@ BrowserPolicyConnector::~BrowserPolicyConnector() {
|
| void BrowserPolicyConnector::Init(
|
| PrefService* local_state,
|
| scoped_refptr<net::URLRequestContextGetter> request_context,
|
| - scoped_ptr<DeviceManagementService> device_management_service) {
|
| + scoped_ptr<DeviceManagementService> enterprise_device_management_service,
|
| + scoped_ptr<DeviceManagementService> consumer_device_management_service) {
|
| DCHECK(!is_initialized());
|
|
|
| - device_management_service_ = device_management_service.Pass();
|
| + enterprise_device_management_service_ =
|
| + enterprise_device_management_service.Pass();
|
| + consumer_device_management_service_ =
|
| + consumer_device_management_service.Pass();
|
|
|
| if (g_testing_provider)
|
| g_testing_provider->Init(GetSchemaRegistry());
|
| @@ -116,7 +125,8 @@ 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();
|
| + enterprise_device_management_service_.reset();
|
| + consumer_device_management_service_.reset();
|
| }
|
|
|
| PolicyService* BrowserPolicyConnector::GetPolicyService() {
|
| @@ -154,8 +164,12 @@ void BrowserPolicyConnector::ScheduleServiceInitialization(
|
| int64 delay_milliseconds) {
|
| // Skip device initialization if the BrowserPolicyConnector was never
|
| // initialized (unit tests).
|
| - if (device_management_service_)
|
| - device_management_service_->ScheduleInitialization(delay_milliseconds);
|
| + if (enterprise_device_management_service_)
|
| + enterprise_device_management_service_->
|
| + ScheduleInitialization(delay_milliseconds);
|
| + if (consumer_device_management_service_)
|
| + consumer_device_management_service_->
|
| + ScheduleInitialization(delay_milliseconds);
|
| }
|
|
|
| const ConfigurationPolicyHandlerList*
|
| @@ -163,6 +177,21 @@ const ConfigurationPolicyHandlerList*
|
| return handler_list_.get();
|
| }
|
|
|
| +DeviceManagementService* BrowserPolicyConnector::GetDeviceManagementService(
|
| + ManagementMode management_mode) {
|
| + switch (management_mode) {
|
| + case ENTERPRISE_MANAGED:
|
| + return enterprise_device_management_service_.get();
|
| +
|
| + case CONSUMER_MANAGED:
|
| + return consumer_device_management_service_.get();
|
| +
|
| + default:
|
| + NOTREACHED();
|
| + return NULL;
|
| + }
|
| +}
|
| +
|
| // static
|
| void BrowserPolicyConnector::SetPolicyProviderForTesting(
|
| ConfigurationPolicyProvider* provider) {
|
| @@ -208,12 +237,28 @@ 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:
|
| + NOTREACHED();
|
| + return std::string();
|
| + }
|
| }
|
|
|
| // static
|
|
|