| 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 14 matching lines...) Expand all Loading... |
| 25 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
| 26 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
| 27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 28 #include "policy/policy_constants.h" | 28 #include "policy/policy_constants.h" |
| 29 | 29 |
| 30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 31 #include "chrome/browser/policy/configuration_policy_provider_win.h" | 31 #include "chrome/browser/policy/configuration_policy_provider_win.h" |
| 32 #elif defined(OS_MACOSX) | 32 #elif defined(OS_MACOSX) |
| 33 #include "chrome/browser/policy/policy_loader_mac.h" | 33 #include "chrome/browser/policy/policy_loader_mac.h" |
| 34 #elif defined(OS_POSIX) | 34 #elif defined(OS_POSIX) |
| 35 #include "chrome/browser/policy/config_dir_policy_provider.h" | 35 #include "chrome/browser/policy/config_dir_policy_loader.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #if defined(OS_CHROMEOS) | 38 #if defined(OS_CHROMEOS) |
| 39 #include "chrome/browser/chromeos/cros/cros_library.h" | 39 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 40 #include "chrome/browser/chromeos/system/statistics_provider.h" | 40 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 41 #include "chrome/browser/policy/app_pack_updater.h" | 41 #include "chrome/browser/policy/app_pack_updater.h" |
| 42 #include "chrome/browser/policy/cros_user_policy_cache.h" | 42 #include "chrome/browser/policy/cros_user_policy_cache.h" |
| 43 #include "chrome/browser/policy/device_policy_cache.h" | 43 #include "chrome/browser/policy/device_policy_cache.h" |
| 44 #include "chromeos/dbus/dbus_thread_manager.h" | 44 #include "chromeos/dbus/dbus_thread_manager.h" |
| 45 #endif | 45 #endif |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 user_cloud_policy_subsystem_->Shutdown(); | 104 user_cloud_policy_subsystem_->Shutdown(); |
| 105 user_cloud_policy_subsystem_.reset(); | 105 user_cloud_policy_subsystem_.reset(); |
| 106 user_policy_token_cache_.reset(); | 106 user_policy_token_cache_.reset(); |
| 107 user_data_store_.reset(); | 107 user_data_store_.reset(); |
| 108 | 108 |
| 109 // Delete the providers while the |handler_list_| is still valid, since | 109 // Delete the providers while the |handler_list_| is still valid, since |
| 110 // OnProviderGoingAway() can trigger refreshes at the | 110 // OnProviderGoingAway() can trigger refreshes at the |
| 111 // ConfigurationPolicyPrefStore. | 111 // ConfigurationPolicyPrefStore. |
| 112 recommended_cloud_provider_.reset(); | 112 recommended_cloud_provider_.reset(); |
| 113 managed_cloud_provider_.reset(); | 113 managed_cloud_provider_.reset(); |
| 114 recommended_platform_provider_.reset(); | 114 platform_provider_.reset(); |
| 115 managed_platform_provider_.reset(); | |
| 116 } | 115 } |
| 117 | 116 |
| 118 void BrowserPolicyConnector::Init() { | 117 void BrowserPolicyConnector::Init() { |
| 119 managed_platform_provider_.reset(CreateManagedPlatformProvider()); | 118 platform_provider_.reset(CreatePlatformProvider()); |
| 120 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); | |
| 121 | 119 |
| 122 #if defined(OS_CHROMEOS) | 120 #if defined(OS_CHROMEOS) |
| 123 // The CloudPolicyProvider blocks asynchronous Profile creation until a login | 121 // The CloudPolicyProvider blocks asynchronous Profile creation until a login |
| 124 // is performed. This is used to ensure that the Profile's PrefService sees | 122 // is performed. This is used to ensure that the Profile's PrefService sees |
| 125 // managed preferences on managed Chrome OS devices. However, this also | 123 // managed preferences on managed Chrome OS devices. However, this also |
| 126 // prevents creation of new Profiles in Desktop Chrome. The implementation of | 124 // prevents creation of new Profiles in Desktop Chrome. The implementation of |
| 127 // cloud policy on the Desktop requires a refactoring of the cloud provider, | 125 // cloud policy on the Desktop requires a refactoring of the cloud provider, |
| 128 // but for now it just isn't created. | 126 // but for now it just isn't created. |
| 129 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 127 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 130 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 128 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 147 FROM_HERE, | 145 FROM_HERE, |
| 148 base::Bind(base::IgnoreResult(&BrowserPolicyConnector::GetAppPackUpdater), | 146 base::Bind(base::IgnoreResult(&BrowserPolicyConnector::GetAppPackUpdater), |
| 149 weak_ptr_factory_.GetWeakPtr())); | 147 weak_ptr_factory_.GetWeakPtr())); |
| 150 #endif | 148 #endif |
| 151 } | 149 } |
| 152 | 150 |
| 153 PolicyService* BrowserPolicyConnector::CreatePolicyService( | 151 PolicyService* BrowserPolicyConnector::CreatePolicyService( |
| 154 Profile* profile) const { | 152 Profile* profile) const { |
| 155 // |providers| in decreasing order of priority. | 153 // |providers| in decreasing order of priority. |
| 156 PolicyServiceImpl::Providers providers; | 154 PolicyServiceImpl::Providers providers; |
| 157 if (managed_platform_provider_.get()) | 155 if (platform_provider_.get()) |
| 158 providers.push_back(managed_platform_provider_.get()); | 156 providers.push_back(platform_provider_.get()); |
| 159 if (managed_cloud_provider_.get()) | 157 if (managed_cloud_provider_.get()) |
| 160 providers.push_back(managed_cloud_provider_.get()); | 158 providers.push_back(managed_cloud_provider_.get()); |
| 161 if (recommended_platform_provider_.get()) | |
| 162 providers.push_back(recommended_platform_provider_.get()); | |
| 163 if (recommended_cloud_provider_.get()) | 159 if (recommended_cloud_provider_.get()) |
| 164 providers.push_back(recommended_cloud_provider_.get()); | 160 providers.push_back(recommended_cloud_provider_.get()); |
| 165 return new PolicyServiceImpl(providers); | 161 return new PolicyServiceImpl(providers); |
| 166 } | 162 } |
| 167 | 163 |
| 168 void BrowserPolicyConnector::RegisterForDevicePolicy( | 164 void BrowserPolicyConnector::RegisterForDevicePolicy( |
| 169 const std::string& owner_email, | 165 const std::string& owner_email, |
| 170 const std::string& token, | 166 const std::string& token, |
| 171 bool known_machine_id) { | 167 bool known_machine_id) { |
| 172 #if defined(OS_CHROMEOS) | 168 #if defined(OS_CHROMEOS) |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 device_data_store_->set_device_status_collector( | 491 device_data_store_->set_device_status_collector( |
| 496 new DeviceStatusCollector( | 492 new DeviceStatusCollector( |
| 497 g_browser_process->local_state(), | 493 g_browser_process->local_state(), |
| 498 chromeos::system::StatisticsProvider::GetInstance(), | 494 chromeos::system::StatisticsProvider::GetInstance(), |
| 499 NULL)); | 495 NULL)); |
| 500 #endif | 496 #endif |
| 501 } | 497 } |
| 502 | 498 |
| 503 // static | 499 // static |
| 504 ConfigurationPolicyProvider* | 500 ConfigurationPolicyProvider* |
| 505 BrowserPolicyConnector::CreateManagedPlatformProvider() { | 501 BrowserPolicyConnector::CreatePlatformProvider() { |
| 506 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); | 502 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); |
| 507 #if defined(OS_WIN) | 503 #if defined(OS_WIN) |
| 508 return new ConfigurationPolicyProviderWin(policy_list); | 504 return new ConfigurationPolicyProviderWin(policy_list); |
| 509 #elif defined(OS_MACOSX) | 505 #elif defined(OS_MACOSX) |
| 510 return MacPolicyLoader::CreateProvider(policy_list); | 506 return MacPolicyLoader::CreateProvider(policy_list); |
| 511 #elif defined(OS_POSIX) | 507 #elif defined(OS_POSIX) |
| 512 FilePath config_dir_path; | 508 FilePath config_dir_path; |
| 513 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { | 509 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { |
| 514 return new ConfigDirPolicyProvider( | 510 return ConfigDirPolicyLoader::CreateProvider( |
| 515 policy_list, | 511 policy_list, |
| 516 POLICY_LEVEL_MANDATORY, | |
| 517 POLICY_SCOPE_MACHINE, | 512 POLICY_SCOPE_MACHINE, |
| 518 config_dir_path.Append(FILE_PATH_LITERAL("managed"))); | 513 config_dir_path); |
| 519 } else { | 514 } else { |
| 520 return NULL; | 515 return NULL; |
| 521 } | 516 } |
| 522 #else | |
| 523 return NULL; | |
| 524 #endif | |
| 525 } | |
| 526 | |
| 527 // static | |
| 528 ConfigurationPolicyProvider* | |
| 529 BrowserPolicyConnector::CreateRecommendedPlatformProvider() { | |
| 530 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 531 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); | |
| 532 FilePath config_dir_path; | |
| 533 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { | |
| 534 return new ConfigDirPolicyProvider( | |
| 535 policy_list, | |
| 536 POLICY_LEVEL_RECOMMENDED, | |
| 537 POLICY_SCOPE_MACHINE, | |
| 538 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); | |
| 539 } else { | |
| 540 return NULL; | |
| 541 } | |
| 542 #else | 517 #else |
| 543 return NULL; | 518 return NULL; |
| 544 #endif | 519 #endif |
| 545 } | 520 } |
| 546 | 521 |
| 547 } // namespace policy | 522 } // namespace policy |
| OLD | NEW |