Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 Profile* profile, | 323 Profile* profile, |
| 324 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 324 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| 325 TokenService* token_service = profile->GetTokenService(); | 325 TokenService* token_service = profile->GetTokenService(); |
| 326 token_service->UpdateCredentials(credentials); | 326 token_service->UpdateCredentials(credentials); |
| 327 if (token_service->AreCredentialsValid()) { | 327 if (token_service->AreCredentialsValid()) { |
| 328 token_service->StartFetchingTokens(); | 328 token_service->StartFetchingTokens(); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 void LoginUtilsImpl::RespectLocalePreference(PrefService* pref) { | 332 void LoginUtilsImpl::RespectLocalePreference(PrefService* pref) { |
| 333 std::string pref_locale = pref->GetString(prefs::kApplicationLocale); | 333 std::string pref_locale = |
|
whywhat
2011/01/11 10:24:14
Could you use several variables with more specific
Denis Lagno
2011/01/12 15:33:28
Done.
| |
| 334 if (pref_locale.empty()) { | 334 pref->GetString(prefs::kApplicationLocaleOverride); |
| 335 // Profile synchronization takes time and is not completed at that moment | 335 if (!pref_locale.empty()) { |
| 336 // at first login. So we initialize locale preference in steps: | 336 LanguageSwitchMenu::SwitchLanguage(pref_locale); |
| 337 // (1) first save it to temporary backup; | 337 return; |
| 338 // (2) on next login we assume that synchronization is already completed | 338 } |
| 339 // and we may finalize initialization. | 339 |
| 340 std::string pref_locale_backup = | 340 if (g_browser_process == NULL) |
| 341 pref->GetString(prefs::kApplicationLocaleBackup); | 341 return; |
| 342 if (pref_locale_backup.empty()) { | 342 std::string cur_locale = g_browser_process->GetApplicationLocale(); |
| 343 pref->SetString(prefs::kApplicationLocaleBackup, | 343 |
| 344 g_browser_process->GetApplicationLocale()); | 344 pref_locale = pref->GetString(prefs::kApplicationLocale); |
| 345 return; | 345 if (!pref_locale.empty()) { |
| 346 } else { | 346 if (pref->GetString(prefs::kApplicationLocaleAccepted) == pref_locale) { |
| 347 pref_locale.swap(pref_locale_backup); | 347 // If locale is accepted then we do not want to show LocaleChangeInfoBar. |
| 348 pref->SetString(prefs::kApplicationLocale, pref_locale); | 348 pref->SetString(prefs::kApplicationLocaleBackup, pref_locale); |
| 349 } else if (pref->GetString(prefs::kApplicationLocaleBackup) != cur_locale) { | |
|
whywhat
2011/01/11 10:24:14
I guess pref->GetString(prefs::kApplicationLocaleB
Denis Lagno
2011/01/12 15:33:28
Done.
| |
| 350 if (pref->GetString(prefs::kApplicationLocaleBackup) == pref_locale || | |
| 351 pref->GetString(prefs::kApplicationLocaleBackup).empty()) { | |
| 352 pref->SetString(prefs::kApplicationLocaleBackup, cur_locale); | |
| 353 } | |
| 349 } | 354 } |
| 355 LanguageSwitchMenu::SwitchLanguage(pref_locale); | |
| 356 return; | |
| 350 } | 357 } |
| 351 LanguageSwitchMenu::SwitchLanguage(pref_locale); | 358 // Profile synchronization takes time and is not completed at that moment |
| 359 // at first login. So we initialize locale preference in steps: | |
| 360 // (1) first save it to temporary backup; | |
| 361 // (2) on next login we assume that synchronization is already completed | |
| 362 // and we may finalize initialization. | |
| 363 pref_locale = pref->GetString(prefs::kApplicationLocaleBackup); | |
| 364 pref->SetString(prefs::kApplicationLocaleBackup, cur_locale); | |
| 365 pref->ScheduleSavePersistentPrefs(); | |
| 366 if (!pref_locale.empty()) { | |
| 367 pref->SetString(prefs::kApplicationLocale, pref_locale); | |
| 368 pref->ScheduleSavePersistentPrefs(); | |
| 369 LanguageSwitchMenu::SwitchLanguage(pref_locale); | |
| 370 } | |
| 352 } | 371 } |
| 353 | 372 |
| 354 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { | 373 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { |
| 355 VLOG(1) << "Completing off the record login"; | 374 VLOG(1) << "Completing off the record login"; |
| 356 | 375 |
| 357 UserManager::Get()->OffTheRecordUserLoggedIn(); | 376 UserManager::Get()->OffTheRecordUserLoggedIn(); |
| 358 | 377 |
| 359 if (CrosLibrary::Get()->EnsureLoaded()) { | 378 if (CrosLibrary::Get()->EnsureLoaded()) { |
| 360 // For guest session we ask session manager to restart Chrome with --bwsi | 379 // For guest session we ask session manager to restart Chrome with --bwsi |
| 361 // flag. We keep only some of the arguments of this process. | 380 // flag. We keep only some of the arguments of this process. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 BrowserInit browser_init; | 545 BrowserInit browser_init; |
| 527 int return_code; | 546 int return_code; |
| 528 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), | 547 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), |
| 529 profile, | 548 profile, |
| 530 FilePath(), | 549 FilePath(), |
| 531 true, | 550 true, |
| 532 &return_code); | 551 &return_code); |
| 533 } | 552 } |
| 534 | 553 |
| 535 } // namespace chromeos | 554 } // namespace chromeos |
| OLD | NEW |