| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/policy/cloud_policy_provider.h" | 13 #include "chrome/browser/policy/cloud_policy_provider.h" |
| 14 #include "chrome/browser/policy/cloud_policy_provider_impl.h" | |
| 15 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 14 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 16 #include "chrome/browser/policy/configuration_policy_provider.h" | 15 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 17 #include "chrome/browser/policy/policy_service_impl.h" | 16 #include "chrome/browser/policy/policy_service_impl.h" |
| 18 #include "chrome/browser/policy/user_policy_cache.h" | 17 #include "chrome/browser/policy/user_policy_cache.h" |
| 19 #include "chrome/browser/policy/user_policy_token_cache.h" | 18 #include "chrome/browser/policy/user_policy_token_cache.h" |
| 20 #include "chrome/browser/signin/token_service.h" | 19 #include "chrome/browser/signin/token_service.h" |
| 21 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 22 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/net/gaia/gaia_constants.h" | 23 #include "chrome/common/net/gaia/gaia_constants.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 user_cloud_policy_subsystem_->Shutdown(); | 103 user_cloud_policy_subsystem_->Shutdown(); |
| 105 user_cloud_policy_subsystem_.reset(); | 104 user_cloud_policy_subsystem_.reset(); |
| 106 user_policy_token_cache_.reset(); | 105 user_policy_token_cache_.reset(); |
| 107 user_data_store_.reset(); | 106 user_data_store_.reset(); |
| 108 } | 107 } |
| 109 | 108 |
| 110 void BrowserPolicyConnector::Init() { | 109 void BrowserPolicyConnector::Init() { |
| 111 managed_platform_provider_.reset(CreateManagedPlatformProvider()); | 110 managed_platform_provider_.reset(CreateManagedPlatformProvider()); |
| 112 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); | 111 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); |
| 113 | 112 |
| 114 managed_cloud_provider_.reset(new CloudPolicyProviderImpl( | 113 #if defined(OS_CHROMEOS) |
| 115 this, | 114 // The CloudPolicyProvider blocks asynchronous Profile creation until a login |
| 116 GetChromePolicyDefinitionList(), | 115 // is performed. This is used to ensure that the Profile's PrefService sees |
| 117 POLICY_LEVEL_MANDATORY)); | 116 // managed preferences on managed Chrome OS devices. However, this also |
| 118 recommended_cloud_provider_.reset(new CloudPolicyProviderImpl( | 117 // prevents creation of new Profiles in Desktop Chrome. The implementation of |
| 119 this, | 118 // cloud policy on the Desktop requires a refactoring of the cloud provider, |
| 120 GetChromePolicyDefinitionList(), | 119 // but for now it just isn't created. |
| 121 POLICY_LEVEL_RECOMMENDED)); | 120 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 121 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| 122 managed_cloud_provider_.reset(new CloudPolicyProvider( |
| 123 this, |
| 124 GetChromePolicyDefinitionList(), |
| 125 POLICY_LEVEL_MANDATORY)); |
| 126 recommended_cloud_provider_.reset(new CloudPolicyProvider( |
| 127 this, |
| 128 GetChromePolicyDefinitionList(), |
| 129 POLICY_LEVEL_RECOMMENDED)); |
| 130 } |
| 122 | 131 |
| 123 #if defined(OS_CHROMEOS) | |
| 124 InitializeDevicePolicy(); | 132 InitializeDevicePolicy(); |
| 125 | 133 |
| 126 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableONCPolicy)) { | 134 if (command_line->HasSwitch(switches::kEnableONCPolicy)) { |
| 127 network_configuration_updater_.reset( | 135 network_configuration_updater_.reset( |
| 128 new NetworkConfigurationUpdater( | 136 new NetworkConfigurationUpdater( |
| 129 managed_cloud_provider_.get(), | 137 managed_cloud_provider_.get(), |
| 130 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | 138 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); |
| 131 } | 139 } |
| 132 | 140 |
| 133 // Create the AppPackUpdater to start updating the cache. It requires the | 141 // Create the AppPackUpdater to start updating the cache. It requires the |
| 134 // system request context, which isn't available yet; therefore it is | 142 // system request context, which isn't available yet; therefore it is |
| 135 // created only once the loops are running. | 143 // created only once the loops are running. |
| 136 MessageLoop::current()->PostTask( | 144 MessageLoop::current()->PostTask( |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); | 321 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); |
| 314 | 322 |
| 315 UserPolicyCache* user_policy_cache = | 323 UserPolicyCache* user_policy_cache = |
| 316 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile), | 324 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile), |
| 317 wait_for_policy_fetch); | 325 wait_for_policy_fetch); |
| 318 user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); | 326 user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); |
| 319 user_policy_token_cache_.reset( | 327 user_policy_token_cache_.reset( |
| 320 new UserPolicyTokenCache(user_data_store_.get(), | 328 new UserPolicyTokenCache(user_data_store_.get(), |
| 321 policy_cache_dir.Append(kTokenCacheFile))); | 329 policy_cache_dir.Append(kTokenCacheFile))); |
| 322 | 330 |
| 323 // Prepending user caches meaning they will take precedence of device policy | 331 managed_cloud_provider_->SetUserPolicyCache(user_policy_cache); |
| 324 // caches. | 332 recommended_cloud_provider_->SetUserPolicyCache(user_policy_cache); |
| 325 managed_cloud_provider_->PrependCache(user_policy_cache); | |
| 326 recommended_cloud_provider_->PrependCache(user_policy_cache); | |
| 327 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | 333 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( |
| 328 user_data_store_.get(), | 334 user_data_store_.get(), |
| 329 user_policy_cache)); | 335 user_policy_cache)); |
| 330 | 336 |
| 331 // Initiate the DM-Token load. | 337 // Initiate the DM-Token load. |
| 332 user_policy_token_cache_->Load(); | 338 user_policy_token_cache_->Load(); |
| 333 | 339 |
| 334 user_data_store_->set_user_name(user_name); | 340 user_data_store_->set_user_name(user_name); |
| 335 user_data_store_->set_user_affiliation(GetUserAffiliation(user_name)); | 341 user_data_store_->set_user_affiliation(GetUserAffiliation(user_name)); |
| 336 | 342 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 456 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 451 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { | 457 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { |
| 452 device_data_store_.reset(CloudPolicyDataStore::CreateForDevicePolicies()); | 458 device_data_store_.reset(CloudPolicyDataStore::CreateForDevicePolicies()); |
| 453 chromeos::CryptohomeLibrary* cryptohome = | 459 chromeos::CryptohomeLibrary* cryptohome = |
| 454 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); | 460 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); |
| 455 install_attributes_.reset(new EnterpriseInstallAttributes(cryptohome)); | 461 install_attributes_.reset(new EnterpriseInstallAttributes(cryptohome)); |
| 456 DevicePolicyCache* device_policy_cache = | 462 DevicePolicyCache* device_policy_cache = |
| 457 new DevicePolicyCache(device_data_store_.get(), | 463 new DevicePolicyCache(device_data_store_.get(), |
| 458 install_attributes_.get()); | 464 install_attributes_.get()); |
| 459 | 465 |
| 460 managed_cloud_provider_->AppendCache(device_policy_cache); | 466 managed_cloud_provider_->SetDevicePolicyCache(device_policy_cache); |
| 461 recommended_cloud_provider_->AppendCache(device_policy_cache); | 467 recommended_cloud_provider_->SetDevicePolicyCache(device_policy_cache); |
| 462 | 468 |
| 463 device_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | 469 device_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( |
| 464 device_data_store_.get(), | 470 device_data_store_.get(), |
| 465 device_policy_cache)); | 471 device_policy_cache)); |
| 466 | 472 |
| 467 // Initialize the subsystem once the message loops are spinning. | 473 // Initialize the subsystem once the message loops are spinning. |
| 468 MessageLoop::current()->PostTask( | 474 MessageLoop::current()->PostTask( |
| 469 FROM_HERE, | 475 FROM_HERE, |
| 470 base::Bind(&BrowserPolicyConnector::CompleteInitialization, | 476 base::Bind(&BrowserPolicyConnector::CompleteInitialization, |
| 471 weak_ptr_factory_.GetWeakPtr())); | 477 weak_ptr_factory_.GetWeakPtr())); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); | 563 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); |
| 558 } else { | 564 } else { |
| 559 return NULL; | 565 return NULL; |
| 560 } | 566 } |
| 561 #else | 567 #else |
| 562 return NULL; | 568 return NULL; |
| 563 #endif | 569 #endif |
| 564 } | 570 } |
| 565 | 571 |
| 566 } // namespace policy | 572 } // namespace policy |
| OLD | NEW |