diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-05 11:59:42 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-05 11:59:42 +0000 |
commit | e29e2e68c45d58c46c2f60e5b5bf18f809a0899b (patch) | |
tree | f4384e171b7ecd6bbbdc04ab9c54854b2f43795e /chrome/browser/policy/browser_policy_connector.cc | |
parent | 8650d924a5ffd6b5fd0e4f3fc092403bdc1f98ec (diff) | |
download | chromium_src-e29e2e68c45d58c46c2f60e5b5bf18f809a0899b.zip chromium_src-e29e2e68c45d58c46c2f60e5b5bf18f809a0899b.tar.gz chromium_src-e29e2e68c45d58c46c2f60e5b5bf18f809a0899b.tar.bz2 |
Make sure we initialize the user policy cache before loading the user profile on ChromeOS.
BUG=chromium-os:19463
TEST=see bug description
Review URL: http://codereview.chromium.org/7827014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy/browser_policy_connector.cc')
-rw-r--r-- | chrome/browser/policy/browser_policy_connector.cc | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/chrome/browser/policy/browser_policy_connector.cc b/chrome/browser/policy/browser_policy_connector.cc index f8a1b47..c32f426 100644 --- a/chrome/browser/policy/browser_policy_connector.cc +++ b/chrome/browser/policy/browser_policy_connector.cc @@ -184,24 +184,25 @@ void BrowserPolicyConnector::ScheduleServiceInitialization( } #endif } -void BrowserPolicyConnector::InitializeUserPolicy(const std::string& user_name, - const FilePath& policy_dir, - TokenService* token_service) { +void BrowserPolicyConnector::InitializeUserPolicy( + const std::string& user_name) { // Throw away the old backend. user_cloud_policy_subsystem_.reset(); user_policy_token_cache_.reset(); user_data_store_.reset(); + token_service_ = NULL; registrar_.RemoveAll(); CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { - token_service_ = token_service; - if (token_service_) { - registrar_.Add(this, - chrome::NOTIFICATION_TOKEN_AVAILABLE, - Source<TokenService>(token_service_)); - } + FilePath policy_dir; + PathService::Get(chrome::DIR_USER_DATA, &policy_dir); +#if defined(OS_CHROMEOS) + policy_dir = policy_dir.Append( + command_line->GetSwitchValuePath(switches::kLoginProfile)); +#endif + + if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); UserPolicyCache* user_policy_cache = new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile)); @@ -224,19 +225,26 @@ void BrowserPolicyConnector::InitializeUserPolicy(const std::string& user_name, user_data_store_->set_user_name(user_name); user_data_store_->set_user_affiliation(GetUserAffiliation(user_name)); - if (token_service_ && - token_service_->HasTokenForService( - GaiaConstants::kDeviceManagementService)) { - user_data_store_->SetGaiaToken(token_service_->GetTokenForService( - GaiaConstants::kDeviceManagementService)); - } - user_cloud_policy_subsystem_->CompleteInitialization( prefs::kUserPolicyRefreshRate, kServiceInitializationStartupDelay); } } +void BrowserPolicyConnector::SetUserPolicyTokenService( + TokenService* token_service) { + token_service_ = token_service; + registrar_.Add(this, + chrome::NOTIFICATION_TOKEN_AVAILABLE, + Source<TokenService>(token_service_)); + + if (token_service_->HasTokenForService( + GaiaConstants::kDeviceManagementService)) { + user_data_store_->SetGaiaToken(token_service_->GetTokenForService( + GaiaConstants::kDeviceManagementService)); + } +} + void BrowserPolicyConnector::RegisterForUserPolicy( const std::string& oauth_token) { if (user_data_store_.get()) |