Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/policy/browser_policy_connector.h" | 5 #include "chrome/browser/policy/browser_policy_connector.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "chrome/browser/policy/cloud/cloud_policy_service.h" | 27 #include "chrome/browser/policy/cloud/cloud_policy_service.h" |
| 28 #include "chrome/browser/policy/cloud/device_management_service.h" | 28 #include "chrome/browser/policy/cloud/device_management_service.h" |
| 29 #include "chrome/browser/policy/configuration_policy_provider.h" | 29 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 30 #include "chrome/browser/policy/managed_mode_policy_provider.h" | 30 #include "chrome/browser/policy/managed_mode_policy_provider.h" |
| 31 #include "chrome/browser/policy/policy_domain_descriptor.h" | 31 #include "chrome/browser/policy/policy_domain_descriptor.h" |
| 32 #include "chrome/browser/policy/policy_service_impl.h" | 32 #include "chrome/browser/policy/policy_service_impl.h" |
| 33 #include "chrome/browser/policy/policy_statistics_collector.h" | 33 #include "chrome/browser/policy/policy_statistics_collector.h" |
| 34 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
| 35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
| 37 #include "components/policy/core/common/policy_schema.h" | |
| 37 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 38 #include "google_apis/gaia/gaia_auth_util.h" | 39 #include "google_apis/gaia/gaia_auth_util.h" |
| 39 #include "google_apis/gaia/gaia_constants.h" | 40 #include "google_apis/gaia/gaia_constants.h" |
| 40 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
| 41 #include "net/url_request/url_request_context_getter.h" | 42 #include "net/url_request/url_request_context_getter.h" |
| 42 #include "policy/policy_constants.h" | 43 #include "policy/policy_constants.h" |
| 43 #include "third_party/icu/source/i18n/unicode/regex.h" | 44 #include "third_party/icu/source/i18n/unicode/regex.h" |
| 44 | 45 |
| 45 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 46 #include "chrome/browser/policy/policy_loader_win.h" | 47 #include "chrome/browser/policy/policy_loader_win.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 // Delay in milliseconds from startup. | 88 // Delay in milliseconds from startup. |
| 88 const int64 kServiceInitializationStartupDelay = 5000; | 89 const int64 kServiceInitializationStartupDelay = 5000; |
| 89 | 90 |
| 90 // The URL for the device management server. | 91 // The URL for the device management server. |
| 91 const char kDefaultDeviceManagementServerUrl[] = | 92 const char kDefaultDeviceManagementServerUrl[] = |
| 92 "https://m.google.com/devicemanagement/data/api"; | 93 "https://m.google.com/devicemanagement/data/api"; |
| 93 | 94 |
| 94 // Used in BrowserPolicyConnector::SetPolicyProviderForTesting. | 95 // Used in BrowserPolicyConnector::SetPolicyProviderForTesting. |
| 95 ConfigurationPolicyProvider* g_testing_provider = NULL; | 96 ConfigurationPolicyProvider* g_testing_provider = NULL; |
| 96 | 97 |
| 97 | |
| 98 #if defined(OS_MACOSX) && !defined(OS_IOS) | 98 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 99 base::FilePath GetManagedPolicyPath() { | 99 base::FilePath GetManagedPolicyPath() { |
| 100 // This constructs the path to the plist file in which Mac OS X stores the | 100 // This constructs the path to the plist file in which Mac OS X stores the |
| 101 // managed preference for the application. This is undocumented and therefore | 101 // managed preference for the application. This is undocumented and therefore |
| 102 // fragile, but if it doesn't work out, AsyncPolicyLoader has a task that | 102 // fragile, but if it doesn't work out, AsyncPolicyLoader has a task that |
| 103 // polls periodically in order to reload managed preferences later even if we | 103 // polls periodically in order to reload managed preferences later even if we |
| 104 // missed the change. | 104 // missed the change. |
| 105 base::FilePath path; | 105 base::FilePath path; |
| 106 if (!PathService::Get(chrome::DIR_MANAGED_PREFS, &path)) | 106 if (!PathService::Get(chrome::DIR_MANAGED_PREFS, &path)) |
| 107 return base::FilePath(); | 107 return base::FilePath(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_cloud_policy_store( | 152 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_cloud_policy_store( |
| 153 new DeviceCloudPolicyStoreChromeOS( | 153 new DeviceCloudPolicyStoreChromeOS( |
| 154 chromeos::DeviceSettingsService::Get(), | 154 chromeos::DeviceSettingsService::Get(), |
| 155 install_attributes_.get())); | 155 install_attributes_.get())); |
| 156 device_cloud_policy_manager_.reset( | 156 device_cloud_policy_manager_.reset( |
| 157 new DeviceCloudPolicyManagerChromeOS( | 157 new DeviceCloudPolicyManagerChromeOS( |
| 158 device_cloud_policy_store.Pass(), | 158 device_cloud_policy_store.Pass(), |
| 159 install_attributes_.get())); | 159 install_attributes_.get())); |
| 160 } | 160 } |
| 161 #endif | 161 #endif |
| 162 | |
| 163 std::vector<ConfigurationPolicyProvider*> providers; | |
| 164 #if defined(OS_CHROMEOS) | |
| 165 providers.push_back(&global_user_cloud_policy_provider_); | |
| 166 #endif | |
| 167 policy_service_ = CreatePolicyService(providers); | |
| 168 platform_provider_->InitialLoad(); | |
| 162 } | 169 } |
| 163 | 170 |
| 164 BrowserPolicyConnector::~BrowserPolicyConnector() { | 171 BrowserPolicyConnector::~BrowserPolicyConnector() { |
| 165 if (is_initialized()) { | 172 if (is_initialized()) { |
| 166 // Shutdown() wasn't invoked by our owner after having called Init(). | 173 // Shutdown() wasn't invoked by our owner after having called Init(). |
| 167 // This usually means it's an early shutdown and | 174 // This usually means it's an early shutdown and |
| 168 // BrowserProcessImpl::StartTearDown() wasn't invoked. | 175 // BrowserProcessImpl::StartTearDown() wasn't invoked. |
| 169 // Cleanup properly in those cases and avoid crashing the ToastCrasher test. | 176 // Cleanup properly in those cases and avoid crashing the ToastCrasher test. |
| 170 Shutdown(); | 177 Shutdown(); |
| 171 } | 178 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 device_local_account_policy_service_->Disconnect(); | 273 device_local_account_policy_service_->Disconnect(); |
| 267 global_user_cloud_policy_provider_.Shutdown(); | 274 global_user_cloud_policy_provider_.Shutdown(); |
| 268 #endif | 275 #endif |
| 269 | 276 |
| 270 device_management_service_.reset(); | 277 device_management_service_.reset(); |
| 271 | 278 |
| 272 request_context_ = NULL; | 279 request_context_ = NULL; |
| 273 } | 280 } |
| 274 | 281 |
| 275 PolicyService* BrowserPolicyConnector::GetPolicyService() { | 282 PolicyService* BrowserPolicyConnector::GetPolicyService() { |
| 276 if (!policy_service_) { | |
| 277 std::vector<ConfigurationPolicyProvider*> providers; | |
| 278 #if defined(OS_CHROMEOS) | |
| 279 providers.push_back(&global_user_cloud_policy_provider_); | |
| 280 #endif | |
| 281 policy_service_ = CreatePolicyService(providers); | |
| 282 } | |
| 283 return policy_service_.get(); | 283 return policy_service_.get(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 #if defined(OS_CHROMEOS) | 286 #if defined(OS_CHROMEOS) |
| 287 bool BrowserPolicyConnector::IsEnterpriseManaged() { | 287 bool BrowserPolicyConnector::IsEnterpriseManaged() { |
| 288 return install_attributes_ && install_attributes_->IsEnterpriseDevice(); | 288 return install_attributes_ && install_attributes_->IsEnterpriseDevice(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 std::string BrowserPolicyConnector::GetEnterpriseDomain() { | 291 std::string BrowserPolicyConnector::GetEnterpriseDomain() { |
| 292 return install_attributes_ ? install_attributes_->GetDomain() : std::string(); | 292 return install_attributes_ ? install_attributes_->GetDomain() : std::string(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 316 if (platform_provider_) | 316 if (platform_provider_) |
| 317 providers.push_back(platform_provider_.get()); | 317 providers.push_back(platform_provider_.get()); |
| 318 #if defined(OS_CHROMEOS) | 318 #if defined(OS_CHROMEOS) |
| 319 if (device_cloud_policy_manager_) | 319 if (device_cloud_policy_manager_) |
| 320 providers.push_back(device_cloud_policy_manager_.get()); | 320 providers.push_back(device_cloud_policy_manager_.get()); |
| 321 #endif | 321 #endif |
| 322 std::copy(additional_providers.begin(), additional_providers.end(), | 322 std::copy(additional_providers.begin(), additional_providers.end(), |
| 323 std::back_inserter(providers)); | 323 std::back_inserter(providers)); |
| 324 } | 324 } |
| 325 scoped_ptr<PolicyService> service(new PolicyServiceImpl(providers)); | 325 scoped_ptr<PolicyService> service(new PolicyServiceImpl(providers)); |
| 326 | |
| 327 // Create the global descriptor. | |
| 326 scoped_refptr<PolicyDomainDescriptor> descriptor = new PolicyDomainDescriptor( | 328 scoped_refptr<PolicyDomainDescriptor> descriptor = new PolicyDomainDescriptor( |
| 327 POLICY_DOMAIN_CHROME); | 329 POLICY_DOMAIN_CHROME); |
| 328 service->RegisterPolicyDomain(descriptor); | 330 std::string err; |
| 331 scoped_ptr<PolicySchema> schema = PolicySchema::Parse(kPolicyJsonSchema, | |
| 332 &err); | |
| 333 CHECK(err == "") << err; | |
|
Joao da Silva
2013/09/11 13:32:02
CHECK(schema) << err
| |
| 334 descriptor->RegisterComponent("", schema.Pass()); | |
| 335 service->InitialRegisterPolicyDomain(descriptor); | |
| 329 return service.Pass(); | 336 return service.Pass(); |
| 330 } | 337 } |
| 331 | 338 |
| 332 const ConfigurationPolicyHandlerList* | 339 const ConfigurationPolicyHandlerList* |
| 333 BrowserPolicyConnector::GetHandlerList() const { | 340 BrowserPolicyConnector::GetHandlerList() const { |
| 334 return &handler_list_; | 341 return &handler_list_; |
| 335 } | 342 } |
| 336 | 343 |
| 337 UserAffiliation BrowserPolicyConnector::GetUserAffiliation( | 344 UserAffiliation BrowserPolicyConnector::GetUserAffiliation( |
| 338 const std::string& user_name) { | 345 const std::string& user_name) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 return new AsyncPolicyProvider(loader.Pass()); | 505 return new AsyncPolicyProvider(loader.Pass()); |
| 499 } else { | 506 } else { |
| 500 return NULL; | 507 return NULL; |
| 501 } | 508 } |
| 502 #else | 509 #else |
| 503 return NULL; | 510 return NULL; |
| 504 #endif | 511 #endif |
| 505 } | 512 } |
| 506 | 513 |
| 507 } // namespace policy | 514 } // namespace policy |
| OLD | NEW |