diff options
author | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-22 16:05:57 +0000 |
---|---|---|
committer | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-22 16:05:57 +0000 |
commit | 455ee19d2e3d8c78dfa38967bb484f276a812647 (patch) | |
tree | 3b7deaabc03d784ed5d70f92305375731da4557d /chrome/browser | |
parent | 95bf8a5bab5b636d63862a83b6930a414d1bad0b (diff) | |
download | chromium_src-455ee19d2e3d8c78dfa38967bb484f276a812647.zip chromium_src-455ee19d2e3d8c78dfa38967bb484f276a812647.tar.gz chromium_src-455ee19d2e3d8c78dfa38967bb484f276a812647.tar.bz2 |
Error handling added
BUG=chromium-os:10033
TEST=none
Review URL: http://codereview.chromium.org/5939002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_main.cc | 12 | ||||
-rw-r--r-- | chrome/browser/browser_main_mac.mm | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/language_switch_menu.cc | 9 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/wizard_controller.cc | 5 |
4 files changed, 21 insertions, 10 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 904c6e2..7f535f6 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -615,7 +615,8 @@ PrefService* InitializeLocalState(const CommandLine& parsed_command_line, // Initialize ResourceBundle which handles files loaded from external // sources. This has to be done before uninstall code path and before prefs // are registered. - local_state->RegisterStringPref(prefs::kApplicationLocale, ""); + local_state->RegisterStringPref(prefs::kApplicationLocale, + std::string()); #if !defined(OS_CHROMEOS) local_state->RegisterBooleanPref(prefs::kMetricsReportingEnabled, GoogleUpdateSettings::GetCollectStatsConsent()); @@ -1151,9 +1152,12 @@ int BrowserMain(const MainFunctionParams& parameters) { #else // On a POSIX OS other than ChromeOS, the parameter that is passed to the // method InitSharedInstance is ignored. - std::string app_locale = ResourceBundle::InitSharedInstance( - local_state->GetString(prefs::kApplicationLocale)); - g_browser_process->SetApplicationLocale(app_locale); + const std::string locale = + local_state->GetString(prefs::kApplicationLocale); + const std::string loaded_locale = + ResourceBundle::InitSharedInstance(locale); + CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; + g_browser_process->SetApplicationLocale(loaded_locale); FilePath resources_pack_path; PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); diff --git a/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm index 98629ba..619be2d 100644 --- a/chrome/browser/browser_main_mac.mm +++ b/chrome/browser/browser_main_mac.mm @@ -99,10 +99,11 @@ class BrowserMainPartsMac : public BrowserMainPartsPosix { // Before we load the nib, we need to start up the resource bundle so we // have the strings avaiable for localization. - std::string pref_locale; // TODO(markusheintz): Read preference pref::kApplicationLocale in order // to enforce the application locale. - ResourceBundle::InitSharedInstance(pref_locale); + const std::string loaded_locale = + ResourceBundle::InitSharedInstance(std::string()); + CHECK(!loaded_locale.empty()) << "Default locale could not be found"; FilePath resources_pack_path; PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); diff --git a/chrome/browser/chromeos/login/language_switch_menu.cc b/chrome/browser/chromeos/login/language_switch_menu.cc index c18d20d..5e25f23 100644 --- a/chrome/browser/chromeos/login/language_switch_menu.cc +++ b/chrome/browser/chromeos/login/language_switch_menu.cc @@ -67,8 +67,9 @@ 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); + CHECK_NE(-1, index) << "Unknown locale: " << locale; + return language_list_->GetLanguageNameAt(index); }; void LanguageSwitchMenu::SetFirstLevelMenuWidth(int width) { @@ -93,7 +94,9 @@ void LanguageSwitchMenu::SwitchLanguage(const std::string& locale) { prefs->SavePersistentPrefs(); // Switch the locale. - ResourceBundle::ReloadSharedInstance(locale); + const std::string loaded_locale = + ResourceBundle::ReloadSharedInstance(locale); + CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; // Enable the keyboard layouts that are necessary for the new locale. input_method::EnableInputMethods( diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 15cc8b5..a3b7efd 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -1007,7 +1007,10 @@ void ShowLoginWizard(const std::string& first_screen_name, locale = controller->GetCustomization()->initial_locale(); VLOG(1) << "Initial locale: " << locale; if (!locale.empty()) { - ResourceBundle::ReloadSharedInstance(locale); + const std::string loaded_locale = + ResourceBundle::ReloadSharedInstance(locale); + CHECK(!loaded_locale.empty()) << "Locale could not be found for " + << locale; } } } |