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_pref_names.h" | 40 #include "components/policy/core/common/policy_pref_names.h" |
42 #include "components/policy/core/common/schema.h" | 41 #include "components/policy/core/common/schema.h" |
43 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
44 #include "content/public/common/content_client.h" | 43 #include "content/public/common/content_client.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 request_context_ = request_context; | 278 request_context_ = request_context; |
280 | 279 |
281 scoped_ptr<DeviceManagementService::Configuration> configuration( | 280 scoped_ptr<DeviceManagementService::Configuration> configuration( |
282 new DeviceManagementServiceConfiguration); | 281 new DeviceManagementServiceConfiguration); |
283 device_management_service_.reset( | 282 device_management_service_.reset( |
284 new DeviceManagementService(configuration.Pass(), request_context)); | 283 new DeviceManagementService(configuration.Pass(), request_context)); |
285 device_management_service_->ScheduleInitialization( | 284 device_management_service_->ScheduleInitialization( |
286 kServiceInitializationStartupDelay); | 285 kServiceInitializationStartupDelay); |
287 | 286 |
288 if (g_testing_provider) | 287 if (g_testing_provider) |
289 g_testing_provider->Init(); | 288 g_testing_provider->Init(GetSchemaRegistry()); |
290 if (platform_provider_) | 289 if (platform_provider_) |
291 platform_provider_->Init(); | 290 platform_provider_->Init(GetSchemaRegistry()); |
292 | 291 |
293 #if defined(OS_CHROMEOS) | 292 #if defined(OS_CHROMEOS) |
294 global_user_cloud_policy_provider_.Init(); | 293 global_user_cloud_policy_provider_.Init(GetSchemaRegistry()); |
295 | 294 |
296 if (device_cloud_policy_manager_) { | 295 if (device_cloud_policy_manager_) { |
297 device_cloud_policy_manager_->Init(); | 296 // For now the |device_cloud_policy_manager_| is using the global schema |
| 297 // registry. Eventually it will have its own registry, once device cloud |
| 298 // policy for extensions is introduced. |
| 299 device_cloud_policy_manager_->Init(GetSchemaRegistry()); |
298 scoped_ptr<CloudPolicyClient::StatusProvider> status_provider( | 300 scoped_ptr<CloudPolicyClient::StatusProvider> status_provider( |
299 new DeviceStatusCollector( | 301 new DeviceStatusCollector( |
300 local_state_, | 302 local_state_, |
301 chromeos::system::StatisticsProvider::GetInstance(), | 303 chromeos::system::StatisticsProvider::GetInstance(), |
302 NULL)); | 304 NULL)); |
303 device_cloud_policy_manager_->Connect( | 305 device_cloud_policy_manager_->Connect( |
304 local_state_, | 306 local_state_, |
305 device_management_service_.get(), | 307 device_management_service_.get(), |
306 status_provider.Pass()); | 308 status_provider.Pass()); |
307 } | 309 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 // |providers| in decreasing order of priority. | 427 // |providers| in decreasing order of priority. |
426 if (platform_provider_) | 428 if (platform_provider_) |
427 providers.push_back(platform_provider_.get()); | 429 providers.push_back(platform_provider_.get()); |
428 #if defined(OS_CHROMEOS) | 430 #if defined(OS_CHROMEOS) |
429 if (device_cloud_policy_manager_) | 431 if (device_cloud_policy_manager_) |
430 providers.push_back(device_cloud_policy_manager_.get()); | 432 providers.push_back(device_cloud_policy_manager_.get()); |
431 #endif | 433 #endif |
432 std::copy(additional_providers.begin(), additional_providers.end(), | 434 std::copy(additional_providers.begin(), additional_providers.end(), |
433 std::back_inserter(providers)); | 435 std::back_inserter(providers)); |
434 } | 436 } |
435 scoped_ptr<PolicyService> service(new PolicyServiceImpl(providers)); | 437 return scoped_ptr<PolicyService>(new PolicyServiceImpl(providers)); |
436 scoped_refptr<PolicyDomainDescriptor> descriptor = new PolicyDomainDescriptor( | |
437 POLICY_DOMAIN_CHROME); | |
438 descriptor->RegisterComponent("", Schema::Wrap(GetChromeSchemaData())); | |
439 service->RegisterPolicyDomain(descriptor); | |
440 return service.Pass(); | |
441 } | 438 } |
442 | 439 |
443 const ConfigurationPolicyHandlerList* | 440 const ConfigurationPolicyHandlerList* |
444 BrowserPolicyConnector::GetHandlerList() const { | 441 BrowserPolicyConnector::GetHandlerList() const { |
445 return handler_list_.get(); | 442 return handler_list_.get(); |
446 } | 443 } |
447 | 444 |
448 UserAffiliation BrowserPolicyConnector::GetUserAffiliation( | 445 UserAffiliation BrowserPolicyConnector::GetUserAffiliation( |
449 const std::string& user_name) { | 446 const std::string& user_name) { |
450 #if defined(OS_CHROMEOS) | 447 #if defined(OS_CHROMEOS) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 std::string timezone; | 570 std::string timezone; |
574 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, | 571 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, |
575 &timezone) && | 572 &timezone) && |
576 !timezone.empty()) { | 573 !timezone.empty()) { |
577 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 574 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
578 UTF8ToUTF16(timezone)); | 575 UTF8ToUTF16(timezone)); |
579 } | 576 } |
580 #endif | 577 #endif |
581 } | 578 } |
582 | 579 |
583 // static | |
584 ConfigurationPolicyProvider* BrowserPolicyConnector::CreatePlatformProvider() { | 580 ConfigurationPolicyProvider* BrowserPolicyConnector::CreatePlatformProvider() { |
585 #if defined(OS_WIN) | 581 #if defined(OS_WIN) |
586 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); | 582 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); |
587 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( | 583 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( |
588 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 584 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
589 policy_list)); | 585 policy_list)); |
590 return new AsyncPolicyProvider(loader.Pass()); | 586 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
591 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 587 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
592 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); | 588 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); |
593 scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderMac( | 589 scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderMac( |
594 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 590 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
595 policy_list, | 591 policy_list, |
596 GetManagedPolicyPath(), | 592 GetManagedPolicyPath(), |
597 new MacPreferences())); | 593 new MacPreferences())); |
598 return new AsyncPolicyProvider(loader.Pass()); | 594 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
599 #elif defined(OS_POSIX) && !defined(OS_ANDROID) | 595 #elif defined(OS_POSIX) && !defined(OS_ANDROID) |
600 base::FilePath config_dir_path; | 596 base::FilePath config_dir_path; |
601 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { | 597 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { |
602 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( | 598 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( |
603 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 599 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
604 config_dir_path, | 600 config_dir_path, |
605 POLICY_SCOPE_MACHINE)); | 601 POLICY_SCOPE_MACHINE)); |
606 return new AsyncPolicyProvider(loader.Pass()); | 602 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
607 } else { | 603 } else { |
608 return NULL; | 604 return NULL; |
609 } | 605 } |
610 #else | 606 #else |
611 return NULL; | 607 return NULL; |
612 #endif | 608 #endif |
613 } | 609 } |
614 | 610 |
615 } // namespace policy | 611 } // namespace policy |
OLD | NEW |