Commit cbce4724 authored by tony@chromium.org's avatar tony@chromium.org

If no locale data files can be found, show a dialog and exit

with RESULT_CODE_MISSING_DATA.  We used to just CHECK() crash.

BUG=69194


Review URL: http://codereview.chromium.org/7610009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96627 0039d316-1c4b-4281-b951-d872f2087c98
parent 939c013a
......@@ -831,6 +831,14 @@ bool IsCrashReportingEnabled(const PrefService* local_state) {
} // namespace
namespace chrome_browser {
// This error message is not localized because we failed to load the
// localization data files.
const char kMissingLocaleDataTitle[] = "Missing File Error";
const char kMissingLocaleDataMessage[] =
"Unable to find locale data files. Please reinstall.";
} // namespace chrome_browser
// BrowserMainParts ------------------------------------------------------------
BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters)
......@@ -1440,6 +1448,11 @@ int BrowserMain(const MainFunctionParams& parameters) {
// method InitSharedInstance is ignored.
const std::string loaded_locale =
ResourceBundle::InitSharedInstance(locale);
if (loaded_locale.empty() &&
!parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) {
ShowMissingLocaleMessageBox();
return chrome::RESULT_CODE_MISSING_DATA;
}
CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale;
g_browser_process->SetApplicationLocale(loaded_locale);
......
......@@ -30,6 +30,12 @@ namespace net {
class NetworkChangeNotifier;
}
namespace chrome_browser {
// For use by ShowMissingLocaleMessageBox.
extern const char kMissingLocaleDataTitle[];
extern const char kMissingLocaleDataMessage[];
}
// BrowserMainParts:
// This class contains different "stages" to be executed in |BrowserMain()|,
// mostly initialization. This is made into a class rather than just functions
......@@ -201,6 +207,9 @@ void RecordBreakpadStatusUMA(MetricsService* metrics);
// present on the current platform.
void WarnAboutMinimumSystemRequirements();
// Displays a warning message that we can't find any locale data files.
void ShowMissingLocaleMessageBox();
// Records the time from our process' startup to the present time in
// the UMA histogram |metric_name|.
void RecordBrowserStartupTime();
......
......@@ -179,6 +179,22 @@ void WarnAboutMinimumSystemRequirements() {
// Nothing to warn about on GTK right now.
}
void ShowMissingLocaleMessageBox() {
GtkWidget* dialog = gtk_message_dialog_new(
NULL,
static_cast<GtkDialogFlags>(0),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"%s",
chrome_browser::kMissingLocaleDataMessage);
gtk_window_set_title(GTK_WINDOW(dialog),
chrome_browser::kMissingLocaleDataTitle);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
void RecordBrowserStartupTime() {
// Not implemented on GTK for now.
}
......
......@@ -45,6 +45,10 @@ void WarnAboutMinimumSystemRequirements() {
// Nothing to check for on Mac right now.
}
void ShowMissingLocaleMessageBox() {
// Not called on Mac because we load the locale files differently.
}
// From browser_main_win.h, stubs until we figure out the right thing...
int DoUninstallTasks(bool chrome_still_running) {
......
......@@ -83,6 +83,12 @@ void WarnAboutMinimumSystemRequirements() {
}
}
void ShowMissingLocaleMessageBox() {
ui::MessageBox(NULL, ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage),
ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle),
MB_OK | MB_ICONERROR | MB_TOPMOST);
}
void RecordBrowserStartupTime() {
// Calculate the time that has elapsed from our own process creation.
FILETIME creation_time = {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment