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

Side by Side Diff: chrome/browser/ui/cocoa/simple_message_box_mac.mm

Issue 2107493002: Offer user to send feedback from profile error dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pkasting's & droger's Created 4 years, 4 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
« no previous file with comments | « chrome/browser/ui/chrome_pages.h ('k') | chrome/browser/ui/profile_error_dialog.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/simple_message_box.h" 5 #include "chrome/browser/ui/simple_message_box.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
10 #include "chrome/browser/ui/simple_message_box_internal.h" 11 #include "chrome/browser/ui/simple_message_box_internal.h"
11 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
12 #include "components/startup_metric_utils/browser/startup_metric_utils.h" 13 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
13 #include "grit/components_strings.h" 14 #include "grit/components_strings.h"
14 #include "ui/base/l10n/l10n_util_mac.h" 15 #include "ui/base/l10n/l10n_util_mac.h"
15 16
16 namespace chrome { 17 namespace chrome {
17 18
18 namespace { 19 namespace {
19 20
20 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, 21 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent,
21 const base::string16& title, 22 const base::string16& title,
22 const base::string16& message, 23 const base::string16& message,
24 const base::string16& checkbox_text,
23 MessageBoxType type) { 25 MessageBoxType type) {
24 startup_metric_utils::SetNonBrowserUIDisplayed(); 26 startup_metric_utils::SetNonBrowserUIDisplayed();
25 if (internal::g_should_skip_message_box_for_test) 27 if (internal::g_should_skip_message_box_for_test)
26 return MESSAGE_BOX_RESULT_YES; 28 return MESSAGE_BOX_RESULT_YES;
27 29
28 // Ignore the title; it's the window title on other platforms and ignorable. 30 // Ignore the title; it's the window title on other platforms and ignorable.
29 NSAlert* alert = [[[NSAlert alloc] init] autorelease]; 31 NSAlert* alert = [[[NSAlert alloc] init] autorelease];
30 [alert setMessageText:base::SysUTF16ToNSString(message)]; 32 [alert setMessageText:base::SysUTF16ToNSString(message)];
31 [alert setAlertStyle:NSWarningAlertStyle]; 33 [alert setAlertStyle:NSWarningAlertStyle];
32 if (type == MESSAGE_BOX_TYPE_QUESTION) { 34 if (type == MESSAGE_BOX_TYPE_QUESTION) {
33 [alert addButtonWithTitle: 35 [alert addButtonWithTitle:
34 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)]; 36 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)];
35 [alert addButtonWithTitle: 37 [alert addButtonWithTitle:
36 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)]; 38 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)];
37 } else { 39 } else {
38 [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)]; 40 [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)];
39 } 41 }
42
43 base::scoped_nsobject<NSButton> checkbox;
44 if (!checkbox_text.empty()) {
45 checkbox.reset([[NSButton alloc] initWithFrame:NSZeroRect]);
46 [checkbox setButtonType:NSSwitchButton];
47 [checkbox setTitle:base::SysUTF16ToNSString(checkbox_text)];
48 [checkbox sizeToFit];
49 [alert setAccessoryView:checkbox];
50 }
51
40 NSInteger result = [alert runModal]; 52 NSInteger result = [alert runModal];
41 return (result == NSAlertSecondButtonReturn) ? 53 if (result == NSAlertSecondButtonReturn)
42 MESSAGE_BOX_RESULT_NO : MESSAGE_BOX_RESULT_YES; 54 return MESSAGE_BOX_RESULT_NO;
55
56 if (!checkbox || ([checkbox state] == NSOnState))
57 return MESSAGE_BOX_RESULT_YES;
58
59 return MESSAGE_BOX_RESULT_NO;
43 } 60 }
44 61
45 } // namespace 62 } // namespace
46 63
47 void ShowWarningMessageBox(gfx::NativeWindow parent, 64 void ShowWarningMessageBox(gfx::NativeWindow parent,
48 const base::string16& title, 65 const base::string16& title,
49 const base::string16& message) { 66 const base::string16& message) {
50 ShowMessageBox(parent, title, message, MESSAGE_BOX_TYPE_WARNING); 67 ShowMessageBox(parent, title, message, base::string16(),
68 MESSAGE_BOX_TYPE_WARNING);
69 }
70
71 bool ShowWarningMessageBoxWithCheckbox(gfx::NativeWindow parent,
72 const base::string16& title,
73 const base::string16& message,
74 const base::string16& checkbox_text) {
75 ShowMessageBox(parent, title, message, checkbox_text,
76 MESSAGE_BOX_TYPE_WARNING);
77 return false;
51 } 78 }
52 79
53 MessageBoxResult ShowQuestionMessageBox(gfx::NativeWindow parent, 80 MessageBoxResult ShowQuestionMessageBox(gfx::NativeWindow parent,
54 const base::string16& title, 81 const base::string16& title,
55 const base::string16& message) { 82 const base::string16& message) {
56 return ShowMessageBox(parent, title, message, MESSAGE_BOX_TYPE_QUESTION); 83 return ShowMessageBox(parent, title, message, base::string16(),
84 MESSAGE_BOX_TYPE_QUESTION);
57 } 85 }
58 86
59 } // namespace chrome 87 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/chrome_pages.h ('k') | chrome/browser/ui/profile_error_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698