| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 11 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 15 #include "chrome/browser/chromeos/policy/app_pack_updater.h" | 17 #include "chrome/browser/chromeos/policy/app_pack_updater.h" |
| 16 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 18 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 17 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 18 #include "chrome/browser/chromeos/policy/device_local_account.h" | 20 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 19 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 21 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| 20 #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" | 22 #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" |
| 21 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 23 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 22 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 24 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 23 #include "chrome/browser/chromeos/settings/cros_settings.h" | 25 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 24 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 26 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 27 #include "chrome/browser/policy/device_management_service_configuration.h" |
| 25 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 26 #include "chromeos/chromeos_paths.h" | 29 #include "chromeos/chromeos_paths.h" |
| 27 #include "chromeos/chromeos_switches.h" | 30 #include "chromeos/chromeos_switches.h" |
| 28 #include "chromeos/cryptohome/system_salt_getter.h" | 31 #include "chromeos/cryptohome/system_salt_getter.h" |
| 29 #include "chromeos/dbus/dbus_thread_manager.h" | 32 #include "chromeos/dbus/dbus_thread_manager.h" |
| 30 #include "chromeos/network/network_handler.h" | 33 #include "chromeos/network/network_handler.h" |
| 31 #include "chromeos/network/onc/onc_certificate_importer_impl.h" | 34 #include "chromeos/network/onc/onc_certificate_importer_impl.h" |
| 32 #include "chromeos/settings/cros_settings_names.h" | 35 #include "chromeos/settings/cros_settings_names.h" |
| 33 #include "chromeos/settings/cros_settings_provider.h" | 36 #include "chromeos/settings/cros_settings_provider.h" |
| 34 #include "chromeos/settings/timezone_settings.h" | 37 #include "chromeos/settings/timezone_settings.h" |
| 35 #include "chromeos/system/statistics_provider.h" | 38 #include "chromeos/system/statistics_provider.h" |
| 36 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 39 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 37 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 40 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
| 38 #include "components/policy/core/common/proxy_policy_provider.h" | 41 #include "components/policy/core/common/proxy_policy_provider.h" |
| 39 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
| 40 #include "google_apis/gaia/gaia_auth_util.h" | 43 #include "google_apis/gaia/gaia_auth_util.h" |
| 41 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
| 42 | 45 |
| 43 using content::BrowserThread; | 46 using content::BrowserThread; |
| 44 | 47 |
| 45 namespace policy { | 48 namespace policy { |
| 46 | 49 |
| 47 namespace { | 50 namespace { |
| 48 | 51 |
| 52 // TODO(davidyu): Update the URL to the real one once it is ready. |
| 53 // http://crbug.com/366491. |
| 54 // |
| 55 // The URL for the consumer device management server. |
| 56 const char kDefaultConsumerDeviceManagementServerUrl[] = |
| 57 "https://m.google.com/devicemanagement/data/api"; |
| 58 |
| 49 // Install attributes for tests. | 59 // Install attributes for tests. |
| 50 EnterpriseInstallAttributes* g_testing_install_attributes = NULL; | 60 EnterpriseInstallAttributes* g_testing_install_attributes = NULL; |
| 51 | 61 |
| 52 // Helper that returns a new SequencedTaskRunner backed by the blocking pool. | 62 // Helper that returns a new SequencedTaskRunner backed by the blocking pool. |
| 53 // Each SequencedTaskRunner returned is independent from the others. | 63 // Each SequencedTaskRunner returned is independent from the others. |
| 54 scoped_refptr<base::SequencedTaskRunner> GetBackgroundTaskRunner() { | 64 scoped_refptr<base::SequencedTaskRunner> GetBackgroundTaskRunner() { |
| 55 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 65 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 56 CHECK(pool); | 66 CHECK(pool); |
| 57 return pool->GetSequencedTaskRunnerWithShutdownBehavior( | 67 return pool->GetSequencedTaskRunnerWithShutdownBehavior( |
| 58 pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 68 pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 59 } | 69 } |
| 60 | 70 |
| 71 std::string GetConsumerDeviceManagementServerUrl() { |
| 72 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 73 if (command_line->HasSwitch( |
| 74 chromeos::switches::kConsumerDeviceManagementUrl)) { |
| 75 return command_line->GetSwitchValueASCII( |
| 76 chromeos::switches::kConsumerDeviceManagementUrl); |
| 77 } |
| 78 return kDefaultConsumerDeviceManagementServerUrl; |
| 79 }; |
| 80 |
| 61 } // namespace | 81 } // namespace |
| 62 | 82 |
| 63 BrowserPolicyConnectorChromeOS::BrowserPolicyConnectorChromeOS() | 83 BrowserPolicyConnectorChromeOS::BrowserPolicyConnectorChromeOS() |
| 64 : device_cloud_policy_manager_(NULL), | 84 : device_cloud_policy_manager_(NULL), |
| 65 global_user_cloud_policy_provider_(NULL), | 85 global_user_cloud_policy_provider_(NULL), |
| 66 weak_ptr_factory_(this) { | 86 weak_ptr_factory_(this) { |
| 67 if (g_testing_install_attributes) | 87 if (g_testing_install_attributes) |
| 68 install_attributes_.reset(g_testing_install_attributes); | 88 install_attributes_.reset(g_testing_install_attributes); |
| 69 | 89 |
| 70 // SystemSaltGetter or DBusThreadManager may be uninitialized on unit tests. | 90 // SystemSaltGetter or DBusThreadManager may be uninitialized on unit tests. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 global_user_cloud_policy_provider_)); | 123 global_user_cloud_policy_provider_)); |
| 104 } | 124 } |
| 105 | 125 |
| 106 BrowserPolicyConnectorChromeOS::~BrowserPolicyConnectorChromeOS() {} | 126 BrowserPolicyConnectorChromeOS::~BrowserPolicyConnectorChromeOS() {} |
| 107 | 127 |
| 108 void BrowserPolicyConnectorChromeOS::Init( | 128 void BrowserPolicyConnectorChromeOS::Init( |
| 109 PrefService* local_state, | 129 PrefService* local_state, |
| 110 scoped_refptr<net::URLRequestContextGetter> request_context) { | 130 scoped_refptr<net::URLRequestContextGetter> request_context) { |
| 111 ChromeBrowserPolicyConnector::Init(local_state, request_context); | 131 ChromeBrowserPolicyConnector::Init(local_state, request_context); |
| 112 | 132 |
| 133 scoped_ptr<DeviceManagementService::Configuration> configuration( |
| 134 new DeviceManagementServiceConfiguration( |
| 135 GetConsumerDeviceManagementServerUrl())); |
| 136 consumer_device_management_service_.reset( |
| 137 new DeviceManagementService(configuration.Pass())); |
| 138 consumer_device_management_service_->ScheduleInitialization( |
| 139 kServiceInitializationStartupDelay); |
| 140 |
| 113 if (device_cloud_policy_manager_) { | 141 if (device_cloud_policy_manager_) { |
| 114 // Note: for now the |device_cloud_policy_manager_| is using the global | 142 // Note: for now the |device_cloud_policy_manager_| is using the global |
| 115 // schema registry. Eventually it will have its own registry, once device | 143 // schema registry. Eventually it will have its own registry, once device |
| 116 // cloud policy for extensions is introduced. That means it'd have to be | 144 // cloud policy for extensions is introduced. That means it'd have to be |
| 117 // initialized from here instead of BrowserPolicyConnector::Init(). | 145 // initialized from here instead of BrowserPolicyConnector::Init(). |
| 118 | 146 |
| 119 scoped_ptr<CloudPolicyClient::StatusProvider> status_provider( | 147 scoped_ptr<CloudPolicyClient::StatusProvider> status_provider( |
| 120 new DeviceStatusCollector( | 148 new DeviceStatusCollector( |
| 121 local_state, | 149 local_state, |
| 122 chromeos::system::StatisticsProvider::GetInstance(), | 150 chromeos::system::StatisticsProvider::GetInstance(), |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 std::string timezone; | 264 std::string timezone; |
| 237 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, | 265 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, |
| 238 &timezone) && | 266 &timezone) && |
| 239 !timezone.empty()) { | 267 !timezone.empty()) { |
| 240 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 268 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 241 base::UTF8ToUTF16(timezone)); | 269 base::UTF8ToUTF16(timezone)); |
| 242 } | 270 } |
| 243 } | 271 } |
| 244 | 272 |
| 245 } // namespace policy | 273 } // namespace policy |
| OLD | NEW |