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 "chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 [NSApp endSheet:[[self alert] window]]; | 213 [NSApp endSheet:[[self alert] window]]; |
214 } | 214 } |
215 | 215 |
216 @end | 216 @end |
217 | 217 |
218 //////////////////////////////////////////////////////////////////////////////// | 218 //////////////////////////////////////////////////////////////////////////////// |
219 // JavaScriptAppModalDialogCocoa, public: | 219 // JavaScriptAppModalDialogCocoa, public: |
220 | 220 |
221 JavaScriptAppModalDialogCocoa::JavaScriptAppModalDialogCocoa( | 221 JavaScriptAppModalDialogCocoa::JavaScriptAppModalDialogCocoa( |
222 JavaScriptAppModalDialog* dialog) | 222 app_modal::JavaScriptAppModalDialog* dialog) |
223 : dialog_(dialog), | 223 : dialog_(dialog), |
224 helper_(NULL) { | 224 helper_(NULL) { |
225 // Determine the names of the dialog buttons based on the flags. "Default" | 225 // Determine the names of the dialog buttons based on the flags. "Default" |
226 // is the OK button. "Other" is the cancel button. We don't use the | 226 // is the OK button. "Other" is the cancel button. We don't use the |
227 // "Alternate" button in NSRunAlertPanel. | 227 // "Alternate" button in NSRunAlertPanel. |
228 NSString* default_button = l10n_util::GetNSStringWithFixup(IDS_APP_OK); | 228 NSString* default_button = l10n_util::GetNSStringWithFixup(IDS_APP_OK); |
229 NSString* other_button = l10n_util::GetNSStringWithFixup(IDS_APP_CANCEL); | 229 NSString* other_button = l10n_util::GetNSStringWithFixup(IDS_APP_CANCEL); |
230 bool text_field = false; | 230 bool text_field = false; |
231 bool one_button = false; | 231 bool one_button = false; |
232 switch (dialog_->javascript_message_type()) { | 232 switch (dialog_->javascript_message_type()) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 [helper_ playOrQueueAction:ACTION_ACCEPT]; | 433 [helper_ playOrQueueAction:ACTION_ACCEPT]; |
434 } | 434 } |
435 | 435 |
436 void JavaScriptAppModalDialogCocoa::CancelAppModalDialog() { | 436 void JavaScriptAppModalDialogCocoa::CancelAppModalDialog() { |
437 [helper_ playOrQueueAction:ACTION_CANCEL]; | 437 [helper_ playOrQueueAction:ACTION_CANCEL]; |
438 } | 438 } |
439 | 439 |
440 namespace { | 440 namespace { |
441 | 441 |
442 class ChromeJavaScriptNativeDialogCocoaFactory | 442 class ChromeJavaScriptNativeDialogCocoaFactory |
443 : public JavaScriptNativeDialogFactory { | 443 : public app_modal::JavaScriptNativeDialogFactory { |
444 public: | 444 public: |
445 ChromeJavaScriptNativeDialogCocoaFactory() {} | 445 ChromeJavaScriptNativeDialogCocoaFactory() {} |
446 ~ChromeJavaScriptNativeDialogCocoaFactory() override {} | 446 ~ChromeJavaScriptNativeDialogCocoaFactory() override {} |
447 | 447 |
448 private: | 448 private: |
449 NativeAppModalDialog* CreateNativeJavaScriptDialog( | 449 app_modal::NativeAppModalDialog* CreateNativeJavaScriptDialog( |
450 JavaScriptAppModalDialog* dialog, | 450 app_modal::JavaScriptAppModalDialog* dialog, |
451 gfx::NativeWindow parent_window) override { | 451 gfx::NativeWindow parent_window) override { |
452 return new JavaScriptAppModalDialogCocoa(dialog); | 452 return new JavaScriptAppModalDialogCocoa(dialog); |
453 } | 453 } |
454 | 454 |
455 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogCocoaFactory); | 455 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogCocoaFactory); |
456 }; | 456 }; |
457 | 457 |
458 } // namespace | 458 } // namespace |
459 | 459 |
460 void InstallChromeJavaScriptNativeDialogFactory() { | 460 void InstallChromeJavaScriptNativeDialogFactory() { |
461 SetJavaScriptNativeDialogFactory( | 461 app_modal::JavaScriptDialogManager::GetInstance()-> |
462 make_scoped_ptr(new ChromeJavaScriptNativeDialogCocoaFactory)); | 462 SetNativeDialogFactory( |
| 463 make_scoped_ptr(new ChromeJavaScriptNativeDialogCocoaFactory)); |
463 } | 464 } |
OLD | NEW |