| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
| 32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 33 #include "policy/policy_constants.h" | 33 #include "policy/policy_constants.h" |
| 34 | 34 |
| 35 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 36 #include "chrome/browser/policy/configuration_policy_provider_win.h" | 36 #include "chrome/browser/policy/configuration_policy_provider_win.h" |
| 37 #elif defined(OS_MACOSX) | 37 #elif defined(OS_MACOSX) |
| 38 #include "chrome/browser/policy/policy_loader_mac.h" | 38 #include "chrome/browser/policy/policy_loader_mac.h" |
| 39 #include "chrome/browser/preferences_mac.h" | 39 #include "chrome/browser/preferences_mac.h" |
| 40 #elif defined(OS_POSIX) | 40 #elif defined(OS_POSIX) |
| 41 #include "chrome/browser/policy/config_dir_policy_provider.h" | 41 #include "chrome/browser/policy/config_dir_policy_loader.h" |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 45 #include "chrome/browser/chromeos/cros/cros_library.h" | 45 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 46 #include "chrome/browser/chromeos/system/statistics_provider.h" | 46 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 47 #include "chrome/browser/policy/app_pack_updater.h" | 47 #include "chrome/browser/policy/app_pack_updater.h" |
| 48 #include "chrome/browser/policy/cros_user_policy_cache.h" | 48 #include "chrome/browser/policy/cros_user_policy_cache.h" |
| 49 #include "chrome/browser/policy/device_policy_cache.h" | 49 #include "chrome/browser/policy/device_policy_cache.h" |
| 50 #include "chromeos/dbus/dbus_thread_manager.h" | 50 #include "chromeos/dbus/dbus_thread_manager.h" |
| 51 #endif | 51 #endif |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 user_data_store_.reset(); | 113 user_data_store_.reset(); |
| 114 | 114 |
| 115 if (user_cloud_policy_manager_.get()) | 115 if (user_cloud_policy_manager_.get()) |
| 116 user_cloud_policy_manager_->Shutdown(); | 116 user_cloud_policy_manager_->Shutdown(); |
| 117 user_cloud_policy_manager_.reset(); | 117 user_cloud_policy_manager_.reset(); |
| 118 | 118 |
| 119 device_management_service_.reset(); | 119 device_management_service_.reset(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void BrowserPolicyConnector::Init() { | 122 void BrowserPolicyConnector::Init() { |
| 123 managed_platform_provider_.reset(CreateManagedPlatformProvider()); | 123 platform_provider_.reset(CreatePlatformProvider()); |
| 124 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); | |
| 125 | 124 |
| 126 #if defined(OS_CHROMEOS) | 125 #if defined(OS_CHROMEOS) |
| 127 // The CloudPolicyProvider blocks asynchronous Profile creation until a login | 126 // The CloudPolicyProvider blocks asynchronous Profile creation until a login |
| 128 // is performed. This is used to ensure that the Profile's PrefService sees | 127 // is performed. This is used to ensure that the Profile's PrefService sees |
| 129 // managed preferences on managed Chrome OS devices. However, this also | 128 // managed preferences on managed Chrome OS devices. However, this also |
| 130 // prevents creation of new Profiles in Desktop Chrome. The implementation of | 129 // prevents creation of new Profiles in Desktop Chrome. The implementation of |
| 131 // cloud policy on the Desktop requires a refactoring of the cloud provider, | 130 // cloud policy on the Desktop requires a refactoring of the cloud provider, |
| 132 // but for now it just isn't created. | 131 // but for now it just isn't created. |
| 133 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 132 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 134 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 133 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 156 FROM_HERE, | 155 FROM_HERE, |
| 157 base::Bind(base::IgnoreResult(&BrowserPolicyConnector::GetAppPackUpdater), | 156 base::Bind(base::IgnoreResult(&BrowserPolicyConnector::GetAppPackUpdater), |
| 158 weak_ptr_factory_.GetWeakPtr())); | 157 weak_ptr_factory_.GetWeakPtr())); |
| 159 #endif | 158 #endif |
| 160 } | 159 } |
| 161 | 160 |
| 162 PolicyService* BrowserPolicyConnector::CreatePolicyService( | 161 PolicyService* BrowserPolicyConnector::CreatePolicyService( |
| 163 Profile* profile) { | 162 Profile* profile) { |
| 164 // |providers| in decreasing order of priority. | 163 // |providers| in decreasing order of priority. |
| 165 PolicyServiceImpl::Providers providers; | 164 PolicyServiceImpl::Providers providers; |
| 166 if (managed_platform_provider_.get()) | 165 if (platform_provider_.get()) |
| 167 providers.push_back(managed_platform_provider_.get()); | 166 providers.push_back(platform_provider_.get()); |
| 168 if (managed_cloud_provider_.get()) | 167 if (managed_cloud_provider_.get()) |
| 169 providers.push_back(managed_cloud_provider_.get()); | 168 providers.push_back(managed_cloud_provider_.get()); |
| 170 if (recommended_platform_provider_.get()) | |
| 171 providers.push_back(recommended_platform_provider_.get()); | |
| 172 if (recommended_cloud_provider_.get()) | 169 if (recommended_cloud_provider_.get()) |
| 173 providers.push_back(recommended_cloud_provider_.get()); | 170 providers.push_back(recommended_cloud_provider_.get()); |
| 174 | 171 |
| 175 // The global policy service uses the proxy provider to allow for swapping in | 172 // The global policy service uses the proxy provider to allow for swapping in |
| 176 // user policy after startup, while profiles use |user_cloud_policy_manager_| | 173 // user policy after startup, while profiles use |user_cloud_policy_manager_| |
| 177 // directly as their provider, which may also block initialization on a policy | 174 // directly as their provider, which may also block initialization on a policy |
| 178 // fetch at login time. | 175 // fetch at login time. |
| 179 if (profile) { | 176 if (profile) { |
| 180 if (user_cloud_policy_manager_.get()) | 177 if (user_cloud_policy_manager_.get()) |
| 181 providers.push_back(user_cloud_policy_manager_.get()); | 178 providers.push_back(user_cloud_policy_manager_.get()); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 device_data_store_->set_device_status_collector( | 547 device_data_store_->set_device_status_collector( |
| 551 new DeviceStatusCollector( | 548 new DeviceStatusCollector( |
| 552 g_browser_process->local_state(), | 549 g_browser_process->local_state(), |
| 553 chromeos::system::StatisticsProvider::GetInstance(), | 550 chromeos::system::StatisticsProvider::GetInstance(), |
| 554 NULL)); | 551 NULL)); |
| 555 #endif | 552 #endif |
| 556 } | 553 } |
| 557 | 554 |
| 558 // static | 555 // static |
| 559 ConfigurationPolicyProvider* | 556 ConfigurationPolicyProvider* |
| 560 BrowserPolicyConnector::CreateManagedPlatformProvider() { | 557 BrowserPolicyConnector::CreatePlatformProvider() { |
| 561 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); | 558 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); |
| 562 #if defined(OS_WIN) | 559 #if defined(OS_WIN) |
| 563 return new ConfigurationPolicyProviderWin(policy_list); | 560 return new ConfigurationPolicyProviderWin(policy_list); |
| 564 #elif defined(OS_MACOSX) | 561 #elif defined(OS_MACOSX) |
| 565 scoped_ptr<AsyncPolicyLoader> loader( | 562 scoped_ptr<AsyncPolicyLoader> loader( |
| 566 new PolicyLoaderMac(policy_list, new MacPreferences())); | 563 new PolicyLoaderMac(policy_list, new MacPreferences())); |
| 567 return new AsyncPolicyProvider(policy_list, loader.Pass()); | 564 return new AsyncPolicyProvider(policy_list, loader.Pass()); |
| 568 #elif defined(OS_POSIX) | 565 #elif defined(OS_POSIX) |
| 569 FilePath config_dir_path; | 566 FilePath config_dir_path; |
| 570 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { | 567 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { |
| 571 return new ConfigDirPolicyProvider( | 568 scoped_ptr<AsyncPolicyLoader> loader( |
| 572 policy_list, | 569 new ConfigDirPolicyLoader(config_dir_path, POLICY_SCOPE_MACHINE)); |
| 573 POLICY_LEVEL_MANDATORY, | 570 return new AsyncPolicyProvider(policy_list, loader.Pass()); |
| 574 POLICY_SCOPE_MACHINE, | |
| 575 config_dir_path.Append(FILE_PATH_LITERAL("managed"))); | |
| 576 } else { | 571 } else { |
| 577 return NULL; | 572 return NULL; |
| 578 } | 573 } |
| 579 #else | |
| 580 return NULL; | |
| 581 #endif | |
| 582 } | |
| 583 | |
| 584 // static | |
| 585 ConfigurationPolicyProvider* | |
| 586 BrowserPolicyConnector::CreateRecommendedPlatformProvider() { | |
| 587 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 588 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); | |
| 589 FilePath config_dir_path; | |
| 590 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { | |
| 591 return new ConfigDirPolicyProvider( | |
| 592 policy_list, | |
| 593 POLICY_LEVEL_RECOMMENDED, | |
| 594 POLICY_SCOPE_MACHINE, | |
| 595 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); | |
| 596 } else { | |
| 597 return NULL; | |
| 598 } | |
| 599 #else | 574 #else |
| 600 return NULL; | 575 return NULL; |
| 601 #endif | 576 #endif |
| 602 } | 577 } |
| 603 | 578 |
| 604 } // namespace policy | 579 } // namespace policy |
| OLD | NEW |