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

Side by Side Diff: chrome/browser/ui/profile_error_dialog.cc

Issue 2929953002: Make profile error dialog async (Closed)
Patch Set: rebase Created 3 years, 6 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/profile_error_dialog.h" 5 #include "chrome/browser/ui/profile_error_dialog.h"
6 6
7 #include "base/auto_reset.h"
8 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/ui/chrome_pages.h" 12 #include "chrome/browser/ui/chrome_pages.h"
13 #include "chrome/browser/ui/simple_message_box.h" 13 #include "chrome/browser/ui/simple_message_box.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 16
17 namespace { 17 namespace {
18 18
19 #if !defined(OS_ANDROID) 19 #if !defined(OS_ANDROID)
20 constexpr char kProfileErrorFeedbackCategory[] = "FEEDBACK_PROFILE_ERROR"; 20 constexpr char kProfileErrorFeedbackCategory[] = "FEEDBACK_PROFILE_ERROR";
21
22 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.
23
24 void OnProfileErrorDialogDismissed(const std::string& diagnostics,
25 bool needs_feedback) {
26 is_showing_profile_error_dialog = false;
27
28 if (!needs_feedback)
29 return;
30
31 std::string feedback_description =
32 l10n_util::GetStringUTF8(IDS_PROFILE_ERROR_FEEDBACK_DESCRIPTION);
33 if (!diagnostics.empty()) {
34 // TODO(afakhry): Add support to inject diagnostics to the feedback
35 // reports without adding them to the description. crbug.com/708511.
36 feedback_description +=
37 "\n\n" +
38 l10n_util::GetStringUTF8(IDS_PROFILE_ERROR_FEEDBACK_DIAGNOSTICS_LINE) +
39 diagnostics;
40 }
41
42 chrome::ShowFeedbackPage(nullptr, chrome::kFeedbackSourceProfileErrorDialog,
43 feedback_description, kProfileErrorFeedbackCategory);
44 }
21 #endif // !defined(OS_ANDROID) 45 #endif // !defined(OS_ANDROID)
22 46
23 } // namespace 47 } // namespace
24 48
25 void ShowProfileErrorDialog(ProfileErrorType type, 49 void ShowProfileErrorDialog(ProfileErrorType type,
26 int message_id, 50 int message_id,
27 const std::string& diagnostics) { 51 const std::string& diagnostics) {
28 #if defined(OS_ANDROID) 52 #if defined(OS_ANDROID)
29 NOTIMPLEMENTED(); 53 NOTIMPLEMENTED();
30 #else 54 #else
31 UMA_HISTOGRAM_ENUMERATION("Profile.ProfileError", static_cast<int>(type), 55 UMA_HISTOGRAM_ENUMERATION("Profile.ProfileError", static_cast<int>(type),
32 static_cast<int>(ProfileErrorType::END)); 56 static_cast<int>(ProfileErrorType::END));
33 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 57 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
34 switches::kNoErrorDialogs)) { 58 switches::kNoErrorDialogs)) {
35 return; 59 return;
36 } 60 }
37 61
38 static bool is_showing_profile_error_dialog = false;
39 if (is_showing_profile_error_dialog) 62 if (is_showing_profile_error_dialog)
40 return; 63 return;
41 64
42 base::AutoReset<bool> resetter(&is_showing_profile_error_dialog, true); 65 is_showing_profile_error_dialog = true;
43 if (chrome::ShowWarningMessageBoxWithCheckbox( 66 chrome::ShowWarningMessageBoxWithCheckbox(
44 nullptr, l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_TITLE), 67 nullptr, l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_TITLE),
45 l10n_util::GetStringUTF16(message_id), 68 l10n_util::GetStringUTF16(message_id),
46 l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_CHECKBOX))) { 69 l10n_util::GetStringUTF16(IDS_PROFILE_ERROR_DIALOG_CHECKBOX),
47 std::string feedback_description = 70 base::Bind(&OnProfileErrorDialogDismissed, diagnostics));
48 l10n_util::GetStringUTF8(IDS_PROFILE_ERROR_FEEDBACK_DESCRIPTION);
49 if (!diagnostics.empty()) {
50 // TODO(afakhry): Add support to inject diagnostics to the feedback
51 // reports without adding them to the description. crbug.com/708511.
52 feedback_description += "\n\n" +
53 l10n_util::GetStringUTF8(
54 IDS_PROFILE_ERROR_FEEDBACK_DIAGNOSTICS_LINE) +
55 diagnostics;
56 }
57
58 chrome::ShowFeedbackPage(nullptr, chrome::kFeedbackSourceProfileErrorDialog,
59 feedback_description,
60 kProfileErrorFeedbackCategory);
61 }
62 #endif 71 #endif
63 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698