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

Unified Diff: chrome/browser/chromeos/login/language_switch_menu.cc

Issue 5939002: Error handling added (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: InitSharedResource() and ReloadSharedResource() return code is checked Created 10 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/language_switch_menu.cc
diff --git a/chrome/browser/chromeos/login/language_switch_menu.cc b/chrome/browser/chromeos/login/language_switch_menu.cc
index c18d20da42d4925457a8c879dde0b1c298a28df1..01cee907135586a96c45eac73f4d2bc0a66660af 100644
--- a/chrome/browser/chromeos/login/language_switch_menu.cc
+++ b/chrome/browser/chromeos/login/language_switch_menu.cc
@@ -67,8 +67,14 @@ void LanguageSwitchMenu::InitLanguageMenu() {
std::wstring LanguageSwitchMenu::GetCurrentLocaleName() const {
DCHECK(g_browser_process);
const std::string locale = g_browser_process->GetApplicationLocale();
- return language_list_->GetLanguageNameAt(
- language_list_->GetIndexFromLocale(locale));
+ int index = language_list_->GetIndexFromLocale(locale);
+ if (index == -1) {
Peter Kasting 2010/12/20 17:18:48 I don't think we should "handle" this error. IMO
glotov 2010/12/21 13:19:08 Agree. That was my second option but I wanted some
+ // If locale cannot be found (probably resources bundle failed to
+ // load or user edited prefs file manually) - use the default.
+ LOG(DFATAL) << "Unknown locale: " << locale << ". Defaulting to the first.";
+ index = 0;
+ }
+ return language_list_->GetLanguageNameAt(index);
};
void LanguageSwitchMenu::SetFirstLevelMenuWidth(int width) {
@@ -93,7 +99,8 @@ void LanguageSwitchMenu::SwitchLanguage(const std::string& locale) {
prefs->SavePersistentPrefs();
// Switch the locale.
- ResourceBundle::ReloadSharedInstance(locale);
+ CHECK(ResourceBundle::ReloadSharedInstance(locale) == locale)
Peter Kasting 2010/12/20 17:18:48 Never do real work inside a CHECK or DCHECK.
glotov 2010/12/21 13:19:08 Done.
+ << "Locale could not be found for " << locale;
// Enable the keyboard layouts that are necessary for the new locale.
input_method::EnableInputMethods(

Powered by Google App Engine
This is Rietveld 408576698