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

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

Issue 6257006: Move a bunch of random other files to src/ui/base... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/cocoa/js_modal_dialog_cocoa.h" 5 #include "chrome/browser/ui/cocoa/js_modal_dialog_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "app/l10n_util_mac.h" 9 #include "app/l10n_util_mac.h"
10 #include "app/message_box_flags.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #import "base/mac/cocoa_protocols.h" 11 #import "base/mac/cocoa_protocols.h"
13 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
14 #import "chrome/browser/chrome_browser_application_mac.h" 13 #import "chrome/browser/chrome_browser_application_mac.h"
15 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" 14 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
16 #include "grit/app_strings.h" 15 #include "grit/app_strings.h"
17 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "ui/base/message_box_flags.h"
18 18
19 // Helper object that receives the notification that the dialog/sheet is 19 // Helper object that receives the notification that the dialog/sheet is
20 // going away. Is responsible for cleaning itself up. 20 // going away. Is responsible for cleaning itself up.
21 @interface JavaScriptAppModalDialogHelper : NSObject<NSAlertDelegate> { 21 @interface JavaScriptAppModalDialogHelper : NSObject<NSAlertDelegate> {
22 @private 22 @private
23 NSAlert* alert_; 23 NSAlert* alert_;
24 NSTextField* textField_; // WEAK; owned by alert_ 24 NSTextField* textField_; // WEAK; owned by alert_
25 } 25 }
26 26
27 - (NSAlert*)alert; 27 - (NSAlert*)alert;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 : dialog_(dialog), 99 : dialog_(dialog),
100 helper_(NULL) { 100 helper_(NULL) {
101 // Determine the names of the dialog buttons based on the flags. "Default" 101 // Determine the names of the dialog buttons based on the flags. "Default"
102 // is the OK button. "Other" is the cancel button. We don't use the 102 // is the OK button. "Other" is the cancel button. We don't use the
103 // "Alternate" button in NSRunAlertPanel. 103 // "Alternate" button in NSRunAlertPanel.
104 NSString* default_button = l10n_util::GetNSStringWithFixup(IDS_APP_OK); 104 NSString* default_button = l10n_util::GetNSStringWithFixup(IDS_APP_OK);
105 NSString* other_button = l10n_util::GetNSStringWithFixup(IDS_APP_CANCEL); 105 NSString* other_button = l10n_util::GetNSStringWithFixup(IDS_APP_CANCEL);
106 bool text_field = false; 106 bool text_field = false;
107 bool one_button = false; 107 bool one_button = false;
108 switch (dialog_->dialog_flags()) { 108 switch (dialog_->dialog_flags()) {
109 case MessageBoxFlags::kIsJavascriptAlert: 109 case ui::MessageBoxFlags::kIsJavascriptAlert:
110 one_button = true; 110 one_button = true;
111 break; 111 break;
112 case MessageBoxFlags::kIsJavascriptConfirm: 112 case ui::MessageBoxFlags::kIsJavascriptConfirm:
113 if (dialog_->is_before_unload_dialog()) { 113 if (dialog_->is_before_unload_dialog()) {
114 default_button = l10n_util::GetNSStringWithFixup( 114 default_button = l10n_util::GetNSStringWithFixup(
115 IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL); 115 IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL);
116 other_button = l10n_util::GetNSStringWithFixup( 116 other_button = l10n_util::GetNSStringWithFixup(
117 IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL); 117 IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL);
118 } 118 }
119 break; 119 break;
120 case MessageBoxFlags::kIsJavascriptPrompt: 120 case ui::MessageBoxFlags::kIsJavascriptPrompt:
121 text_field = true; 121 text_field = true;
122 break; 122 break;
123 123
124 default: 124 default:
125 NOTREACHED(); 125 NOTREACHED();
126 } 126 }
127 127
128 // Create a helper which will receive the sheet ended selector. It will 128 // Create a helper which will receive the sheet ended selector. It will
129 // delete itself when done. It doesn't need anything passed to its init 129 // delete itself when done. It doesn't need anything passed to its init
130 // as it will get a contextInfo parameter. 130 // as it will get a contextInfo parameter.
(...skipping 28 matching lines...) Expand all
159 159
160 //////////////////////////////////////////////////////////////////////////////// 160 ////////////////////////////////////////////////////////////////////////////////
161 // JSModalDialogCocoa, NativeAppModalDialog implementation: 161 // JSModalDialogCocoa, NativeAppModalDialog implementation:
162 162
163 int JSModalDialogCocoa::GetAppModalDialogButtons() const { 163 int JSModalDialogCocoa::GetAppModalDialogButtons() const {
164 // From the above, it is the case that if there is 1 button, it is always the 164 // From the above, it is the case that if there is 1 button, it is always the
165 // OK button. The second button, if it exists, is always the Cancel button. 165 // OK button. The second button, if it exists, is always the Cancel button.
166 int num_buttons = [[alert_ buttons] count]; 166 int num_buttons = [[alert_ buttons] count];
167 switch (num_buttons) { 167 switch (num_buttons) {
168 case 1: 168 case 1:
169 return MessageBoxFlags::DIALOGBUTTON_OK; 169 return ui::MessageBoxFlags::DIALOGBUTTON_OK;
170 case 2: 170 case 2:
171 return MessageBoxFlags::DIALOGBUTTON_OK | 171 return ui::MessageBoxFlags::DIALOGBUTTON_OK |
172 MessageBoxFlags::DIALOGBUTTON_CANCEL; 172 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL;
173 default: 173 default:
174 NOTREACHED(); 174 NOTREACHED();
175 return 0; 175 return 0;
176 } 176 }
177 } 177 }
178 178
179 void JSModalDialogCocoa::ShowAppModalDialog() { 179 void JSModalDialogCocoa::ShowAppModalDialog() {
180 [alert_ 180 [alert_
181 beginSheetModalForWindow:nil // nil here makes it app-modal 181 beginSheetModalForWindow:nil // nil here makes it app-modal
182 modalDelegate:helper_.get() 182 modalDelegate:helper_.get()
(...skipping 28 matching lines...) Expand all
211 211
212 //////////////////////////////////////////////////////////////////////////////// 212 ////////////////////////////////////////////////////////////////////////////////
213 // NativeAppModalDialog, public: 213 // NativeAppModalDialog, public:
214 214
215 // static 215 // static
216 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( 216 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt(
217 JavaScriptAppModalDialog* dialog, 217 JavaScriptAppModalDialog* dialog,
218 gfx::NativeWindow parent_window) { 218 gfx::NativeWindow parent_window) {
219 return new JSModalDialogCocoa(dialog); 219 return new JSModalDialogCocoa(dialog);
220 } 220 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/external_protocol_dialog.mm ('k') | chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698