Chromium Code Reviews| 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/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/net/gaia/token_service.h" | |
| 11 #include "chrome/browser/policy/cloud_policy_provider.h" | |
| 12 #include "chrome/browser/policy/cloud_policy_provider_impl.h" | |
| 10 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 13 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 11 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 14 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 12 #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" | |
| 13 #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" | |
| 19 #include "chrome/browser/policy/user_policy_identity_strategy.h" | |
| 14 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/net/gaia/gaia_constants.h" | |
| 16 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "content/common/notification_details.h" | |
| 25 #include "content/common/notification_source.h" | |
| 17 | 26 |
| 18 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 19 #include "chrome/browser/policy/configuration_policy_provider_win.h" | 28 #include "chrome/browser/policy/configuration_policy_provider_win.h" |
| 20 #elif defined(OS_MACOSX) | 29 #elif defined(OS_MACOSX) |
| 21 #include "chrome/browser/policy/configuration_policy_provider_mac.h" | 30 #include "chrome/browser/policy/configuration_policy_provider_mac.h" |
| 22 #elif defined(OS_POSIX) | 31 #elif defined(OS_POSIX) |
| 23 #include "chrome/browser/policy/config_dir_policy_provider.h" | 32 #include "chrome/browser/policy/config_dir_policy_provider.h" |
| 24 #endif | 33 #endif |
| 25 | 34 |
| 26 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
| 27 #include "chrome/browser/chromeos/cros/cros_library.h" | 36 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 28 #include "chrome/browser/policy/device_policy_cache.h" | 37 #include "chrome/browser/policy/device_policy_cache.h" |
| 29 #include "chrome/browser/policy/device_policy_identity_strategy.h" | 38 #include "chrome/browser/policy/device_policy_identity_strategy.h" |
| 30 #include "chrome/browser/policy/enterprise_install_attributes.h" | 39 #include "chrome/browser/policy/enterprise_install_attributes.h" |
| 40 #include "content/common/notification_service.h" | |
| 31 #endif | 41 #endif |
| 32 | 42 |
| 33 namespace policy { | 43 namespace policy { |
| 34 | 44 |
| 35 namespace { | 45 namespace { |
| 36 | 46 |
| 47 // The directory suffixes for user cloud policy. | |
|
Mattias Nissler (ping if slow)
2011/06/21 20:09:56
what is a directory suffix?
gfeher
2011/06/22 19:18:34
Done.
| |
| 48 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); | |
| 49 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); | |
| 50 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); | |
| 51 | |
| 37 // The following constants define delays applied before the initial policy fetch | 52 // The following constants define delays applied before the initial policy fetch |
| 38 // on startup. (So that displaying Chrome's GUI does not get delayed.) | 53 // on startup. (So that displaying Chrome's GUI does not get delayed.) |
| 39 // Delay in milliseconds from startup. | 54 // Delay in milliseconds from startup. |
| 40 const int64 kServiceInitializationStartupDelay = 5000; | 55 const int64 kServiceInitializationStartupDelay = 5000; |
| 41 | 56 |
| 42 } // namespace | 57 } // namespace |
| 43 | 58 |
| 44 // static | 59 // static |
| 45 BrowserPolicyConnector* BrowserPolicyConnector::Create() { | 60 BrowserPolicyConnector* BrowserPolicyConnector::Create() { |
| 46 return new BrowserPolicyConnector(); | 61 return new BrowserPolicyConnector(); |
| 47 } | 62 } |
| 48 | 63 |
| 49 // static | 64 // static |
| 50 BrowserPolicyConnector* BrowserPolicyConnector::CreateForTests() { | 65 BrowserPolicyConnector* BrowserPolicyConnector::CreateForTests() { |
| 51 const ConfigurationPolicyProvider::PolicyDefinitionList* | 66 const ConfigurationPolicyProvider::PolicyDefinitionList* |
| 52 policy_list = ConfigurationPolicyPrefStore:: | 67 policy_list = ConfigurationPolicyPrefStore:: |
| 53 GetChromePolicyDefinitionList(); | 68 GetChromePolicyDefinitionList(); |
| 54 return new BrowserPolicyConnector( | 69 return new BrowserPolicyConnector( |
| 55 new DummyConfigurationPolicyProvider(policy_list), | 70 new policy::DummyConfigurationPolicyProvider(policy_list), |
| 56 new DummyConfigurationPolicyProvider(policy_list)); | 71 new policy::DummyConfigurationPolicyProvider(policy_list), |
| 72 new policy::DummyCloudPolicyProvider(policy_list), | |
| 73 new policy::DummyCloudPolicyProvider(policy_list)); | |
| 57 } | 74 } |
| 58 | 75 |
| 59 BrowserPolicyConnector::BrowserPolicyConnector() | 76 BrowserPolicyConnector::BrowserPolicyConnector() |
| 60 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 77 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 61 managed_platform_provider_.reset(CreateManagedPlatformProvider()); | 78 managed_platform_provider_.reset(CreateManagedPlatformProvider()); |
| 62 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); | 79 recommended_platform_provider_.reset(CreateRecommendedPlatformProvider()); |
| 63 | 80 |
| 81 managed_cloud_provider_.reset(new CloudPolicyProviderImpl( | |
| 82 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), | |
| 83 CloudPolicyCacheBase::POLICY_LEVEL_MANDATORY)); | |
| 84 recommended_cloud_provider_.reset(new CloudPolicyProviderImpl( | |
| 85 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), | |
| 86 CloudPolicyCacheBase::POLICY_LEVEL_RECOMMENDED)); | |
| 87 | |
| 64 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
| 65 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 89 InitializeDevicePolicy(); |
| 66 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { | |
| 67 identity_strategy_.reset(new DevicePolicyIdentityStrategy()); | |
| 68 install_attributes_.reset(new EnterpriseInstallAttributes( | |
| 69 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary())); | |
| 70 cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | |
| 71 identity_strategy_.get(), | |
| 72 new DevicePolicyCache(identity_strategy_.get(), | |
| 73 install_attributes_.get()))); | |
| 74 | |
| 75 // Initialize the subsystem once the message loops are spinning. | |
| 76 MessageLoop::current()->PostTask( | |
| 77 FROM_HERE, | |
| 78 method_factory_.NewRunnableMethod(&BrowserPolicyConnector::Initialize)); | |
| 79 } | |
| 80 #endif | 90 #endif |
| 81 } | 91 } |
| 82 | 92 |
| 83 BrowserPolicyConnector::BrowserPolicyConnector( | 93 BrowserPolicyConnector::BrowserPolicyConnector( |
| 84 ConfigurationPolicyProvider* managed_platform_provider, | 94 ConfigurationPolicyProvider* managed_platform_provider, |
| 85 ConfigurationPolicyProvider* recommended_platform_provider) | 95 ConfigurationPolicyProvider* recommended_platform_provider, |
| 96 CloudPolicyProvider* managed_cloud_provider, | |
| 97 CloudPolicyProvider* recommended_cloud_provider) | |
| 86 : managed_platform_provider_(managed_platform_provider), | 98 : managed_platform_provider_(managed_platform_provider), |
| 87 recommended_platform_provider_(recommended_platform_provider), | 99 recommended_platform_provider_(recommended_platform_provider), |
| 100 managed_cloud_provider_(managed_cloud_provider), | |
| 101 recommended_cloud_provider_(recommended_cloud_provider), | |
| 88 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {} | 102 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {} |
| 89 | 103 |
| 90 BrowserPolicyConnector::~BrowserPolicyConnector() { | 104 BrowserPolicyConnector::~BrowserPolicyConnector() { |
| 91 if (cloud_policy_subsystem_.get()) | 105 // Shutdown device cloud policy. |
| 92 cloud_policy_subsystem_->Shutdown(); | |
| 93 cloud_policy_subsystem_.reset(); | |
| 94 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
| 95 identity_strategy_.reset(); | 107 if (device_cloud_policy_subsystem_.get()) |
| 108 device_cloud_policy_subsystem_->Shutdown(); | |
| 109 device_cloud_policy_subsystem_.reset(); | |
| 110 device_identity_strategy_.reset(); | |
| 96 #endif | 111 #endif |
| 112 | |
| 113 // Shutdown user cloud policy. | |
| 114 if (user_cloud_policy_subsystem_.get()) | |
| 115 user_cloud_policy_subsystem_->Shutdown(); | |
| 116 user_cloud_policy_subsystem_.reset(); | |
| 117 user_identity_strategy_.reset(); | |
| 97 } | 118 } |
| 98 | 119 |
| 99 ConfigurationPolicyProvider* | 120 ConfigurationPolicyProvider* |
| 100 BrowserPolicyConnector::GetManagedPlatformProvider() const { | 121 BrowserPolicyConnector::GetManagedPlatformProvider() const { |
| 101 return managed_platform_provider_.get(); | 122 return managed_platform_provider_.get(); |
| 102 } | 123 } |
| 103 | 124 |
| 104 ConfigurationPolicyProvider* | 125 ConfigurationPolicyProvider* |
| 105 BrowserPolicyConnector::GetManagedCloudProvider() const { | 126 BrowserPolicyConnector::GetManagedCloudProvider() const { |
| 106 if (cloud_policy_subsystem_.get()) | 127 return managed_cloud_provider_.get(); |
| 107 return cloud_policy_subsystem_->GetManagedPolicyProvider(); | |
| 108 | |
| 109 return NULL; | |
| 110 } | 128 } |
| 111 | 129 |
| 112 ConfigurationPolicyProvider* | 130 ConfigurationPolicyProvider* |
| 113 BrowserPolicyConnector::GetRecommendedPlatformProvider() const { | 131 BrowserPolicyConnector::GetRecommendedPlatformProvider() const { |
| 114 return recommended_platform_provider_.get(); | 132 return recommended_platform_provider_.get(); |
| 115 } | 133 } |
| 116 | 134 |
| 117 ConfigurationPolicyProvider* | 135 ConfigurationPolicyProvider* |
| 118 BrowserPolicyConnector::GetRecommendedCloudProvider() const { | 136 BrowserPolicyConnector::GetRecommendedCloudProvider() const { |
| 119 if (cloud_policy_subsystem_.get()) | 137 return recommended_cloud_provider_.get(); |
| 120 return cloud_policy_subsystem_->GetRecommendedPolicyProvider(); | |
| 121 | |
| 122 return NULL; | |
| 123 } | 138 } |
| 124 | 139 |
| 125 ConfigurationPolicyProvider* | 140 ConfigurationPolicyProvider* |
| 126 BrowserPolicyConnector::CreateManagedPlatformProvider() { | 141 BrowserPolicyConnector::CreateManagedPlatformProvider() { |
| 127 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list = | 142 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list = |
| 128 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(); | 143 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(); |
| 129 #if defined(OS_WIN) | 144 #if defined(OS_WIN) |
| 130 return new ConfigurationPolicyProviderWin(policy_list); | 145 return new ConfigurationPolicyProviderWin(policy_list); |
| 131 #elif defined(OS_MACOSX) | 146 #elif defined(OS_MACOSX) |
| 132 return new ConfigurationPolicyProviderMac(policy_list); | 147 return new ConfigurationPolicyProviderMac(policy_list); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 155 policy_list, | 170 policy_list, |
| 156 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); | 171 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); |
| 157 } else { | 172 } else { |
| 158 return new DummyConfigurationPolicyProvider(policy_list); | 173 return new DummyConfigurationPolicyProvider(policy_list); |
| 159 } | 174 } |
| 160 #else | 175 #else |
| 161 return new DummyConfigurationPolicyProvider(policy_list); | 176 return new DummyConfigurationPolicyProvider(policy_list); |
| 162 #endif | 177 #endif |
| 163 } | 178 } |
| 164 | 179 |
| 165 void BrowserPolicyConnector::SetCredentials(const std::string& owner_email, | 180 void BrowserPolicyConnector::SetDeviceCredentials( |
| 166 const std::string& gaia_token) { | 181 const std::string& owner_email, |
| 182 const std::string& gaia_token) { | |
| 167 #if defined(OS_CHROMEOS) | 183 #if defined(OS_CHROMEOS) |
| 168 if (identity_strategy_.get()) | 184 if (device_identity_strategy_.get()) |
| 169 identity_strategy_->SetAuthCredentials(owner_email, gaia_token); | 185 device_identity_strategy_->SetAuthCredentials(owner_email, gaia_token); |
| 170 #endif | 186 #endif |
| 171 } | 187 } |
| 172 | 188 |
| 173 bool BrowserPolicyConnector::IsEnterpriseManaged() { | 189 bool BrowserPolicyConnector::IsEnterpriseManaged() { |
| 174 #if defined(OS_CHROMEOS) | 190 #if defined(OS_CHROMEOS) |
| 175 return install_attributes_.get() && install_attributes_->IsEnterpriseDevice(); | 191 return install_attributes_.get() && install_attributes_->IsEnterpriseDevice(); |
| 176 #else | 192 #else |
| 177 return false; | 193 return false; |
| 178 #endif | 194 #endif |
| 179 } | 195 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 190 | 206 |
| 191 std::string BrowserPolicyConnector::GetEnterpriseDomain() { | 207 std::string BrowserPolicyConnector::GetEnterpriseDomain() { |
| 192 #if defined(OS_CHROMEOS) | 208 #if defined(OS_CHROMEOS) |
| 193 if (install_attributes_.get()) | 209 if (install_attributes_.get()) |
| 194 return install_attributes_->GetDomain(); | 210 return install_attributes_->GetDomain(); |
| 195 #endif | 211 #endif |
| 196 | 212 |
| 197 return std::string(); | 213 return std::string(); |
| 198 } | 214 } |
| 199 | 215 |
| 200 void BrowserPolicyConnector::StopAutoRetry() { | 216 void BrowserPolicyConnector::DeviceStopAutoRetry() { |
| 201 if (cloud_policy_subsystem_.get()) | |
| 202 cloud_policy_subsystem_->StopAutoRetry(); | |
| 203 } | |
| 204 | |
| 205 void BrowserPolicyConnector::FetchPolicy() { | |
| 206 #if defined(OS_CHROMEOS) | 217 #if defined(OS_CHROMEOS) |
| 207 if (identity_strategy_.get()) | 218 if (device_cloud_policy_subsystem_.get()) |
| 208 return identity_strategy_->FetchPolicy(); | 219 device_cloud_policy_subsystem_->StopAutoRetry(); |
| 209 #endif | 220 #endif |
| 210 } | 221 } |
| 211 | 222 |
| 212 void BrowserPolicyConnector::Initialize() { | 223 void BrowserPolicyConnector::FetchDevicePolicy() { |
| 213 if (cloud_policy_subsystem_.get()) { | 224 #if defined(OS_CHROMEOS) |
| 214 cloud_policy_subsystem_->CompleteInitialization( | 225 if (device_identity_strategy_.get()) |
| 215 prefs::kDevicePolicyRefreshRate, | 226 return device_identity_strategy_->FetchPolicy(); |
| 227 #endif | |
| 228 } | |
| 229 | |
| 230 void BrowserPolicyConnector::InitializeUserPolicy(std::string& user_name, | |
| 231 const FilePath& policy_dir, | |
| 232 TokenService* token_service) { | |
| 233 // Throw away the old backend. | |
| 234 user_cloud_policy_subsystem_.reset(); | |
| 235 user_identity_strategy_.reset(); | |
| 236 registrar_.RemoveAll(); | |
| 237 | |
| 238 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 239 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | |
| 240 token_service_ = token_service; | |
| 241 if (token_service_) { | |
|
Mattias Nissler (ping if slow)
2011/06/21 20:09:56
Why do we need to null-check this? The whole thing
gfeher
2011/06/22 19:18:34
Okay. But I add a DCHECK because it's hard to debu
| |
| 242 registrar_.Add(this, | |
| 243 NotificationType::TOKEN_AVAILABLE, | |
| 244 Source<TokenService>(token_service_)); | |
| 245 } | |
| 246 | |
| 247 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); | |
| 248 UserPolicyCache* user_policy_cache = | |
| 249 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile)); | |
| 250 | |
| 251 // Prepending user caches meaning they will take precedence of device policy | |
| 252 // caches. | |
| 253 managed_cloud_provider_->PrependCache(user_policy_cache); | |
| 254 recommended_cloud_provider_->PrependCache(user_policy_cache); | |
| 255 user_identity_strategy_.reset( | |
| 256 new UserPolicyIdentityStrategy( | |
| 257 user_name, | |
| 258 policy_cache_dir.Append(kTokenCacheFile))); | |
| 259 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | |
| 260 user_identity_strategy_.get(), | |
| 261 user_policy_cache)); | |
| 262 | |
| 263 // Initiate the DM-Token load. | |
| 264 user_identity_strategy_->LoadTokenCache(); | |
| 265 | |
| 266 // In case the token of |token_service_| is already available we set it | |
| 267 // directly, since there will be no notification for it. | |
| 268 if (token_service_) { | |
| 269 if (token_service_->HasTokenForService( | |
| 270 GaiaConstants::kDeviceManagementService)) { | |
| 271 user_identity_strategy_->SetAuthToken( | |
| 272 token_service_->GetTokenForService( | |
| 273 GaiaConstants::kDeviceManagementService)); | |
| 274 } | |
| 275 } | |
| 276 | |
| 277 user_cloud_policy_subsystem_->CompleteInitialization( | |
| 278 prefs::kUserPolicyRefreshRate, | |
| 216 kServiceInitializationStartupDelay); | 279 kServiceInitializationStartupDelay); |
| 217 } | 280 } |
| 218 } | 281 } |
| 219 | 282 |
| 220 void BrowserPolicyConnector::ScheduleServiceInitialization( | 283 void BrowserPolicyConnector::ScheduleServiceInitialization( |
| 221 int64 delay_milliseconds) { | 284 int64 delay_milliseconds) { |
| 222 if (cloud_policy_subsystem_.get()) | 285 if (user_cloud_policy_subsystem_.get()) { |
| 223 cloud_policy_subsystem_->ScheduleServiceInitialization(delay_milliseconds); | 286 user_cloud_policy_subsystem_-> |
| 287 ScheduleServiceInitialization(delay_milliseconds); | |
| 288 } | |
| 289 #if defined(OS_CHROMEOS) | |
| 290 if (device_cloud_policy_subsystem_.get()) { | |
| 291 device_cloud_policy_subsystem_-> | |
| 292 ScheduleServiceInitialization(delay_milliseconds); | |
| 293 } | |
| 294 #endif | |
| 295 } | |
| 296 | |
| 297 void BrowserPolicyConnector::InitializeDevicePolicy() { | |
| 298 #if defined(OS_CHROMEOS) | |
| 299 // Throw away the old backend. | |
| 300 device_cloud_policy_subsystem_.reset(); | |
| 301 device_identity_strategy_.reset(); | |
| 302 | |
| 303 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 304 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { | |
| 305 device_cloud_policy_subsystem_.reset(); | |
| 306 device_identity_strategy_.reset(); | |
| 307 | |
| 308 device_identity_strategy_.reset(new DevicePolicyIdentityStrategy()); | |
| 309 install_attributes_.reset(new EnterpriseInstallAttributes( | |
| 310 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary())); | |
| 311 DevicePolicyCache* device_policy_cache = | |
| 312 new DevicePolicyCache(device_identity_strategy_.get(), | |
| 313 install_attributes_.get()); | |
| 314 | |
| 315 managed_cloud_provider_->AppendCache(device_policy_cache); | |
| 316 recommended_cloud_provider_->AppendCache(device_policy_cache); | |
| 317 | |
| 318 device_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | |
| 319 device_identity_strategy_.get(), | |
| 320 device_policy_cache)); | |
| 321 | |
| 322 // Initialize the subsystem once the message loops are spinning. | |
| 323 MessageLoop::current()->PostTask( | |
| 324 FROM_HERE, | |
| 325 method_factory_.NewRunnableMethod( | |
| 326 &BrowserPolicyConnector::InitializeDevicePolicySubsystem)); | |
| 327 } | |
| 328 #endif | |
| 329 } | |
| 330 | |
| 331 void BrowserPolicyConnector::InitializeDevicePolicySubsystem() { | |
| 332 #if defined(OS_CHROMEOS) | |
| 333 if (device_cloud_policy_subsystem_.get()) { | |
| 334 device_cloud_policy_subsystem_->CompleteInitialization( | |
| 335 prefs::kDevicePolicyRefreshRate, | |
| 336 kServiceInitializationStartupDelay); | |
| 337 } | |
| 338 #endif | |
| 339 } | |
| 340 | |
| 341 void BrowserPolicyConnector::Observe(NotificationType type, | |
| 342 const NotificationSource& source, | |
| 343 const NotificationDetails& details) { | |
| 344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 345 if (type == NotificationType::TOKEN_AVAILABLE) { | |
| 346 const TokenService* token_source = | |
| 347 Source<const TokenService>(source).ptr(); | |
| 348 DCHECK_EQ(token_service_, token_source); | |
| 349 const TokenService::TokenAvailableDetails* token_details = | |
| 350 Details<const TokenService::TokenAvailableDetails>(details).ptr(); | |
| 351 if (token_details->service() == GaiaConstants::kDeviceManagementService) { | |
| 352 if (user_identity_strategy_.get()) { | |
| 353 user_identity_strategy_->SetAuthToken(token_details->token()); | |
| 354 } | |
| 355 } | |
| 356 } else { | |
| 357 NOTREACHED(); | |
| 358 } | |
| 224 } | 359 } |
| 225 | 360 |
| 226 } // namespace | 361 } // namespace |
| OLD | NEW |