| OLD | NEW |
| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 #endif | 207 #endif |
| 208 | 208 |
| 209 private: | 209 private: |
| 210 void DoBrowserLaunchInternal(Profile* profile, | 210 void DoBrowserLaunchInternal(Profile* profile, |
| 211 LoginDisplayHost* login_host, | 211 LoginDisplayHost* login_host, |
| 212 bool locale_pref_checked); | 212 bool locale_pref_checked); |
| 213 | 213 |
| 214 static void RunCallbackOnLocaleLoaded( | 214 static void RunCallbackOnLocaleLoaded( |
| 215 const base::Closure& callback, | 215 const base::Closure& callback, |
| 216 InputEventsBlocker* input_events_blocker, | 216 InputEventsBlocker* input_events_blocker, |
| 217 const locale_util::LanguageSwitchResult& result); | 217 const std::string& locale, |
| 218 const std::string& loaded_locale, |
| 219 const bool success); |
| 218 | 220 |
| 219 // Attempts restarting the browser process and esures that this does | 221 // Attempts restarting the browser process and esures that this does |
| 220 // not happen while we are still fetching new OAuth refresh tokens. | 222 // not happen while we are still fetching new OAuth refresh tokens. |
| 221 void AttemptRestart(Profile* profile); | 223 void AttemptRestart(Profile* profile); |
| 222 | 224 |
| 223 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). | 225 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). |
| 224 scoped_refptr<Authenticator> authenticator_; | 226 scoped_refptr<Authenticator> authenticator_; |
| 225 | 227 |
| 226 // Delegate to be fired when the profile will be prepared. | 228 // Delegate to be fired when the profile will be prepared. |
| 227 LoginUtils::Delegate* delegate_; | 229 LoginUtils::Delegate* delegate_; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 login_host->Finalize(); | 319 login_host->Finalize(); |
| 318 user_manager::UserManager::Get()->SessionStarted(); | 320 user_manager::UserManager::Get()->SessionStarted(); |
| 319 chromeos::BootTimesLoader::Get()->LoginDone( | 321 chromeos::BootTimesLoader::Get()->LoginDone( |
| 320 user_manager::UserManager::Get()->IsCurrentUserNew()); | 322 user_manager::UserManager::Get()->IsCurrentUserNew()); |
| 321 } | 323 } |
| 322 | 324 |
| 323 // static | 325 // static |
| 324 void LoginUtilsImpl::RunCallbackOnLocaleLoaded( | 326 void LoginUtilsImpl::RunCallbackOnLocaleLoaded( |
| 325 const base::Closure& callback, | 327 const base::Closure& callback, |
| 326 InputEventsBlocker* /* input_events_blocker */, | 328 InputEventsBlocker* /* input_events_blocker */, |
| 327 const locale_util::LanguageSwitchResult& /* result */) { | 329 const std::string& /* locale */, |
| 330 const std::string& /* loaded_locale */, |
| 331 const bool /* success */) { |
| 328 callback.Run(); | 332 callback.Run(); |
| 329 } | 333 } |
| 330 | 334 |
| 331 void LoginUtilsImpl::RespectLocalePreference(Profile* profile, | 335 void LoginUtilsImpl::RespectLocalePreference(Profile* profile, |
| 332 const base::Closure& callback) { | 336 const base::Closure& callback) { |
| 333 if (browser_shutdown::IsTryingToQuit()) | 337 if (browser_shutdown::IsTryingToQuit()) |
| 334 return; | 338 return; |
| 335 | 339 |
| 336 user_manager::User* const user = | 340 user_manager::User* const user = |
| 337 ProfileHelper::Get()->GetUserByProfile(profile); | 341 ProfileHelper::Get()->GetUserByProfile(profile); |
| 338 locale_util::SwitchLanguageCallback locale_switched_callback(base::Bind( | 342 scoped_ptr<locale_util::SwitchLanguageCallback> locale_switched_callback( |
| 339 &LoginUtilsImpl::RunCallbackOnLocaleLoaded, | 343 new locale_util::SwitchLanguageCallback(base::Bind( |
| 340 callback, | 344 &LoginUtilsImpl::RunCallbackOnLocaleLoaded, |
| 341 base::Owned(new InputEventsBlocker))); // Block UI events until | 345 callback, |
| 342 // the ResourceBundle is | 346 base::Owned(new InputEventsBlocker)))); // Block UI events until |
| 343 // reloaded. | 347 // the ResourceBundle is |
| 348 // reloaded. |
| 344 if (!UserSessionManager::GetInstance()->RespectLocalePreference( | 349 if (!UserSessionManager::GetInstance()->RespectLocalePreference( |
| 345 profile, user, locale_switched_callback)) { | 350 profile, |
| 351 user, |
| 352 locale_switched_callback.Pass())) { |
| 346 callback.Run(); | 353 callback.Run(); |
| 347 } | 354 } |
| 348 } | 355 } |
| 349 | 356 |
| 350 void LoginUtilsImpl::DoBrowserLaunch(Profile* profile, | 357 void LoginUtilsImpl::DoBrowserLaunch(Profile* profile, |
| 351 LoginDisplayHost* login_host) { | 358 LoginDisplayHost* login_host) { |
| 352 DoBrowserLaunchInternal(profile, login_host, false /* locale_pref_checked */); | 359 DoBrowserLaunchInternal(profile, login_host, false /* locale_pref_checked */); |
| 353 } | 360 } |
| 354 | 361 |
| 355 void LoginUtilsImpl::PrepareProfile( | 362 void LoginUtilsImpl::PrepareProfile( |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 CrosSettings* cros_settings = CrosSettings::Get(); | 507 CrosSettings* cros_settings = CrosSettings::Get(); |
| 501 bool allow_new_user = false; | 508 bool allow_new_user = false; |
| 502 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 509 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 503 if (allow_new_user) | 510 if (allow_new_user) |
| 504 return true; | 511 return true; |
| 505 return cros_settings->FindEmailInList( | 512 return cros_settings->FindEmailInList( |
| 506 kAccountsPrefUsers, username, wildcard_match); | 513 kAccountsPrefUsers, username, wildcard_match); |
| 507 } | 514 } |
| 508 | 515 |
| 509 } // namespace chromeos | 516 } // namespace chromeos |
| OLD | NEW |