| 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 13 matching lines...) Expand all Loading... |
| 24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 25 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
| 26 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
| 27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/policy/async_policy_provider.h" | 28 #include "chrome/browser/policy/async_policy_provider.h" |
| 29 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 29 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
| 30 #include "chrome/browser/policy/cloud/cloud_policy_refresh_scheduler.h" | 30 #include "chrome/browser/policy/cloud/cloud_policy_refresh_scheduler.h" |
| 31 #include "chrome/browser/policy/cloud/cloud_policy_service.h" | 31 #include "chrome/browser/policy/cloud/cloud_policy_service.h" |
| 32 #include "chrome/browser/policy/cloud/device_management_service.h" | 32 #include "chrome/browser/policy/cloud/device_management_service.h" |
| 33 #include "chrome/browser/policy/configuration_policy_provider.h" | 33 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 34 #include "chrome/browser/policy/policy_domain_descriptor.h" | |
| 35 #include "chrome/browser/policy/policy_service_impl.h" | 34 #include "chrome/browser/policy/policy_service_impl.h" |
| 36 #include "chrome/browser/policy/policy_statistics_collector.h" | 35 #include "chrome/browser/policy/policy_statistics_collector.h" |
| 37 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
| 38 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
| 39 #include "chrome/common/chrome_version_info.h" | 38 #include "chrome/common/chrome_version_info.h" |
| 40 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 41 #include "components/policy/core/common/policy_namespace.h" | 40 #include "components/policy/core/common/policy_namespace.h" |
| 42 #include "components/policy/core/common/policy_pref_names.h" | 41 #include "components/policy/core/common/policy_pref_names.h" |
| 43 #include "components/policy/core/common/schema.h" | 42 #include "components/policy/core/common/schema.h" |
| 44 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 request_context_ = request_context; | 281 request_context_ = request_context; |
| 283 | 282 |
| 284 scoped_ptr<DeviceManagementService::Configuration> configuration( | 283 scoped_ptr<DeviceManagementService::Configuration> configuration( |
| 285 new DeviceManagementServiceConfiguration); | 284 new DeviceManagementServiceConfiguration); |
| 286 device_management_service_.reset( | 285 device_management_service_.reset( |
| 287 new DeviceManagementService(configuration.Pass(), request_context)); | 286 new DeviceManagementService(configuration.Pass(), request_context)); |
| 288 device_management_service_->ScheduleInitialization( | 287 device_management_service_->ScheduleInitialization( |
| 289 kServiceInitializationStartupDelay); | 288 kServiceInitializationStartupDelay); |
| 290 | 289 |
| 291 if (g_testing_provider) | 290 if (g_testing_provider) |
| 292 g_testing_provider->Init(); | 291 g_testing_provider->Init(GetSchemaRegistry()); |
| 293 if (platform_provider_) | 292 if (platform_provider_) |
| 294 platform_provider_->Init(); | 293 platform_provider_->Init(GetSchemaRegistry()); |
| 295 | 294 |
| 296 #if defined(OS_CHROMEOS) | 295 #if defined(OS_CHROMEOS) |
| 297 global_user_cloud_policy_provider_.Init(); | 296 global_user_cloud_policy_provider_.Init(GetSchemaRegistry()); |
| 298 | 297 |
| 299 if (device_cloud_policy_manager_) { | 298 if (device_cloud_policy_manager_) { |
| 300 device_cloud_policy_manager_->Init(); | 299 // For now the |device_cloud_policy_manager_| is using the global schema |
| 300 // registry. Eventually it will have its own registry, once device cloud |
| 301 // policy for extensions is introduced. |
| 302 device_cloud_policy_manager_->Init(GetSchemaRegistry()); |
| 301 scoped_ptr<CloudPolicyClient::StatusProvider> status_provider( | 303 scoped_ptr<CloudPolicyClient::StatusProvider> status_provider( |
| 302 new DeviceStatusCollector( | 304 new DeviceStatusCollector( |
| 303 local_state_, | 305 local_state_, |
| 304 chromeos::system::StatisticsProvider::GetInstance(), | 306 chromeos::system::StatisticsProvider::GetInstance(), |
| 305 NULL)); | 307 NULL)); |
| 306 device_cloud_policy_manager_->Connect( | 308 device_cloud_policy_manager_->Connect( |
| 307 local_state_, | 309 local_state_, |
| 308 device_management_service_.get(), | 310 device_management_service_.get(), |
| 309 status_provider.Pass()); | 311 status_provider.Pass()); |
| 310 } | 312 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 // |providers| in decreasing order of priority. | 434 // |providers| in decreasing order of priority. |
| 433 if (platform_provider_) | 435 if (platform_provider_) |
| 434 providers.push_back(platform_provider_.get()); | 436 providers.push_back(platform_provider_.get()); |
| 435 #if defined(OS_CHROMEOS) | 437 #if defined(OS_CHROMEOS) |
| 436 if (device_cloud_policy_manager_) | 438 if (device_cloud_policy_manager_) |
| 437 providers.push_back(device_cloud_policy_manager_.get()); | 439 providers.push_back(device_cloud_policy_manager_.get()); |
| 438 #endif | 440 #endif |
| 439 std::copy(additional_providers.begin(), additional_providers.end(), | 441 std::copy(additional_providers.begin(), additional_providers.end(), |
| 440 std::back_inserter(providers)); | 442 std::back_inserter(providers)); |
| 441 } | 443 } |
| 442 scoped_ptr<PolicyService> service(new PolicyServiceImpl(providers)); | 444 return scoped_ptr<PolicyService>(new PolicyServiceImpl(providers)); |
| 443 scoped_refptr<PolicyDomainDescriptor> descriptor = new PolicyDomainDescriptor( | |
| 444 POLICY_DOMAIN_CHROME); | |
| 445 descriptor->RegisterComponent("", Schema::Wrap(GetChromeSchemaData())); | |
| 446 service->RegisterPolicyDomain(descriptor); | |
| 447 return service.Pass(); | |
| 448 } | 445 } |
| 449 | 446 |
| 450 const ConfigurationPolicyHandlerList* | 447 const ConfigurationPolicyHandlerList* |
| 451 BrowserPolicyConnector::GetHandlerList() const { | 448 BrowserPolicyConnector::GetHandlerList() const { |
| 452 return handler_list_.get(); | 449 return handler_list_.get(); |
| 453 } | 450 } |
| 454 | 451 |
| 455 UserAffiliation BrowserPolicyConnector::GetUserAffiliation( | 452 UserAffiliation BrowserPolicyConnector::GetUserAffiliation( |
| 456 const std::string& user_name) { | 453 const std::string& user_name) { |
| 457 #if defined(OS_CHROMEOS) | 454 #if defined(OS_CHROMEOS) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 std::string timezone; | 577 std::string timezone; |
| 581 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, | 578 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, |
| 582 &timezone) && | 579 &timezone) && |
| 583 !timezone.empty()) { | 580 !timezone.empty()) { |
| 584 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 581 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 585 UTF8ToUTF16(timezone)); | 582 UTF8ToUTF16(timezone)); |
| 586 } | 583 } |
| 587 #endif | 584 #endif |
| 588 } | 585 } |
| 589 | 586 |
| 590 // static | |
| 591 ConfigurationPolicyProvider* BrowserPolicyConnector::CreatePlatformProvider() { | 587 ConfigurationPolicyProvider* BrowserPolicyConnector::CreatePlatformProvider() { |
| 592 #if defined(OS_WIN) | 588 #if defined(OS_WIN) |
| 593 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); | 589 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); |
| 594 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( | 590 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( |
| 595 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 591 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 596 policy_list)); | 592 policy_list)); |
| 597 return new AsyncPolicyProvider(loader.Pass()); | 593 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
| 598 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 594 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
| 599 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); | 595 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); |
| 600 scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderMac( | 596 scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderMac( |
| 601 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 597 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 602 policy_list, | 598 policy_list, |
| 603 GetManagedPolicyPath(), | 599 GetManagedPolicyPath(), |
| 604 new MacPreferences())); | 600 new MacPreferences())); |
| 605 return new AsyncPolicyProvider(loader.Pass()); | 601 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
| 606 #elif defined(OS_POSIX) && !defined(OS_ANDROID) | 602 #elif defined(OS_POSIX) && !defined(OS_ANDROID) |
| 607 base::FilePath config_dir_path; | 603 base::FilePath config_dir_path; |
| 608 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { | 604 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { |
| 609 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( | 605 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( |
| 610 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 606 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 611 config_dir_path, | 607 config_dir_path, |
| 612 POLICY_SCOPE_MACHINE)); | 608 POLICY_SCOPE_MACHINE)); |
| 613 return new AsyncPolicyProvider(loader.Pass()); | 609 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
| 614 } else { | 610 } else { |
| 615 return NULL; | 611 return NULL; |
| 616 } | 612 } |
| 617 #else | 613 #else |
| 618 return NULL; | 614 return NULL; |
| 619 #endif | 615 #endif |
| 620 } | 616 } |
| 621 | 617 |
| 622 } // namespace policy | 618 } // namespace policy |
| OLD | NEW |