Chromium Code Reviews| 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_client.h" | |
| 13 #include "chrome/browser/policy/cloud_policy_provider.h" | 14 #include "chrome/browser/policy/cloud_policy_provider.h" |
| 15 #include "chrome/browser/policy/cloud_policy_service.h" | |
| 14 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 16 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 15 #include "chrome/browser/policy/configuration_policy_provider.h" | 17 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 18 #include "chrome/browser/policy/device_management_service.h" | |
| 16 #include "chrome/browser/policy/policy_service_impl.h" | 19 #include "chrome/browser/policy/policy_service_impl.h" |
| 20 #include "chrome/browser/policy/user_cloud_policy_manager.h" | |
| 17 #include "chrome/browser/policy/user_policy_cache.h" | 21 #include "chrome/browser/policy/user_policy_cache.h" |
| 18 #include "chrome/browser/policy/user_policy_token_cache.h" | 22 #include "chrome/browser/policy/user_policy_token_cache.h" |
| 19 #include "chrome/browser/signin/token_service.h" | 23 #include "chrome/browser/signin/token_service.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/net/gaia/gaia_constants.h" | 27 #include "chrome/common/net/gaia/gaia_constants.h" |
| 24 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 25 #include "content/public/browser/notification_details.h" | 29 #include "content/public/browser/notification_details.h" |
| 26 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 device_data_store_.reset(); | 103 device_data_store_.reset(); |
| 100 #endif | 104 #endif |
| 101 | 105 |
| 102 // Shutdown user cloud policy. | 106 // Shutdown user cloud policy. |
| 103 if (user_cloud_policy_subsystem_.get()) | 107 if (user_cloud_policy_subsystem_.get()) |
| 104 user_cloud_policy_subsystem_->Shutdown(); | 108 user_cloud_policy_subsystem_->Shutdown(); |
| 105 user_cloud_policy_subsystem_.reset(); | 109 user_cloud_policy_subsystem_.reset(); |
| 106 user_policy_token_cache_.reset(); | 110 user_policy_token_cache_.reset(); |
| 107 user_data_store_.reset(); | 111 user_data_store_.reset(); |
| 108 | 112 |
| 113 if (user_cloud_policy_manager_.get()) | |
| 114 user_cloud_policy_manager_->Shutdown(); | |
| 115 user_cloud_policy_manager_.reset(); | |
| 116 | |
| 117 device_management_service_.reset(); | |
| 118 | |
| 109 // Delete the providers while the |handler_list_| is still valid, since | 119 // Delete the providers while the |handler_list_| is still valid, since |
| 110 // OnProviderGoingAway() can trigger refreshes at the | 120 // OnProviderGoingAway() can trigger refreshes at the |
| 111 // ConfigurationPolicyPrefStore. | 121 // ConfigurationPolicyPrefStore. |
| 112 recommended_cloud_provider_.reset(); | 122 recommended_cloud_provider_.reset(); |
| 113 managed_cloud_provider_.reset(); | 123 managed_cloud_provider_.reset(); |
| 114 recommended_platform_provider_.reset(); | 124 recommended_platform_provider_.reset(); |
| 115 managed_platform_provider_.reset(); | 125 managed_platform_provider_.reset(); |
| 116 } | 126 } |
| 117 | 127 |
| 118 void BrowserPolicyConnector::Init() { | 128 void BrowserPolicyConnector::Init() { |
| 119 managed_platform_provider_.reset(CreateManagedPlatformProvider()); | 129 managed_platform_provider_.reset(CreateManagedPlatformProvider()); |
| 120 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); | 130 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); |
| 121 | 131 |
| 122 #if defined(OS_CHROMEOS) | 132 #if defined(OS_CHROMEOS) |
| 123 // The CloudPolicyProvider blocks asynchronous Profile creation until a login | 133 // The CloudPolicyProvider blocks asynchronous Profile creation until a login |
| 124 // is performed. This is used to ensure that the Profile's PrefService sees | 134 // is performed. This is used to ensure that the Profile's PrefService sees |
| 125 // managed preferences on managed Chrome OS devices. However, this also | 135 // managed preferences on managed Chrome OS devices. However, this also |
| 126 // prevents creation of new Profiles in Desktop Chrome. The implementation of | 136 // prevents creation of new Profiles in Desktop Chrome. The implementation of |
| 127 // cloud policy on the Desktop requires a refactoring of the cloud provider, | 137 // cloud policy on the Desktop requires a refactoring of the cloud provider, |
| 128 // but for now it just isn't created. | 138 // but for now it just isn't created. |
| 129 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 139 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 130 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 140 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| 131 managed_cloud_provider_.reset(new CloudPolicyProvider( | 141 device_management_service_.reset( |
| 132 this, | 142 new DeviceManagementService( |
| 133 GetChromePolicyDefinitionList(), | 143 command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl))); |
| 134 POLICY_LEVEL_MANDATORY)); | 144 if (!command_line->HasSwitch(switches::kEnableCloudPolicyService)) { |
| 135 recommended_cloud_provider_.reset(new CloudPolicyProvider( | 145 managed_cloud_provider_.reset(new CloudPolicyProvider( |
| 136 this, | 146 this, |
| 137 GetChromePolicyDefinitionList(), | 147 GetChromePolicyDefinitionList(), |
| 138 POLICY_LEVEL_RECOMMENDED)); | 148 POLICY_LEVEL_MANDATORY)); |
| 149 recommended_cloud_provider_.reset(new CloudPolicyProvider( | |
| 150 this, | |
| 151 GetChromePolicyDefinitionList(), | |
| 152 POLICY_LEVEL_RECOMMENDED)); | |
| 153 } | |
| 139 } | 154 } |
| 140 | 155 |
| 141 InitializeDevicePolicy(); | 156 InitializeDevicePolicy(); |
| 142 | 157 |
| 143 // Create the AppPackUpdater to start updating the cache. It requires the | 158 // Create the AppPackUpdater to start updating the cache. It requires the |
| 144 // system request context, which isn't available yet; therefore it is | 159 // system request context, which isn't available yet; therefore it is |
| 145 // created only once the loops are running. | 160 // created only once the loops are running. |
| 146 MessageLoop::current()->PostTask( | 161 MessageLoop::current()->PostTask( |
| 147 FROM_HERE, | 162 FROM_HERE, |
| 148 base::Bind(base::IgnoreResult(&BrowserPolicyConnector::GetAppPackUpdater), | 163 base::Bind(base::IgnoreResult(&BrowserPolicyConnector::GetAppPackUpdater), |
| 149 weak_ptr_factory_.GetWeakPtr())); | 164 weak_ptr_factory_.GetWeakPtr())); |
| 150 #endif | 165 #endif |
| 151 } | 166 } |
| 152 | 167 |
| 153 PolicyService* BrowserPolicyConnector::CreatePolicyService( | 168 PolicyService* BrowserPolicyConnector::CreatePolicyService( |
| 154 Profile* profile) const { | 169 Profile* profile) { |
| 155 // |providers| in decreasing order of priority. | 170 // |providers| in decreasing order of priority. |
| 156 PolicyServiceImpl::Providers providers; | 171 PolicyServiceImpl::Providers providers; |
| 157 if (managed_platform_provider_.get()) | 172 if (managed_platform_provider_.get()) |
| 158 providers.push_back(managed_platform_provider_.get()); | 173 providers.push_back(managed_platform_provider_.get()); |
| 159 if (managed_cloud_provider_.get()) | 174 if (managed_cloud_provider_.get()) |
| 160 providers.push_back(managed_cloud_provider_.get()); | 175 providers.push_back(managed_cloud_provider_.get()); |
| 161 if (recommended_platform_provider_.get()) | 176 if (recommended_platform_provider_.get()) |
| 162 providers.push_back(recommended_platform_provider_.get()); | 177 providers.push_back(recommended_platform_provider_.get()); |
| 163 if (recommended_cloud_provider_.get()) | 178 if (recommended_cloud_provider_.get()) |
| 164 providers.push_back(recommended_cloud_provider_.get()); | 179 providers.push_back(recommended_cloud_provider_.get()); |
| 180 if (user_cloud_policy_manager_.get()) | |
| 181 providers.push_back(user_cloud_policy_manager_.get()); | |
|
Joao da Silva
2012/06/05 07:21:46
I think this should be removed now that the proxy
Mattias Nissler (ping if slow)
2012/06/05 10:27:21
Yes, for wait_for_policy_fetch to work correctly.
| |
| 182 providers.push_back(&user_cloud_policy_provider_); | |
| 165 return new PolicyServiceImpl(providers); | 183 return new PolicyServiceImpl(providers); |
| 166 } | 184 } |
| 167 | 185 |
| 168 void BrowserPolicyConnector::RegisterForDevicePolicy( | 186 void BrowserPolicyConnector::RegisterForDevicePolicy( |
| 169 const std::string& owner_email, | 187 const std::string& owner_email, |
| 170 const std::string& token, | 188 const std::string& token, |
| 171 bool known_machine_id) { | 189 bool known_machine_id) { |
| 172 #if defined(OS_CHROMEOS) | 190 #if defined(OS_CHROMEOS) |
| 173 if (device_data_store_.get()) { | 191 if (device_data_store_.get()) { |
| 174 if (!device_data_store_->device_token().empty()) { | 192 if (!device_data_store_->device_token().empty()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 #if defined(OS_CHROMEOS) | 271 #if defined(OS_CHROMEOS) |
| 254 if (device_cloud_policy_subsystem_.get()) | 272 if (device_cloud_policy_subsystem_.get()) |
| 255 device_cloud_policy_subsystem_->RefreshPolicies(false); | 273 device_cloud_policy_subsystem_->RefreshPolicies(false); |
| 256 if (user_cloud_policy_subsystem_.get()) | 274 if (user_cloud_policy_subsystem_.get()) |
| 257 user_cloud_policy_subsystem_->RefreshPolicies(true); // wait_for_auth_token | 275 user_cloud_policy_subsystem_->RefreshPolicies(true); // wait_for_auth_token |
| 258 #endif | 276 #endif |
| 259 } | 277 } |
| 260 | 278 |
| 261 void BrowserPolicyConnector::ScheduleServiceInitialization( | 279 void BrowserPolicyConnector::ScheduleServiceInitialization( |
| 262 int64 delay_milliseconds) { | 280 int64 delay_milliseconds) { |
| 281 if (device_management_service_.get()) | |
| 282 device_management_service_->ScheduleInitialization(delay_milliseconds); | |
| 263 if (user_cloud_policy_subsystem_.get()) { | 283 if (user_cloud_policy_subsystem_.get()) { |
| 264 user_cloud_policy_subsystem_-> | 284 user_cloud_policy_subsystem_-> |
| 265 ScheduleServiceInitialization(delay_milliseconds); | 285 ScheduleServiceInitialization(delay_milliseconds); |
| 266 } | 286 } |
| 267 #if defined(OS_CHROMEOS) | 287 #if defined(OS_CHROMEOS) |
| 268 if (device_cloud_policy_subsystem_.get()) { | 288 if (device_cloud_policy_subsystem_.get()) { |
| 269 device_cloud_policy_subsystem_-> | 289 device_cloud_policy_subsystem_-> |
| 270 ScheduleServiceInitialization(delay_milliseconds); | 290 ScheduleServiceInitialization(delay_milliseconds); |
| 271 } | 291 } |
| 272 #endif | 292 #endif |
| 273 } | 293 } |
| 274 void BrowserPolicyConnector::InitializeUserPolicy( | 294 void BrowserPolicyConnector::InitializeUserPolicy( |
| 275 const std::string& user_name, | 295 const std::string& user_name, |
| 276 bool wait_for_policy_fetch) { | 296 bool wait_for_policy_fetch) { |
| 277 // Throw away the old backend. | 297 // Throw away the old backend. |
| 298 user_cloud_policy_manager_.reset(); | |
| 299 | |
| 278 user_cloud_policy_subsystem_.reset(); | 300 user_cloud_policy_subsystem_.reset(); |
| 279 user_policy_token_cache_.reset(); | 301 user_policy_token_cache_.reset(); |
| 280 user_data_store_.reset(); | 302 user_data_store_.reset(); |
| 281 token_service_ = NULL; | 303 token_service_ = NULL; |
| 282 registrar_.RemoveAll(); | 304 registrar_.RemoveAll(); |
| 283 | 305 |
| 284 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 306 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 285 | 307 |
| 286 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 308 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| 287 user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); | 309 int64 startup_delay = |
| 310 wait_for_policy_fetch ? 0 : kServiceInitializationStartupDelay; | |
| 288 | 311 |
| 289 FilePath profile_dir; | 312 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { |
| 290 PathService::Get(chrome::DIR_USER_DATA, &profile_dir); | |
| 291 #if defined(OS_CHROMEOS) | 313 #if defined(OS_CHROMEOS) |
| 292 profile_dir = profile_dir.Append( | 314 user_cloud_policy_manager_ = |
| 293 command_line->GetSwitchValuePath(switches::kLoginProfile)); | 315 UserCloudPolicyManager::Create(wait_for_policy_fetch); |
| 316 user_cloud_policy_manager_->Initialize(g_browser_process->local_state(), | |
| 317 device_management_service_.get(), | |
| 318 GetUserAffiliation(user_name)); | |
| 319 user_cloud_policy_provider_.SetDelegate(user_cloud_policy_manager_.get()); | |
| 320 | |
| 321 device_management_service_->ScheduleInitialization(startup_delay); | |
| 294 #endif | 322 #endif |
| 295 const FilePath policy_dir = profile_dir.Append(kPolicyDir); | 323 } else { |
| 296 const FilePath policy_cache_file = policy_dir.Append(kPolicyCacheFile); | 324 FilePath profile_dir; |
| 297 const FilePath token_cache_file = policy_dir.Append(kTokenCacheFile); | 325 PathService::Get(chrome::DIR_USER_DATA, &profile_dir); |
| 298 CloudPolicyCacheBase* user_policy_cache = NULL; | 326 #if defined(OS_CHROMEOS) |
| 327 profile_dir = profile_dir.Append( | |
| 328 command_line->GetSwitchValuePath(switches::kLoginProfile)); | |
| 329 #endif | |
| 330 const FilePath policy_dir = profile_dir.Append(kPolicyDir); | |
| 331 const FilePath policy_cache_file = policy_dir.Append(kPolicyCacheFile); | |
| 332 const FilePath token_cache_file = policy_dir.Append(kTokenCacheFile); | |
| 333 CloudPolicyCacheBase* user_policy_cache = NULL; | |
| 299 | 334 |
| 335 user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); | |
| 300 #if defined(OS_CHROMEOS) | 336 #if defined(OS_CHROMEOS) |
| 301 user_policy_cache = | 337 user_policy_cache = |
| 302 new CrosUserPolicyCache( | 338 new CrosUserPolicyCache( |
| 303 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | 339 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), |
| 304 user_data_store_.get(), | 340 user_data_store_.get(), |
| 305 wait_for_policy_fetch, | 341 wait_for_policy_fetch, |
| 306 token_cache_file, | 342 token_cache_file, |
| 307 policy_cache_file); | 343 policy_cache_file); |
| 308 #else | 344 #else |
| 309 user_policy_cache = new UserPolicyCache(policy_cache_file, | 345 user_policy_cache = new UserPolicyCache(policy_cache_file, |
| 310 wait_for_policy_fetch); | 346 wait_for_policy_fetch); |
| 311 user_policy_token_cache_.reset( | 347 user_policy_token_cache_.reset( |
| 312 new UserPolicyTokenCache(user_data_store_.get(), token_cache_file)); | 348 new UserPolicyTokenCache(user_data_store_.get(), token_cache_file)); |
| 313 | 349 |
| 314 // Initiate the DM-Token load. | 350 // Initiate the DM-Token load. |
| 315 user_policy_token_cache_->Load(); | 351 user_policy_token_cache_->Load(); |
| 316 #endif | 352 #endif |
| 317 | 353 |
| 318 managed_cloud_provider_->SetUserPolicyCache(user_policy_cache); | 354 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( |
| 319 recommended_cloud_provider_->SetUserPolicyCache(user_policy_cache); | 355 user_data_store_.get(), |
| 320 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | 356 user_policy_cache)); |
| 321 user_data_store_.get(), | |
| 322 user_policy_cache)); | |
| 323 | 357 |
| 324 user_data_store_->set_user_name(user_name); | 358 user_data_store_->set_user_name(user_name); |
| 325 user_data_store_->set_user_affiliation(GetUserAffiliation(user_name)); | 359 user_data_store_->set_user_affiliation(GetUserAffiliation(user_name)); |
| 326 | 360 |
| 327 int64 delay = | 361 user_cloud_policy_subsystem_->CompleteInitialization( |
| 328 wait_for_policy_fetch ? 0 : kServiceInitializationStartupDelay; | 362 prefs::kUserPolicyRefreshRate, |
| 329 user_cloud_policy_subsystem_->CompleteInitialization( | 363 startup_delay); |
| 330 prefs::kUserPolicyRefreshRate, | 364 |
| 331 delay); | 365 managed_cloud_provider_->SetUserPolicyCache(user_policy_cache); |
| 366 recommended_cloud_provider_->SetUserPolicyCache(user_policy_cache); | |
| 367 } | |
| 332 } | 368 } |
| 333 } | 369 } |
| 334 | 370 |
| 335 void BrowserPolicyConnector::SetUserPolicyTokenService( | 371 void BrowserPolicyConnector::SetUserPolicyTokenService( |
| 336 TokenService* token_service) { | 372 TokenService* token_service) { |
| 337 token_service_ = token_service; | 373 token_service_ = token_service; |
| 338 registrar_.Add(this, | 374 registrar_.Add(this, |
| 339 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 375 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 340 content::Source<TokenService>(token_service_)); | 376 content::Source<TokenService>(token_service_)); |
| 341 | 377 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 353 // the user policy cache of this, so that a potential blocked login | 389 // the user policy cache of this, so that a potential blocked login |
| 354 // proceeds without waiting for user policy. | 390 // proceeds without waiting for user policy. |
| 355 if (user_cloud_policy_subsystem_.get()) { | 391 if (user_cloud_policy_subsystem_.get()) { |
| 356 user_cloud_policy_subsystem_->GetCloudPolicyCacheBase()-> | 392 user_cloud_policy_subsystem_->GetCloudPolicyCacheBase()-> |
| 357 SetFetchingDone(); | 393 SetFetchingDone(); |
| 358 } | 394 } |
| 359 } else { | 395 } else { |
| 360 if (user_data_store_.get()) | 396 if (user_data_store_.get()) |
| 361 user_data_store_->SetOAuthToken(oauth_token); | 397 user_data_store_->SetOAuthToken(oauth_token); |
| 362 } | 398 } |
| 399 if (user_cloud_policy_manager_.get()) { | |
| 400 CloudPolicyService* service = | |
| 401 user_cloud_policy_manager_->cloud_policy_service(); | |
| 402 if (service->client() && | |
| 403 !service->client()->is_registered() && | |
| 404 !oauth_token.empty()) { | |
| 405 service->client()->Register(oauth_token); | |
| 406 } else { | |
| 407 user_cloud_policy_manager_->CancelWaitForPolicyFetch(); | |
| 408 } | |
| 409 } | |
| 363 } | 410 } |
| 364 | 411 |
| 365 CloudPolicyDataStore* BrowserPolicyConnector::GetDeviceCloudPolicyDataStore() { | 412 CloudPolicyDataStore* BrowserPolicyConnector::GetDeviceCloudPolicyDataStore() { |
| 366 #if defined(OS_CHROMEOS) | 413 #if defined(OS_CHROMEOS) |
| 367 return device_data_store_.get(); | 414 return device_data_store_.get(); |
| 368 #else | 415 #else |
| 369 return NULL; | 416 return NULL; |
| 370 #endif | 417 #endif |
| 371 } | 418 } |
| 372 | 419 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 } | 479 } |
| 433 | 480 |
| 434 void BrowserPolicyConnector::InitializeDevicePolicy() { | 481 void BrowserPolicyConnector::InitializeDevicePolicy() { |
| 435 #if defined(OS_CHROMEOS) | 482 #if defined(OS_CHROMEOS) |
| 436 // Throw away the old backend. | 483 // Throw away the old backend. |
| 437 device_cloud_policy_subsystem_.reset(); | 484 device_cloud_policy_subsystem_.reset(); |
| 438 device_data_store_.reset(); | 485 device_data_store_.reset(); |
| 439 | 486 |
| 440 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 487 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 441 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { | 488 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { |
| 442 device_data_store_.reset(CloudPolicyDataStore::CreateForDevicePolicies()); | 489 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { |
| 443 chromeos::CryptohomeLibrary* cryptohome = | 490 // TODO(mnissler): Initialize new-style device policy here once it's |
| 444 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); | 491 // implemented. |
| 445 install_attributes_.reset(new EnterpriseInstallAttributes(cryptohome)); | 492 } else { |
| 446 DevicePolicyCache* device_policy_cache = | 493 device_data_store_.reset(CloudPolicyDataStore::CreateForDevicePolicies()); |
| 447 new DevicePolicyCache(device_data_store_.get(), | 494 chromeos::CryptohomeLibrary* cryptohome = |
| 448 install_attributes_.get()); | 495 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); |
| 496 install_attributes_.reset(new EnterpriseInstallAttributes(cryptohome)); | |
| 497 DevicePolicyCache* device_policy_cache = | |
| 498 new DevicePolicyCache(device_data_store_.get(), | |
| 499 install_attributes_.get()); | |
| 449 | 500 |
| 450 managed_cloud_provider_->SetDevicePolicyCache(device_policy_cache); | 501 managed_cloud_provider_->SetDevicePolicyCache(device_policy_cache); |
| 451 recommended_cloud_provider_->SetDevicePolicyCache(device_policy_cache); | 502 recommended_cloud_provider_->SetDevicePolicyCache(device_policy_cache); |
| 452 | 503 |
| 453 device_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | 504 device_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( |
| 454 device_data_store_.get(), | 505 device_data_store_.get(), |
| 455 device_policy_cache)); | 506 device_policy_cache)); |
| 456 | 507 |
| 457 // Initialize the subsystem once the message loops are spinning. | 508 // Initialize the subsystem once the message loops are spinning. |
| 458 MessageLoop::current()->PostTask( | 509 MessageLoop::current()->PostTask( |
| 459 FROM_HERE, | 510 FROM_HERE, |
| 460 base::Bind(&BrowserPolicyConnector::CompleteInitialization, | 511 base::Bind(&BrowserPolicyConnector::CompleteInitialization, |
| 461 weak_ptr_factory_.GetWeakPtr())); | 512 weak_ptr_factory_.GetWeakPtr())); |
| 513 } | |
| 462 } | 514 } |
| 463 #endif | 515 #endif |
| 464 } | 516 } |
| 465 | 517 |
| 466 void BrowserPolicyConnector::CompleteInitialization() { | 518 void BrowserPolicyConnector::CompleteInitialization() { |
| 467 #if defined(OS_CHROMEOS) | 519 #if defined(OS_CHROMEOS) |
| 468 if (device_cloud_policy_subsystem_.get()) { | 520 if (device_cloud_policy_subsystem_.get()) { |
| 469 // Read serial number and machine model. This must be done before we call | 521 // Read serial number and machine model. This must be done before we call |
| 470 // CompleteInitialization() below such that the serial number is available | 522 // CompleteInitialization() below such that the serial number is available |
| 471 // for re-submission in case we're doing serial number recovery. | 523 // for re-submission in case we're doing serial number recovery. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); | 590 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); |
| 539 } else { | 591 } else { |
| 540 return NULL; | 592 return NULL; |
| 541 } | 593 } |
| 542 #else | 594 #else |
| 543 return NULL; | 595 return NULL; |
| 544 #endif | 596 #endif |
| 545 } | 597 } |
| 546 | 598 |
| 547 } // namespace policy | 599 } // namespace policy |
| OLD | NEW |