| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/browser/net/gaia/token_service.h" | 9 #include "chrome/browser/net/gaia/token_service.h" |
| 10 #include "chrome/browser/policy/cloud_policy_data_store.h" | 10 #include "chrome/browser/policy/cloud_policy_data_store.h" |
| 11 #include "chrome/browser/policy/cloud_policy_provider.h" | 11 #include "chrome/browser/policy/cloud_policy_provider.h" |
| 12 #include "chrome/browser/policy/cloud_policy_provider_impl.h" | 12 #include "chrome/browser/policy/cloud_policy_provider_impl.h" |
| 13 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 13 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 14 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 14 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 15 #include "chrome/browser/policy/configuration_policy_provider.h" | 15 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 16 #include "chrome/browser/policy/dummy_cloud_policy_provider.h" | 16 #include "chrome/browser/policy/dummy_cloud_policy_provider.h" |
| 17 #include "chrome/browser/policy/dummy_configuration_policy_provider.h" | 17 #include "chrome/browser/policy/dummy_configuration_policy_provider.h" |
| 18 #include "chrome/browser/policy/user_policy_cache.h" | 18 #include "chrome/browser/policy/user_policy_cache.h" |
| 19 #include "chrome/browser/policy/user_policy_token_cache.h" | 19 #include "chrome/browser/policy/user_policy_token_cache.h" |
| 20 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/net/gaia/gaia_constants.h" | 23 #include "chrome/common/net/gaia/gaia_constants.h" |
| 23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 24 #include "content/common/notification_details.h" | 25 #include "content/common/notification_details.h" |
| 25 #include "content/common/notification_source.h" | 26 #include "content/common/notification_source.h" |
| 26 | 27 |
| 27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 28 #include "chrome/browser/policy/configuration_policy_provider_win.h" | 29 #include "chrome/browser/policy/configuration_policy_provider_win.h" |
| 29 #elif defined(OS_MACOSX) | 30 #elif defined(OS_MACOSX) |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // Throw away the old backend. | 240 // Throw away the old backend. |
| 240 user_cloud_policy_subsystem_.reset(); | 241 user_cloud_policy_subsystem_.reset(); |
| 241 user_data_store_.reset(); | 242 user_data_store_.reset(); |
| 242 user_policy_token_cache_ = NULL; | 243 user_policy_token_cache_ = NULL; |
| 243 registrar_.RemoveAll(); | 244 registrar_.RemoveAll(); |
| 244 | 245 |
| 245 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 246 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 246 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 247 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| 247 token_service_ = token_service; | 248 token_service_ = token_service; |
| 248 registrar_.Add(this, | 249 registrar_.Add(this, |
| 249 NotificationType::TOKEN_AVAILABLE, | 250 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 250 Source<TokenService>(token_service_)); | 251 Source<TokenService>(token_service_)); |
| 251 | 252 |
| 252 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); | 253 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); |
| 253 UserPolicyCache* user_policy_cache = | 254 UserPolicyCache* user_policy_cache = |
| 254 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile)); | 255 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile)); |
| 255 user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); | 256 user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); |
| 256 user_policy_token_cache_ = new UserPolicyTokenCache( | 257 user_policy_token_cache_ = new UserPolicyTokenCache( |
| 257 user_data_store_->GetWeakPtr(), | 258 user_data_store_->GetWeakPtr(), |
| 258 policy_cache_dir.Append(kTokenCacheFile)); | 259 policy_cache_dir.Append(kTokenCacheFile)); |
| 259 | 260 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 void BrowserPolicyConnector::InitializeDevicePolicySubsystem() { | 330 void BrowserPolicyConnector::InitializeDevicePolicySubsystem() { |
| 330 #if defined(OS_CHROMEOS) | 331 #if defined(OS_CHROMEOS) |
| 331 if (device_cloud_policy_subsystem_.get()) { | 332 if (device_cloud_policy_subsystem_.get()) { |
| 332 device_cloud_policy_subsystem_->CompleteInitialization( | 333 device_cloud_policy_subsystem_->CompleteInitialization( |
| 333 prefs::kDevicePolicyRefreshRate, | 334 prefs::kDevicePolicyRefreshRate, |
| 334 kServiceInitializationStartupDelay); | 335 kServiceInitializationStartupDelay); |
| 335 } | 336 } |
| 336 #endif | 337 #endif |
| 337 } | 338 } |
| 338 | 339 |
| 339 void BrowserPolicyConnector::Observe(NotificationType type, | 340 void BrowserPolicyConnector::Observe(int type, |
| 340 const NotificationSource& source, | 341 const NotificationSource& source, |
| 341 const NotificationDetails& details) { | 342 const NotificationDetails& details) { |
| 342 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 343 if (type == NotificationType::TOKEN_AVAILABLE) { | 344 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) { |
| 344 const TokenService* token_source = | 345 const TokenService* token_source = |
| 345 Source<const TokenService>(source).ptr(); | 346 Source<const TokenService>(source).ptr(); |
| 346 DCHECK_EQ(token_service_, token_source); | 347 DCHECK_EQ(token_service_, token_source); |
| 347 const TokenService::TokenAvailableDetails* token_details = | 348 const TokenService::TokenAvailableDetails* token_details = |
| 348 Details<const TokenService::TokenAvailableDetails>(details).ptr(); | 349 Details<const TokenService::TokenAvailableDetails>(details).ptr(); |
| 349 if (token_details->service() == GaiaConstants::kDeviceManagementService) { | 350 if (token_details->service() == GaiaConstants::kDeviceManagementService) { |
| 350 if (user_data_store_.get()) { | 351 if (user_data_store_.get()) { |
| 351 user_data_store_->SetGaiaToken(token_details->token()); | 352 user_data_store_->SetGaiaToken(token_details->token()); |
| 352 } | 353 } |
| 353 } | 354 } |
| 354 } else { | 355 } else { |
| 355 NOTREACHED(); | 356 NOTREACHED(); |
| 356 } | 357 } |
| 357 } | 358 } |
| 358 | 359 |
| 359 } // namespace | 360 } // namespace |
| OLD | NEW |