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