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