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

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

Issue 330843002: Make the policy fetch for first time login blocking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fixes a build error on android Created 6 years, 5 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // USER_TYPE_RETAIL_MODE, USER_TYPE_KIOSK_APP, USER_TYPE_GUEST and 131 // USER_TYPE_RETAIL_MODE, USER_TYPE_KIOSK_APP, USER_TYPE_GUEST and
132 // USER_TYPE_LOCALLY_MANAGED are not signed in and can't authenticate the 132 // USER_TYPE_LOCALLY_MANAGED are not signed in and can't authenticate the
133 // policy registration. 133 // policy registration.
134 // USER_TYPE_PUBLIC_ACCOUNT gets its policy from the 134 // USER_TYPE_PUBLIC_ACCOUNT gets its policy from the
135 // DeviceLocalAccountPolicyService. 135 // DeviceLocalAccountPolicyService.
136 const std::string& username = user->email(); 136 const std::string& username = user->email();
137 if (user->GetType() != user_manager::USER_TYPE_REGULAR || 137 if (user->GetType() != user_manager::USER_TYPE_REGULAR ||
138 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { 138 BrowserPolicyConnector::IsNonEnterpriseUser(username)) {
139 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); 139 return scoped_ptr<UserCloudPolicyManagerChromeOS>();
140 } 140 }
141 // If the user is known to be a non enterprise user, we don't reach this code.
142 DCHECK(!BrowserPolicyConnector::IsNonEnterpriseUser(username));
bartfab (slow) 2014/07/07 17:40:13 Nit: #include "components/policy/core/browser/brow
141 143
142 policy::BrowserPolicyConnectorChromeOS* connector = 144 policy::BrowserPolicyConnectorChromeOS* connector =
143 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 145 g_browser_process->platform_part()->browser_policy_connector_chromeos();
144 UserAffiliation affiliation = connector->GetUserAffiliation(username); 146 UserAffiliation affiliation = connector->GetUserAffiliation(username);
145 const bool is_managed_user = affiliation == USER_AFFILIATION_MANAGED;
146 const bool is_browser_restart = 147 const bool is_browser_restart =
147 command_line->HasSwitch(chromeos::switches::kLoginUser); 148 command_line->HasSwitch(chromeos::switches::kLoginUser);
148 const bool wait_for_initial_policy = is_managed_user && !is_browser_restart; 149 const bool wait_for_initial_policy = !is_browser_restart;
bartfab (slow) 2014/07/07 17:40:13 This changes the logic more than you intended - it
150
151 base::TimeDelta initial_policy_fetch_timeout =
bartfab (slow) 2014/07/07 17:40:13 Nit 1: const. Nit 2: s/initial_policy_fetch_timeou
152 chromeos::UserManager::Get()->IsCurrentUserNew()
bartfab (slow) 2014/07/07 17:40:13 1: Nit: #include "chrome/browser/chromeos/login/us
153 ? base::TimeDelta::Max()
154 : base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds);
149 155
150 DeviceManagementService* device_management_service = 156 DeviceManagementService* device_management_service =
151 connector->device_management_service(); 157 connector->device_management_service();
152 if (wait_for_initial_policy) 158 if (wait_for_initial_policy)
153 device_management_service->ScheduleInitialization(0); 159 device_management_service->ScheduleInitialization(0);
154 160
155 base::FilePath profile_dir = profile->GetPath(); 161 base::FilePath profile_dir = profile->GetPath();
156 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); 162 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir);
157 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); 163 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy);
158 const base::FilePath token_cache_file = legacy_dir.Append(kToken); 164 const base::FilePath token_cache_file = legacy_dir.Append(kToken);
(...skipping 29 matching lines...) Expand all
188 scoped_refptr<base::SequencedTaskRunner> file_task_runner = 194 scoped_refptr<base::SequencedTaskRunner> file_task_runner =
189 content::BrowserThread::GetMessageLoopProxyForThread( 195 content::BrowserThread::GetMessageLoopProxyForThread(
190 content::BrowserThread::FILE); 196 content::BrowserThread::FILE);
191 197
192 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( 198 scoped_ptr<UserCloudPolicyManagerChromeOS> manager(
193 new UserCloudPolicyManagerChromeOS( 199 new UserCloudPolicyManagerChromeOS(
194 store.PassAs<CloudPolicyStore>(), 200 store.PassAs<CloudPolicyStore>(),
195 external_data_manager.Pass(), 201 external_data_manager.Pass(),
196 component_policy_cache_dir, 202 component_policy_cache_dir,
197 wait_for_initial_policy, 203 wait_for_initial_policy,
198 base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds), 204 initial_policy_fetch_timeout,
199 base::MessageLoopProxy::current(), 205 base::MessageLoopProxy::current(),
200 file_task_runner, 206 file_task_runner,
201 io_task_runner)); 207 io_task_runner));
202 208
203 bool wildcard_match = false; 209 bool wildcard_match = false;
204 if (connector->IsEnterpriseManaged() && 210 if (connector->IsEnterpriseManaged() &&
205 chromeos::LoginUtils::IsWhitelisted(username, &wildcard_match) && 211 chromeos::LoginUtils::IsWhitelisted(username, &wildcard_match) &&
206 wildcard_match && 212 wildcard_match &&
207 !connector->IsNonEnterpriseUser(username)) { 213 !connector->IsNonEnterpriseUser(username)) {
208 manager->EnableWildcardLoginCheck(username); 214 manager->EnableWildcardLoginCheck(username);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 248
243 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( 249 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory(
244 content::BrowserContext* context) { 250 content::BrowserContext* context) {
245 return false; 251 return false;
246 } 252 }
247 253
248 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( 254 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow(
249 content::BrowserContext* context) {} 255 content::BrowserContext* context) {}
250 256
251 } // namespace policy 257 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698