| Index: chrome/browser/policy/browser_policy_connector.cc
|
| diff --git a/chrome/browser/policy/browser_policy_connector.cc b/chrome/browser/policy/browser_policy_connector.cc
|
| index c6144ddabd30a86f6c3490f7e5f1cf3b29a9e9de..9a350e557ad7908f0a5a44623d6b3d3526217934 100644
|
| --- a/chrome/browser/policy/browser_policy_connector.cc
|
| +++ b/chrome/browser/policy/browser_policy_connector.cc
|
| @@ -231,7 +231,7 @@ void BrowserPolicyConnector::ScheduleServiceInitialization(
|
| }
|
| #endif
|
| }
|
| -void BrowserPolicyConnector::InitializeUserPolicy(
|
| +bool BrowserPolicyConnector::InitializeUserPolicy(
|
| const std::string& user_name) {
|
| // Throw away the old backend.
|
| user_cloud_policy_subsystem_.reset();
|
| @@ -241,6 +241,7 @@ void BrowserPolicyConnector::InitializeUserPolicy(
|
| registrar_.RemoveAll();
|
|
|
| CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + bool need_fetch = false;
|
|
|
| FilePath policy_dir;
|
| PathService::Get(chrome::DIR_USER_DATA, &policy_dir);
|
| @@ -251,8 +252,13 @@ void BrowserPolicyConnector::InitializeUserPolicy(
|
|
|
| if (command_line->HasSwitch(switches::kDeviceManagementUrl)) {
|
| FilePath policy_cache_dir = policy_dir.Append(kPolicyDir);
|
| + CloudPolicyDataStore::UserAffiliation affiliation =
|
| + GetUserAffiliation(user_name);
|
| + need_fetch = affiliation == CloudPolicyDataStore::USER_AFFILIATION_MANAGED;
|
| +
|
| UserPolicyCache* user_policy_cache =
|
| - new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile));
|
| + new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile),
|
| + need_fetch);
|
| user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies());
|
| user_policy_token_cache_.reset(
|
| new UserPolicyTokenCache(user_data_store_.get(),
|
| @@ -270,12 +276,14 @@ void BrowserPolicyConnector::InitializeUserPolicy(
|
| user_policy_token_cache_->Load();
|
|
|
| user_data_store_->set_user_name(user_name);
|
| - user_data_store_->set_user_affiliation(GetUserAffiliation(user_name));
|
| + user_data_store_->set_user_affiliation(affiliation);
|
|
|
| + int64 delay = need_fetch ? 0 : kServiceInitializationStartupDelay;
|
| user_cloud_policy_subsystem_->CompleteInitialization(
|
| prefs::kUserPolicyRefreshRate,
|
| - kServiceInitializationStartupDelay);
|
| + delay);
|
| }
|
| + return need_fetch;
|
| }
|
|
|
| void BrowserPolicyConnector::SetUserPolicyTokenService(
|
| @@ -294,8 +302,18 @@ void BrowserPolicyConnector::SetUserPolicyTokenService(
|
|
|
| void BrowserPolicyConnector::RegisterForUserPolicy(
|
| const std::string& oauth_token) {
|
| - if (user_data_store_.get())
|
| - user_data_store_->SetOAuthToken(oauth_token);
|
| + if (oauth_token.empty()) {
|
| + // An attempt to fetch the dm service oauth token has failed. Notify
|
| + // the user policy cache of this, so that a potential blocked login
|
| + // proceeds without waiting for user policy.
|
| + if (user_cloud_policy_subsystem_.get()) {
|
| + user_cloud_policy_subsystem_->GetCloudPolicyCacheBase()->
|
| + SetFetchingDone();
|
| + }
|
| + } else {
|
| + if (user_data_store_.get())
|
| + user_data_store_->SetOAuthToken(oauth_token);
|
| + }
|
| }
|
|
|
| const CloudPolicyDataStore*
|
|
|