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