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_override = | |
|
whywhat
2011/01/12 16:33:16
Add DCHECK for pref?
Denis Lagno
2011/01/12 20:27:34
Done.
| |
| 334 pref->GetString(prefs::kApplicationLocaleOverride); | |
| 335 if (!pref_locale_override.empty()) { | |
| 336 LanguageSwitchMenu::SwitchLanguage(pref_locale_override); | |
| 337 return; | |
| 338 } | |
| 339 | |
| 340 if (g_browser_process == NULL) | |
| 341 return; | |
| 342 std::string cur_locale = g_browser_process->GetApplicationLocale(); | |
| 343 | |
| 333 std::string pref_locale = pref->GetString(prefs::kApplicationLocale); | 344 std::string pref_locale = pref->GetString(prefs::kApplicationLocale); |
| 334 if (pref_locale.empty()) { | 345 if (!pref_locale.empty()) { |
| 335 // Profile synchronization takes time and is not completed at that moment | 346 if (pref->GetString(prefs::kApplicationLocaleAccepted) == pref_locale) { |
| 336 // at first login. So we initialize locale preference in steps: | 347 // If locale is accepted then we do not want to show LocaleChangeInfoBar. |
|
whywhat
2011/01/12 16:33:16
Info Bar -> notification?
Denis Lagno
2011/01/12 20:27:34
Done.
| |
| 337 // (1) first save it to temporary backup; | 348 // LocaleChangeInfoBar is triggered by different values of |
| 338 // (2) on next login we assume that synchronization is already completed | 349 // kApplicationLocaleBackup and kApplicationLocale preferences, |
| 339 // and we may finalize initialization. | 350 // so make them identical. |
| 340 std::string pref_locale_backup = | 351 pref->SetString(prefs::kApplicationLocaleBackup, pref_locale); |
| 341 pref->GetString(prefs::kApplicationLocaleBackup); | |
| 342 if (pref_locale_backup.empty()) { | |
| 343 pref->SetString(prefs::kApplicationLocaleBackup, | |
| 344 g_browser_process->GetApplicationLocale()); | |
| 345 return; | |
| 346 } else { | 352 } else { |
| 347 pref_locale.swap(pref_locale_backup); | 353 std::string pref_locale_backup = |
| 348 pref->SetString(prefs::kApplicationLocale, pref_locale); | 354 pref->GetString(prefs::kApplicationLocaleBackup); |
| 355 if (pref_locale_backup != cur_locale) { | |
| 356 if (pref_locale_backup == pref_locale || pref_locale_backup.empty()) { | |
| 357 pref->SetString(prefs::kApplicationLocaleBackup, cur_locale); | |
| 358 } | |
| 359 } | |
| 349 } | 360 } |
| 361 LanguageSwitchMenu::SwitchLanguage(pref_locale); | |
| 362 return; | |
| 350 } | 363 } |
| 351 LanguageSwitchMenu::SwitchLanguage(pref_locale); | 364 // Profile synchronization takes time and is not completed at that moment |
| 365 // at first login. So we initialize locale preference in steps: | |
| 366 // (1) first save it to temporary backup; | |
| 367 // (2) on next login we assume that synchronization is already completed | |
| 368 // and we may finalize initialization. | |
| 369 std::string pref_locale_backup = | |
| 370 pref->GetString(prefs::kApplicationLocaleBackup); | |
| 371 pref->SetString(prefs::kApplicationLocaleBackup, cur_locale); | |
| 372 pref->ScheduleSavePersistentPrefs(); | |
| 373 if (!pref_locale_backup.empty()) { | |
| 374 pref->SetString(prefs::kApplicationLocale, pref_locale_backup); | |
| 375 pref->ScheduleSavePersistentPrefs(); | |
| 376 LanguageSwitchMenu::SwitchLanguage(pref_locale_backup); | |
| 377 } | |
| 352 } | 378 } |
| 353 | 379 |
| 354 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { | 380 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { |
| 355 VLOG(1) << "Completing off the record login"; | 381 VLOG(1) << "Completing off the record login"; |
| 356 | 382 |
| 357 UserManager::Get()->OffTheRecordUserLoggedIn(); | 383 UserManager::Get()->OffTheRecordUserLoggedIn(); |
| 358 | 384 |
| 359 if (CrosLibrary::Get()->EnsureLoaded()) { | 385 if (CrosLibrary::Get()->EnsureLoaded()) { |
| 360 // For guest session we ask session manager to restart Chrome with --bwsi | 386 // For guest session we ask session manager to restart Chrome with --bwsi |
| 361 // flag. We keep only some of the arguments of this process. | 387 // 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; | 552 BrowserInit browser_init; |
| 527 int return_code; | 553 int return_code; |
| 528 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), | 554 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), |
| 529 profile, | 555 profile, |
| 530 FilePath(), | 556 FilePath(), |
| 531 true, | 557 true, |
| 532 &return_code); | 558 &return_code); |
| 533 } | 559 } |
| 534 | 560 |
| 535 } // namespace chromeos | 561 } // namespace chromeos |
| OLD | NEW |