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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 620563002: ChromeOS NetworkScreenHandler should not call CheckAndResolveLocale on UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 6 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 #endif 208 #endif
209 209
210 private: 210 private:
211 void DoBrowserLaunchInternal(Profile* profile, 211 void DoBrowserLaunchInternal(Profile* profile,
212 LoginDisplayHost* login_host, 212 LoginDisplayHost* login_host,
213 bool locale_pref_checked); 213 bool locale_pref_checked);
214 214
215 static void RunCallbackOnLocaleLoaded( 215 static void RunCallbackOnLocaleLoaded(
216 const base::Closure& callback, 216 const base::Closure& callback,
217 InputEventsBlocker* input_events_blocker, 217 InputEventsBlocker* input_events_blocker,
218 const std::string& locale, 218 const locale_util::LanguageSwitchResult& result);
219 const std::string& loaded_locale,
220 const bool success);
221 219
222 // Attempts restarting the browser process and esures that this does 220 // Attempts restarting the browser process and esures that this does
223 // not happen while we are still fetching new OAuth refresh tokens. 221 // not happen while we are still fetching new OAuth refresh tokens.
224 void AttemptRestart(Profile* profile); 222 void AttemptRestart(Profile* profile);
225 223
226 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). 224 // Has to be scoped_refptr, see comment for CreateAuthenticator(...).
227 scoped_refptr<Authenticator> authenticator_; 225 scoped_refptr<Authenticator> authenticator_;
228 226
229 // Delegate to be fired when the profile will be prepared. 227 // Delegate to be fired when the profile will be prepared.
230 LoginUtils::Delegate* delegate_; 228 LoginUtils::Delegate* delegate_;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 login_host->Finalize(); 319 login_host->Finalize();
322 user_manager::UserManager::Get()->SessionStarted(); 320 user_manager::UserManager::Get()->SessionStarted();
323 chromeos::BootTimesLoader::Get()->LoginDone( 321 chromeos::BootTimesLoader::Get()->LoginDone(
324 user_manager::UserManager::Get()->IsCurrentUserNew()); 322 user_manager::UserManager::Get()->IsCurrentUserNew());
325 } 323 }
326 324
327 // static 325 // static
328 void LoginUtilsImpl::RunCallbackOnLocaleLoaded( 326 void LoginUtilsImpl::RunCallbackOnLocaleLoaded(
329 const base::Closure& callback, 327 const base::Closure& callback,
330 InputEventsBlocker* /* input_events_blocker */, 328 InputEventsBlocker* /* input_events_blocker */,
331 const std::string& /* locale */, 329 const locale_util::LanguageSwitchResult& /* result */) {
332 const std::string& /* loaded_locale */,
333 const bool /* success */) {
334 callback.Run(); 330 callback.Run();
335 } 331 }
336 332
337 void LoginUtilsImpl::RespectLocalePreference(Profile* profile, 333 void LoginUtilsImpl::RespectLocalePreference(Profile* profile,
338 const base::Closure& callback) { 334 const base::Closure& callback) {
339 if (browser_shutdown::IsTryingToQuit()) 335 if (browser_shutdown::IsTryingToQuit())
340 return; 336 return;
341 337
342 user_manager::User* const user = 338 user_manager::User* const user =
343 ProfileHelper::Get()->GetUserByProfile(profile); 339 ProfileHelper::Get()->GetUserByProfile(profile);
344 scoped_ptr<locale_util::SwitchLanguageCallback> locale_switched_callback( 340 locale_util::SwitchLanguageCallback locale_switched_callback(base::Bind(
345 new locale_util::SwitchLanguageCallback(base::Bind( 341 &LoginUtilsImpl::RunCallbackOnLocaleLoaded,
346 &LoginUtilsImpl::RunCallbackOnLocaleLoaded, 342 callback,
347 callback, 343 base::Owned(new InputEventsBlocker))); // Block UI events until
348 base::Owned(new InputEventsBlocker)))); // Block UI events until 344 // the ResourceBundle is
349 // the ResourceBundle is 345 // reloaded.
350 // reloaded.
351 if (!UserSessionManager::GetInstance()->RespectLocalePreference( 346 if (!UserSessionManager::GetInstance()->RespectLocalePreference(
352 profile, 347 profile, user, locale_switched_callback)) {
353 user,
354 locale_switched_callback.Pass())) {
355 callback.Run(); 348 callback.Run();
356 } 349 }
357 } 350 }
358 351
359 void LoginUtilsImpl::DoBrowserLaunch(Profile* profile, 352 void LoginUtilsImpl::DoBrowserLaunch(Profile* profile,
360 LoginDisplayHost* login_host) { 353 LoginDisplayHost* login_host) {
361 DoBrowserLaunchInternal(profile, login_host, false /* locale_pref_checked */); 354 DoBrowserLaunchInternal(profile, login_host, false /* locale_pref_checked */);
362 } 355 }
363 356
364 void LoginUtilsImpl::PrepareProfile( 357 void LoginUtilsImpl::PrepareProfile(
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 CrosSettings* cros_settings = CrosSettings::Get(); 502 CrosSettings* cros_settings = CrosSettings::Get();
510 bool allow_new_user = false; 503 bool allow_new_user = false;
511 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 504 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
512 if (allow_new_user) 505 if (allow_new_user)
513 return true; 506 return true;
514 return cros_settings->FindEmailInList( 507 return cros_settings->FindEmailInList(
515 kAccountsPrefUsers, username, wildcard_match); 508 kAccountsPrefUsers, username, wildcard_match);
516 } 509 }
517 510
518 } // namespace chromeos 511 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698