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

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

Issue 1727413002: Reland: No longer start up profile if there was an error fetching policy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (!user->HasGaiaAccount() || 142 if (!user->HasGaiaAccount() ||
143 user->IsSupervised() || 143 user->IsSupervised() ||
144 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { 144 BrowserPolicyConnector::IsNonEnterpriseUser(username)) {
145 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); 145 return scoped_ptr<UserCloudPolicyManagerChromeOS>();
146 } 146 }
147 147
148 policy::BrowserPolicyConnectorChromeOS* connector = 148 policy::BrowserPolicyConnectorChromeOS* connector =
149 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 149 g_browser_process->platform_part()->browser_policy_connector_chromeos();
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 const bool wait_for_initial_policy = !is_browser_restart; 152 const user_manager::UserManager* const user_manager =
153 user_manager::UserManager::Get();
153 154
154 const base::TimeDelta initial_policy_fetch_timeout = 155 // We want to block for policy in a few situations: if the user is new, or
155 user_manager::UserManager::Get()->IsCurrentUserNew() 156 // if we are forcing an online signin. An online signin will be forced if
156 ? base::TimeDelta::Max() 157 // there has been a credential error, or if the initial session creation
157 : base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds); 158 // was not completed (the oauth_token_status is not set to valid by
159 // OAuth2LoginManager until profile creation/session restore is complete).
160 const bool block_forever_for_policy =
161 !user_manager->IsLoggedInAsStub() &&
162 (user_manager->IsCurrentUserNew() ||
163 user_manager->GetActiveUser()->force_online_signin() ||
164 user_manager->GetActiveUser()->oauth_token_status() !=
165 user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
166
167 const bool wait_for_policy_fetch =
168 block_forever_for_policy || !is_browser_restart;
169
170 base::TimeDelta initial_policy_fetch_timeout;
171 if (block_forever_for_policy) {
172 initial_policy_fetch_timeout = base::TimeDelta::Max();
173 } else if (wait_for_policy_fetch) {
174 initial_policy_fetch_timeout =
175 base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds);
176 }
158 177
159 DeviceManagementService* device_management_service = 178 DeviceManagementService* device_management_service =
160 connector->device_management_service(); 179 connector->device_management_service();
161 if (wait_for_initial_policy) 180 if (wait_for_policy_fetch)
162 device_management_service->ScheduleInitialization(0); 181 device_management_service->ScheduleInitialization(0);
163 182
164 base::FilePath profile_dir = profile->GetPath(); 183 base::FilePath profile_dir = profile->GetPath();
165 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); 184 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir);
166 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); 185 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy);
167 const base::FilePath token_cache_file = legacy_dir.Append(kToken); 186 const base::FilePath token_cache_file = legacy_dir.Append(kToken);
168 const base::FilePath component_policy_cache_dir = 187 const base::FilePath component_policy_cache_dir =
169 profile_dir.Append(kPolicy).Append(kComponentsDir); 188 profile_dir.Append(kPolicy).Append(kComponentsDir);
170 const base::FilePath external_data_dir = 189 const base::FilePath external_data_dir =
171 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); 190 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir);
(...skipping 22 matching lines...) Expand all
194 if (force_immediate_load) 213 if (force_immediate_load)
195 store->LoadImmediately(); 214 store->LoadImmediately();
196 215
197 scoped_refptr<base::SequencedTaskRunner> file_task_runner = 216 scoped_refptr<base::SequencedTaskRunner> file_task_runner =
198 content::BrowserThread::GetMessageLoopProxyForThread( 217 content::BrowserThread::GetMessageLoopProxyForThread(
199 content::BrowserThread::FILE); 218 content::BrowserThread::FILE);
200 219
201 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( 220 scoped_ptr<UserCloudPolicyManagerChromeOS> manager(
202 new UserCloudPolicyManagerChromeOS( 221 new UserCloudPolicyManagerChromeOS(
203 std::move(store), std::move(external_data_manager), 222 std::move(store), std::move(external_data_manager),
204 component_policy_cache_dir, wait_for_initial_policy, 223 component_policy_cache_dir, wait_for_policy_fetch,
205 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(), 224 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(),
206 file_task_runner, io_task_runner)); 225 file_task_runner, io_task_runner));
207 226
208 bool wildcard_match = false; 227 bool wildcard_match = false;
209 if (connector->IsEnterpriseManaged() && 228 if (connector->IsEnterpriseManaged() &&
210 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) && 229 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) &&
211 wildcard_match && !connector->IsNonEnterpriseUser(username)) { 230 wildcard_match && !connector->IsNonEnterpriseUser(username)) {
212 manager->EnableWildcardLoginCheck(username); 231 manager->EnableWildcardLoginCheck(username);
213 } 232 }
214 233
(...skipping 29 matching lines...) Expand all
244 263
245 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( 264 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory(
246 content::BrowserContext* context) { 265 content::BrowserContext* context) {
247 return false; 266 return false;
248 } 267 }
249 268
250 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( 269 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow(
251 content::BrowserContext* context) {} 270 content::BrowserContext* context) {}
252 271
253 } // namespace policy 272 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698