Commit 6d12da2b authored by rob's avatar rob Committed by Commit bot

Show only one profile corrupted dialog, support --noerrdialogs

Make sure that at most one profile corruption error dialog is shown at
any given time. Currently I ocasionally get six dialogs with an
identical error message when I start Chrome while the profile is locked.
Although, the ShowProfileErrorDialog method is called with two different
messages (corrupt profile vs incompatible profile), I have only seen one
of them showing up at any time, so the boolean guard is applied to any
dialog generated by ShowProfileErrorDialog.

R=pkasting@chromium.org
BUG=446732,447791
TEST=Manually:
1. Start Chrome to initialize the profile directory.
2. Close Chrome.
3. Mark database as read-only: chmod a-r "/tmp/profile/Default/Web Data"
4. Start Chrome again.
5. Verify that only one dialog is shown (instead of six).
6. Close Chrome.
7. Start Chrome, with the --noerrdialogs flag.
8. Verify that no error dialogs are displayed at all (instead of six).

Review URL: https://codereview.chromium.org/873253002

Cr-Commit-Position: refs/heads/master@{#314318}
parent 87b67c6d
......@@ -4,6 +4,9 @@
#include "chrome/browser/ui/profile_error_dialog.h"
#include "base/auto_reset.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/grit/chromium_strings.h"
......@@ -14,9 +17,17 @@ void ShowProfileErrorDialog(ProfileErrorType type, int message_id) {
NOTIMPLEMENTED();
#else
UMA_HISTOGRAM_ENUMERATION("Profile.ProfileError", type, PROFILE_ERROR_END);
chrome::ShowMessageBox(NULL,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
l10n_util::GetStringUTF16(message_id),
chrome::MESSAGE_BOX_TYPE_WARNING);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kNoErrorDialogs))
return;
static bool is_showing_profile_error_dialog = false;
if (!is_showing_profile_error_dialog) {
base::AutoReset<bool> resetter(&is_showing_profile_error_dialog, true);
chrome::ShowMessageBox(NULL,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
l10n_util::GetStringUTF16(message_id),
chrome::MESSAGE_BOX_TYPE_WARNING);
}
#endif
}
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