| 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_provider.h" | 10 #include "chrome/browser/policy/cloud_policy_provider.h" |
| 11 #include "chrome/browser/policy/cloud_policy_provider_impl.h" | 11 #include "chrome/browser/policy/cloud_policy_provider_impl.h" |
| 12 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 12 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 13 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 13 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 14 #include "chrome/browser/policy/configuration_policy_provider.h" | 14 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 15 #include "chrome/browser/policy/dummy_cloud_policy_provider.h" | 15 #include "chrome/browser/policy/dummy_cloud_policy_provider.h" |
| 16 #include "chrome/browser/policy/dummy_configuration_policy_provider.h" | 16 #include "chrome/browser/policy/dummy_configuration_policy_provider.h" |
| 17 #include "chrome/browser/policy/user_policy_cache.h" | 17 #include "chrome/browser/policy/user_policy_cache.h" |
| 18 #include "chrome/browser/policy/user_policy_identity_strategy.h" | 18 #include "chrome/browser/policy/user_policy_identity_strategy.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/net/gaia/gaia_constants.h" | 22 #include "chrome/common/net/gaia/gaia_constants.h" |
| 22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 23 #include "content/common/notification_details.h" | 24 #include "content/common/notification_details.h" |
| 24 #include "content/common/notification_source.h" | 25 #include "content/common/notification_source.h" |
| 25 | 26 |
| 26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 27 #include "chrome/browser/policy/configuration_policy_provider_win.h" | 28 #include "chrome/browser/policy/configuration_policy_provider_win.h" |
| 28 #elif defined(OS_MACOSX) | 29 #elif defined(OS_MACOSX) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 235 |
| 235 // Throw away the old backend. | 236 // Throw away the old backend. |
| 236 user_cloud_policy_subsystem_.reset(); | 237 user_cloud_policy_subsystem_.reset(); |
| 237 user_identity_strategy_.reset(); | 238 user_identity_strategy_.reset(); |
| 238 registrar_.RemoveAll(); | 239 registrar_.RemoveAll(); |
| 239 | 240 |
| 240 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 241 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 241 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 242 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| 242 token_service_ = token_service; | 243 token_service_ = token_service; |
| 243 registrar_.Add(this, | 244 registrar_.Add(this, |
| 244 NotificationType::TOKEN_AVAILABLE, | 245 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 245 Source<TokenService>(token_service_)); | 246 Source<TokenService>(token_service_)); |
| 246 | 247 |
| 247 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); | 248 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); |
| 248 UserPolicyCache* user_policy_cache = | 249 UserPolicyCache* user_policy_cache = |
| 249 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile)); | 250 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile)); |
| 250 | 251 |
| 251 // Prepending user caches meaning they will take precedence of device policy | 252 // Prepending user caches meaning they will take precedence of device policy |
| 252 // caches. | 253 // caches. |
| 253 managed_cloud_provider_->PrependCache(user_policy_cache); | 254 managed_cloud_provider_->PrependCache(user_policy_cache); |
| 254 recommended_cloud_provider_->PrependCache(user_policy_cache); | 255 recommended_cloud_provider_->PrependCache(user_policy_cache); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void BrowserPolicyConnector::InitializeDevicePolicySubsystem() { | 325 void BrowserPolicyConnector::InitializeDevicePolicySubsystem() { |
| 325 #if defined(OS_CHROMEOS) | 326 #if defined(OS_CHROMEOS) |
| 326 if (device_cloud_policy_subsystem_.get()) { | 327 if (device_cloud_policy_subsystem_.get()) { |
| 327 device_cloud_policy_subsystem_->CompleteInitialization( | 328 device_cloud_policy_subsystem_->CompleteInitialization( |
| 328 prefs::kDevicePolicyRefreshRate, | 329 prefs::kDevicePolicyRefreshRate, |
| 329 kServiceInitializationStartupDelay); | 330 kServiceInitializationStartupDelay); |
| 330 } | 331 } |
| 331 #endif | 332 #endif |
| 332 } | 333 } |
| 333 | 334 |
| 334 void BrowserPolicyConnector::Observe(NotificationType type, | 335 void BrowserPolicyConnector::Observe(int type, |
| 335 const NotificationSource& source, | 336 const NotificationSource& source, |
| 336 const NotificationDetails& details) { | 337 const NotificationDetails& details) { |
| 337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 338 if (type == NotificationType::TOKEN_AVAILABLE) { | 339 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) { |
| 339 const TokenService* token_source = | 340 const TokenService* token_source = |
| 340 Source<const TokenService>(source).ptr(); | 341 Source<const TokenService>(source).ptr(); |
| 341 DCHECK_EQ(token_service_, token_source); | 342 DCHECK_EQ(token_service_, token_source); |
| 342 const TokenService::TokenAvailableDetails* token_details = | 343 const TokenService::TokenAvailableDetails* token_details = |
| 343 Details<const TokenService::TokenAvailableDetails>(details).ptr(); | 344 Details<const TokenService::TokenAvailableDetails>(details).ptr(); |
| 344 if (token_details->service() == GaiaConstants::kDeviceManagementService) { | 345 if (token_details->service() == GaiaConstants::kDeviceManagementService) { |
| 345 if (user_identity_strategy_.get()) { | 346 if (user_identity_strategy_.get()) { |
| 346 user_identity_strategy_->SetAuthToken(token_details->token()); | 347 user_identity_strategy_->SetAuthToken(token_details->token()); |
| 347 } | 348 } |
| 348 } | 349 } |
| 349 } else { | 350 } else { |
| 350 NOTREACHED(); | 351 NOTREACHED(); |
| 351 } | 352 } |
| 352 } | 353 } |
| 353 | 354 |
| 354 } // namespace | 355 } // namespace |
| OLD | NEW |