Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc

Issue 1108983002: Fetch policy with refresh token. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UserCloudPolicyManagerChromeOS Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); 143 return scoped_ptr<UserCloudPolicyManagerChromeOS>();
144 } 144 }
145 145
146 policy::BrowserPolicyConnectorChromeOS* connector = 146 policy::BrowserPolicyConnectorChromeOS* connector =
147 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 147 g_browser_process->platform_part()->browser_policy_connector_chromeos();
148 UserAffiliation affiliation = connector->GetUserAffiliation(username); 148 UserAffiliation affiliation = connector->GetUserAffiliation(username);
149 const bool is_affiliated_user = affiliation == USER_AFFILIATION_MANAGED; 149 const bool is_affiliated_user = affiliation == USER_AFFILIATION_MANAGED;
150 const bool is_browser_restart = 150 const bool is_browser_restart =
151 command_line->HasSwitch(chromeos::switches::kLoginUser); 151 command_line->HasSwitch(chromeos::switches::kLoginUser);
152 // TODO(xiyuan): Update the code below after http://crbug.com/462036. 152 // TODO(xiyuan): Update the code below after http://crbug.com/462036.
153 chromeos::UserSessionManager* user_session_manager =
154 chromeos::UserSessionManager::GetInstance();
155 const std::string& refresh_token =
156 user_session_manager->user_context().GetRefreshToken();
153 const bool wait_for_initial_policy = 157 const bool wait_for_initial_policy =
154 !is_browser_restart && 158 !is_browser_restart &&
155 chromeos::UserSessionManager::GetInstance()->has_auth_cookies() && 159 (user_session_manager->has_auth_cookies() || !refresh_token.empty()) &&
xiyuan 2015/04/28 01:52:58 With the refresh token code added to UserCloudPoli
achuithb 2015/04/28 06:28:58 Done.
156 (user_manager::UserManager::Get()->IsCurrentUserNew() || 160 (user_manager::UserManager::Get()->IsCurrentUserNew() ||
157 is_affiliated_user); 161 is_affiliated_user);
158 162
159 const base::TimeDelta initial_policy_fetch_timeout = 163 const base::TimeDelta initial_policy_fetch_timeout =
160 user_manager::UserManager::Get()->IsCurrentUserNew() 164 user_manager::UserManager::Get()->IsCurrentUserNew()
161 ? base::TimeDelta::Max() 165 ? base::TimeDelta::Max()
162 : base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds); 166 : base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds);
163 167
164 DeviceManagementService* device_management_service = 168 DeviceManagementService* device_management_service =
165 connector->device_management_service(); 169 connector->device_management_service();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 external_data_dir, 201 external_data_dir,
198 store.get())); 202 store.get()));
199 if (force_immediate_load) 203 if (force_immediate_load)
200 store->LoadImmediately(); 204 store->LoadImmediately();
201 205
202 scoped_refptr<base::SequencedTaskRunner> file_task_runner = 206 scoped_refptr<base::SequencedTaskRunner> file_task_runner =
203 content::BrowserThread::GetMessageLoopProxyForThread( 207 content::BrowserThread::GetMessageLoopProxyForThread(
204 content::BrowserThread::FILE); 208 content::BrowserThread::FILE);
205 209
206 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( 210 scoped_ptr<UserCloudPolicyManagerChromeOS> manager(
207 new UserCloudPolicyManagerChromeOS(store.Pass(), 211 new UserCloudPolicyManagerChromeOS(
208 external_data_manager.Pass(), 212 store.Pass(), external_data_manager.Pass(),
209 component_policy_cache_dir, 213 component_policy_cache_dir, wait_for_initial_policy, refresh_token,
210 wait_for_initial_policy, 214 initial_policy_fetch_timeout, base::MessageLoopProxy::current(),
211 initial_policy_fetch_timeout, 215 file_task_runner, io_task_runner));
212 base::MessageLoopProxy::current(),
213 file_task_runner,
214 io_task_runner));
215 216
216 bool wildcard_match = false; 217 bool wildcard_match = false;
217 if (connector->IsEnterpriseManaged() && 218 if (connector->IsEnterpriseManaged() &&
218 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) && 219 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) &&
219 wildcard_match && !connector->IsNonEnterpriseUser(username)) { 220 wildcard_match && !connector->IsNonEnterpriseUser(username)) {
220 manager->EnableWildcardLoginCheck(username); 221 manager->EnableWildcardLoginCheck(username);
221 } 222 }
222 223
223 manager->Init( 224 manager->Init(
224 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); 225 SchemaRegistryServiceFactory::GetForContext(profile)->registry());
(...skipping 29 matching lines...) Expand all
254 255
255 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( 256 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory(
256 content::BrowserContext* context) { 257 content::BrowserContext* context) {
257 return false; 258 return false;
258 } 259 }
259 260
260 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( 261 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow(
261 content::BrowserContext* context) {} 262 content::BrowserContext* context) {}
262 263
263 } // namespace policy 264 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698