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