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

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

Issue 7096016: Remove JS dialog dependency from content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now a tc delegate Created 9 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 | 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 "base/logging.h" 9 #include "base/logging.h"
10 #import "base/mac/cocoa_protocols.h" 10 #import "base/mac/cocoa_protocols.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 [alert_ release]; 52 [alert_ release];
53 [super dealloc]; 53 [super dealloc];
54 } 54 }
55 55
56 // |contextInfo| is the JSModalDialogCocoa that owns us. 56 // |contextInfo| is the JSModalDialogCocoa that owns us.
57 - (void)alertDidEnd:(NSAlert*)alert 57 - (void)alertDidEnd:(NSAlert*)alert
58 returnCode:(int)returnCode 58 returnCode:(int)returnCode
59 contextInfo:(void*)contextInfo { 59 contextInfo:(void*)contextInfo {
60 scoped_ptr<JSModalDialogCocoa> native_dialog( 60 scoped_ptr<JSModalDialogCocoa> native_dialog(
61 reinterpret_cast<JSModalDialogCocoa*>(contextInfo)); 61 reinterpret_cast<JSModalDialogCocoa*>(contextInfo));
62 std::wstring input; 62 string16 input;
63 if (textField_) 63 if (textField_)
64 input = base::SysNSStringToWide([textField_ stringValue]); 64 input = base::SysNSStringToUTF16([textField_ stringValue]);
65 bool shouldSuppress = false; 65 bool shouldSuppress = false;
66 if ([alert showsSuppressionButton]) 66 if ([alert showsSuppressionButton])
67 shouldSuppress = [[alert suppressionButton] state] == NSOnState; 67 shouldSuppress = [[alert suppressionButton] state] == NSOnState;
68 switch (returnCode) { 68 switch (returnCode) {
69 case NSAlertFirstButtonReturn: { // OK 69 case NSAlertFirstButtonReturn: { // OK
70 native_dialog->dialog()->OnAccept(input, shouldSuppress); 70 native_dialog->dialog()->OnAccept(input, shouldSuppress);
71 break; 71 break;
72 } 72 }
73 case NSAlertSecondButtonReturn: { // Cancel 73 case NSAlertSecondButtonReturn: { // Cancel
74 // If the user wants to stay on this page, stop quitting (if a quit is in 74 // If the user wants to stay on this page, stop quitting (if a quit is in
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
131 helper_.reset([[JavaScriptAppModalDialogHelper alloc] init]); 131 helper_.reset([[JavaScriptAppModalDialogHelper alloc] init]);
132 132
133 // Show the modal dialog. 133 // Show the modal dialog.
134 alert_ = [helper_ alert]; 134 alert_ = [helper_ alert];
135 NSTextField* field = nil; 135 NSTextField* field = nil;
136 if (text_field) { 136 if (text_field) {
137 field = [helper_ textField]; 137 field = [helper_ textField];
138 [field setStringValue:base::SysWideToNSString( 138 [field setStringValue:base::SysUTF16ToNSString(
139 dialog_->default_prompt_text())]; 139 dialog_->default_prompt_text())];
140 } 140 }
141 [alert_ setDelegate:helper_]; 141 [alert_ setDelegate:helper_];
142 [alert_ setInformativeText:base::SysWideToNSString(dialog_->message_text())]; 142 [alert_ setInformativeText:base::SysUTF16ToNSString(dialog_->message_text())];
143 [alert_ setMessageText:base::SysWideToNSString(dialog_->title())]; 143 [alert_ setMessageText:base::SysUTF16ToNSString(dialog_->title())];
144 [alert_ addButtonWithTitle:default_button]; 144 [alert_ addButtonWithTitle:default_button];
145 if (!one_button) { 145 if (!one_button) {
146 NSButton* other = [alert_ addButtonWithTitle:other_button]; 146 NSButton* other = [alert_ addButtonWithTitle:other_button];
147 [other setKeyEquivalent:@"\e"]; 147 [other setKeyEquivalent:@"\e"];
148 } 148 }
149 if (dialog_->display_suppress_checkbox()) { 149 if (dialog_->display_suppress_checkbox()) {
150 [alert_ setShowsSuppressionButton:YES]; 150 [alert_ setShowsSuppressionButton:YES];
151 NSString* suppression_title = l10n_util::GetNSStringWithFixup( 151 NSString* suppression_title = l10n_util::GetNSStringWithFixup(
152 IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION); 152 IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION);
153 [[alert_ suppressionButton] setTitle:suppression_title]; 153 [[alert_ suppressionButton] setTitle:suppression_title];
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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

Powered by Google App Engine
This is Rietveld 408576698