OLD | NEW |
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 [NSApp endSheet:[alert_ window]]; | 81 [NSApp endSheet:[alert_ window]]; |
82 alert_.reset(); | 82 alert_.reset(); |
83 } | 83 } |
84 | 84 |
85 @end | 85 @end |
86 | 86 |
87 namespace content { | 87 namespace content { |
88 | 88 |
89 ShellJavaScriptDialog::ShellJavaScriptDialog( | 89 ShellJavaScriptDialog::ShellJavaScriptDialog( |
90 ShellJavaScriptDialogCreator* creator, | 90 ShellJavaScriptDialogCreator* creator, |
91 ui::JavascriptMessageType javascript_message_type, | 91 JavaScriptMessageType message_type, |
92 const string16& message_text, | 92 const string16& message_text, |
93 const string16& default_prompt_text, | 93 const string16& default_prompt_text, |
94 const JavaScriptDialogCreator::DialogClosedCallback& callback) | 94 const JavaScriptDialogCreator::DialogClosedCallback& callback) |
95 : creator_(creator), | 95 : creator_(creator), |
96 callback_(callback) { | 96 callback_(callback) { |
97 bool text_field = | 97 bool text_field = message_type == JAVASCRIPT_MESSAGE_TYPE_PROMPT; |
98 javascript_message_type == ui::JAVASCRIPT_MESSAGE_TYPE_PROMPT; | 98 bool one_button = message_type == JAVASCRIPT_MESSAGE_TYPE_ALERT; |
99 bool one_button = | |
100 javascript_message_type == ui::JAVASCRIPT_MESSAGE_TYPE_ALERT; | |
101 | 99 |
102 helper_ = | 100 helper_ = |
103 [[ShellJavaScriptDialogHelper alloc] initHelperWithCreator:creator | 101 [[ShellJavaScriptDialogHelper alloc] initHelperWithCreator:creator |
104 andCallback:callback]; | 102 andCallback:callback]; |
105 | 103 |
106 // Show the modal dialog. | 104 // Show the modal dialog. |
107 NSAlert* alert = [helper_ alert]; | 105 NSAlert* alert = [helper_ alert]; |
108 NSTextField* field = nil; | 106 NSTextField* field = nil; |
109 if (text_field) { | 107 if (text_field) { |
110 field = [helper_ textField]; | 108 field = [helper_ textField]; |
(...skipping 20 matching lines...) Expand all Loading... |
131 | 129 |
132 ShellJavaScriptDialog::~ShellJavaScriptDialog() { | 130 ShellJavaScriptDialog::~ShellJavaScriptDialog() { |
133 [helper_ release]; | 131 [helper_ release]; |
134 } | 132 } |
135 | 133 |
136 void ShellJavaScriptDialog::Cancel() { | 134 void ShellJavaScriptDialog::Cancel() { |
137 [helper_ cancel]; | 135 [helper_ cancel]; |
138 } | 136 } |
139 | 137 |
140 } // namespace content | 138 } // namespace content |
OLD | NEW |