| 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" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 managed_cloud_provider_->PrependCache(user_policy_cache); | 206 managed_cloud_provider_->PrependCache(user_policy_cache); |
| 207 recommended_cloud_provider_->PrependCache(user_policy_cache); | 207 recommended_cloud_provider_->PrependCache(user_policy_cache); |
| 208 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( | 208 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( |
| 209 user_data_store_.get(), | 209 user_data_store_.get(), |
| 210 user_policy_cache)); | 210 user_policy_cache)); |
| 211 | 211 |
| 212 // Initiate the DM-Token load. | 212 // Initiate the DM-Token load. |
| 213 user_policy_token_cache_->Load(); | 213 user_policy_token_cache_->Load(); |
| 214 | 214 |
| 215 user_data_store_->set_user_name(user_name); | 215 user_data_store_->set_user_name(user_name); |
| 216 user_data_store_->set_user_affiliation(GetUserAffiliation(user_name)); | |
| 217 | |
| 218 if (token_service_ && | 216 if (token_service_ && |
| 219 token_service_->HasTokenForService( | 217 token_service_->HasTokenForService( |
| 220 GaiaConstants::kDeviceManagementService)) { | 218 GaiaConstants::kDeviceManagementService)) { |
| 221 user_data_store_->SetGaiaToken(token_service_->GetTokenForService( | 219 user_data_store_->SetGaiaToken(token_service_->GetTokenForService( |
| 222 GaiaConstants::kDeviceManagementService)); | 220 GaiaConstants::kDeviceManagementService)); |
| 223 } | 221 } |
| 224 | 222 |
| 225 user_cloud_policy_subsystem_->CompleteInitialization( | 223 user_cloud_policy_subsystem_->CompleteInitialization( |
| 226 prefs::kUserPolicyRefreshRate, | 224 prefs::kUserPolicyRefreshRate, |
| 227 kServiceInitializationStartupDelay); | 225 kServiceInitializationStartupDelay); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 void BrowserPolicyConnector::InitializeDevicePolicySubsystem() { | 330 void BrowserPolicyConnector::InitializeDevicePolicySubsystem() { |
| 333 #if defined(OS_CHROMEOS) | 331 #if defined(OS_CHROMEOS) |
| 334 if (device_cloud_policy_subsystem_.get()) { | 332 if (device_cloud_policy_subsystem_.get()) { |
| 335 device_cloud_policy_subsystem_->CompleteInitialization( | 333 device_cloud_policy_subsystem_->CompleteInitialization( |
| 336 prefs::kDevicePolicyRefreshRate, | 334 prefs::kDevicePolicyRefreshRate, |
| 337 kServiceInitializationStartupDelay); | 335 kServiceInitializationStartupDelay); |
| 338 } | 336 } |
| 339 #endif | 337 #endif |
| 340 } | 338 } |
| 341 | 339 |
| 342 CloudPolicyDataStore::UserAffiliation | |
| 343 BrowserPolicyConnector::GetUserAffiliation(const std::string& user_name) { | |
| 344 #if defined(OS_CHROMEOS) | |
| 345 if (install_attributes_.get()) { | |
| 346 size_t pos = user_name.find('@'); | |
| 347 if (pos != std::string::npos && | |
| 348 user_name.substr(pos + 1) == install_attributes_->GetDomain()) { | |
| 349 return CloudPolicyDataStore::USER_AFFILIATION_MANAGED; | |
| 350 } | |
| 351 } | |
| 352 #endif | |
| 353 | |
| 354 return CloudPolicyDataStore::USER_AFFILIATION_NONE; | |
| 355 } | |
| 356 | |
| 357 // static | 340 // static |
| 358 BrowserPolicyConnector* BrowserPolicyConnector::CreateForTests() { | 341 BrowserPolicyConnector* BrowserPolicyConnector::CreateForTests() { |
| 359 const ConfigurationPolicyProvider::PolicyDefinitionList* | 342 const ConfigurationPolicyProvider::PolicyDefinitionList* |
| 360 policy_list = ConfigurationPolicyPrefStore:: | 343 policy_list = ConfigurationPolicyPrefStore:: |
| 361 GetChromePolicyDefinitionList(); | 344 GetChromePolicyDefinitionList(); |
| 362 return new BrowserPolicyConnector( | 345 return new BrowserPolicyConnector( |
| 363 new policy::DummyConfigurationPolicyProvider(policy_list), | 346 new policy::DummyConfigurationPolicyProvider(policy_list), |
| 364 new policy::DummyConfigurationPolicyProvider(policy_list), | 347 new policy::DummyConfigurationPolicyProvider(policy_list), |
| 365 new policy::DummyCloudPolicyProvider(policy_list), | 348 new policy::DummyCloudPolicyProvider(policy_list), |
| 366 new policy::DummyCloudPolicyProvider(policy_list)); | 349 new policy::DummyCloudPolicyProvider(policy_list)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); | 385 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); |
| 403 } else { | 386 } else { |
| 404 return new DummyConfigurationPolicyProvider(policy_list); | 387 return new DummyConfigurationPolicyProvider(policy_list); |
| 405 } | 388 } |
| 406 #else | 389 #else |
| 407 return new DummyConfigurationPolicyProvider(policy_list); | 390 return new DummyConfigurationPolicyProvider(policy_list); |
| 408 #endif | 391 #endif |
| 409 } | 392 } |
| 410 | 393 |
| 411 } // namespace | 394 } // namespace |
| OLD | NEW |