Chromium Code Reviews| Index: chrome/browser/ui/profile_error_dialog.cc |
| diff --git a/chrome/browser/ui/profile_error_dialog.cc b/chrome/browser/ui/profile_error_dialog.cc |
| index 93b5c947b5343e3b9277d784f49fd2687ac1d095..3be31e61b17fa490d83922d35c5dcd2d12f772e7 100644 |
| --- a/chrome/browser/ui/profile_error_dialog.cc |
| +++ b/chrome/browser/ui/profile_error_dialog.cc |
| @@ -4,8 +4,8 @@ |
| #include "chrome/browser/ui/profile_error_dialog.h" |
| -#include "base/auto_reset.h" |
| #include "base/base_switches.h" |
| +#include "base/bind.h" |
| #include "base/command_line.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "build/build_config.h" |
| @@ -18,6 +18,30 @@ namespace { |
| #if !defined(OS_ANDROID) |
| constexpr char kProfileErrorFeedbackCategory[] = "FEEDBACK_PROFILE_ERROR"; |
| + |
| +bool is_showing_profile_error_dialog = false; |
|
Peter Kasting
2017/06/12 23:54:19
Nit: "g_" prefix?
xiyuan
2017/06/13 21:49:44
Done.
|
| + |
| +void OnProfileErrorDialogDismissed(const std::string& diagnostics, |
| + bool needs_feedback) { |
| + is_showing_profile_error_dialog = false; |
| + |
| + if (!needs_feedback) |
| + return; |
| + |
| + std::string feedback_description = |
| + l10n_util::GetStringUTF8(IDS_PROFILE_ERROR_FEEDBACK_DESCRIPTION); |
| + if (!diagnostics.empty()) { |
| + // TODO(afakhry): Add support to inject diagnostics to the feedback |
| + // reports without adding them to the description. crbug.com/708511. |
| + feedback_description += |
| + "\n\n" + |
| + l10n_util::GetStringUTF8(IDS_PROFILE_ERROR_FEEDBACK_DIAGNOSTICS_LINE) + |
| + diagnostics; |
| + } |
| + |
| + chrome::ShowFeedbackPage(nullptr, chrome::kFeedbackSourceProfileErrorDialog, |
| + feedback_description, kProfileErrorFeedbackCategory); |
| +} |
| #endif // !defined(OS_ANDROID) |
| } // namespace |
| @@ -35,29 +59,14 @@ void ShowProfileErrorDialog(ProfileErrorType type, |
| return; |
| } |
| - static bool is_showing_profile_error_dialog = false; |
| if (is_showing_profile_error_dialog) |
| return; |
| - base::AutoReset<bool> resetter(&is_showing_profile_error_dialog, true); |
| - if (chrome::ShowWarningMessageBoxWithCheckbox( |
| - nullptr, l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_TITLE), |
| - l10n_util::GetStringUTF16(message_id), |
| - l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_CHECKBOX))) { |
| - std::string feedback_description = |
| - l10n_util::GetStringUTF8(IDS_PROFILE_ERROR_FEEDBACK_DESCRIPTION); |
| - if (!diagnostics.empty()) { |
| - // TODO(afakhry): Add support to inject diagnostics to the feedback |
| - // reports without adding them to the description. crbug.com/708511. |
| - feedback_description += "\n\n" + |
| - l10n_util::GetStringUTF8( |
| - IDS_PROFILE_ERROR_FEEDBACK_DIAGNOSTICS_LINE) + |
| - diagnostics; |
| - } |
| - |
| - chrome::ShowFeedbackPage(nullptr, chrome::kFeedbackSourceProfileErrorDialog, |
| - feedback_description, |
| - kProfileErrorFeedbackCategory); |
| - } |
| + is_showing_profile_error_dialog = true; |
| + chrome::ShowWarningMessageBoxWithCheckbox( |
| + nullptr, l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_TITLE), |
| + l10n_util::GetStringUTF16(message_id), |
| + l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_CHECKBOX), |
| + base::Bind(&OnProfileErrorDialogDismissed, diagnostics)); |
| #endif |
| } |