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

Side by Side Diff: content/shell/shell_javascript_dialog_mac.mm

Issue 9961013: Minor cleaning of shell javascript dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
« no previous file with comments | « content/shell/shell_javascript_dialog.h ('k') | no next file » | 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 "content/shell/shell_javascript_dialog.h" 5 #include "content/shell/shell_javascript_dialog.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #import "base/mac/cocoa_protocols.h" 9 #import "base/mac/cocoa_protocols.h"
10 #import "base/memory/scoped_nsobject.h" 10 #import "base/memory/scoped_nsobject.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool text_field = 97 bool text_field =
98 javascript_message_type == ui::JAVASCRIPT_MESSAGE_TYPE_PROMPT; 98 javascript_message_type == ui::JAVASCRIPT_MESSAGE_TYPE_PROMPT;
99 bool one_button = 99 bool one_button =
100 javascript_message_type == ui::JAVASCRIPT_MESSAGE_TYPE_ALERT; 100 javascript_message_type == ui::JAVASCRIPT_MESSAGE_TYPE_ALERT;
101 101
102 helper_ = 102 helper_ =
103 [[ShellJavaScriptDialogHelper alloc] initHelperWithCreator:creator 103 [[ShellJavaScriptDialogHelper alloc] initHelperWithCreator:creator
104 andCallback:callback]; 104 andCallback:callback];
105 105
106 // Show the modal dialog. 106 // Show the modal dialog.
107 alert_ = [helper_ alert]; 107 NSAlert* alert = [helper_ alert];
108 NSTextField* field = nil; 108 NSTextField* field = nil;
109 if (text_field) { 109 if (text_field) {
110 field = [helper_ textField]; 110 field = [helper_ textField];
111 [field setStringValue:base::SysUTF16ToNSString(default_prompt_text)]; 111 [field setStringValue:base::SysUTF16ToNSString(default_prompt_text)];
112 } 112 }
113 [alert_ setDelegate:helper_]; 113 [alert setDelegate:helper_];
114 [alert_ setInformativeText:base::SysUTF16ToNSString(message_text)]; 114 [alert setInformativeText:base::SysUTF16ToNSString(message_text)];
115 [alert_ setMessageText:@"Javascript alert"]; 115 [alert setMessageText:@"Javascript alert"];
116 [alert_ addButtonWithTitle:@"OK"]; 116 [alert addButtonWithTitle:@"OK"];
117 if (!one_button) { 117 if (!one_button) {
118 NSButton* other = [alert_ addButtonWithTitle:@"Cancel"]; 118 NSButton* other = [alert addButtonWithTitle:@"Cancel"];
119 [other setKeyEquivalent:@"\e"]; 119 [other setKeyEquivalent:@"\e"];
120 } 120 }
121 121
122 [alert_ 122 [alert
123 beginSheetModalForWindow:nil // nil here makes it app-modal 123 beginSheetModalForWindow:nil // nil here makes it app-modal
124 modalDelegate:helper_ 124 modalDelegate:helper_
125 didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) 125 didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
126 contextInfo:this]; 126 contextInfo:this];
127 127
128 if ([alert_ accessoryView]) 128 if ([alert accessoryView])
129 [[alert_ window] makeFirstResponder:[alert_ accessoryView]]; 129 [[alert window] makeFirstResponder:[alert accessoryView]];
130 } 130 }
131 131
132 ShellJavaScriptDialog::~ShellJavaScriptDialog() { 132 ShellJavaScriptDialog::~ShellJavaScriptDialog() {
133 [helper_ release]; 133 [helper_ release];
134 } 134 }
135 135
136 void ShellJavaScriptDialog::Cancel() { 136 void ShellJavaScriptDialog::Cancel() {
137 [helper_ cancel]; 137 [helper_ cancel];
138 } 138 }
139 139
140 } // namespace content 140 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/shell_javascript_dialog.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698