| OLD | NEW |
| 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" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #import "chrome/browser/chrome_browser_application_mac.h" | 12 #import "chrome/browser/chrome_browser_application_mac.h" |
| 13 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 13 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "grit/ui_strings.h" | 15 #include "grit/ui_strings.h" |
| 16 #include "ui/base/l10n/l10n_util_mac.h" | 16 #include "ui/base/l10n/l10n_util_mac.h" |
| 17 #include "ui/base/message_box_flags.h" | |
| 18 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 19 | 18 |
| 20 // Helper object that receives the notification that the dialog/sheet is | 19 // Helper object that receives the notification that the dialog/sheet is |
| 21 // going away. Is responsible for cleaning itself up. | 20 // going away. Is responsible for cleaning itself up. |
| 22 @interface JavaScriptAppModalDialogHelper : NSObject<NSAlertDelegate> { | 21 @interface JavaScriptAppModalDialogHelper : NSObject<NSAlertDelegate> { |
| 23 @private | 22 @private |
| 24 NSAlert* alert_; | 23 NSAlert* alert_; |
| 25 NSTextField* textField_; // WEAK; owned by alert_ | 24 NSTextField* textField_; // WEAK; owned by alert_ |
| 26 } | 25 } |
| 27 | 26 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 JSModalDialogCocoa::JSModalDialogCocoa(JavaScriptAppModalDialog* dialog) | 98 JSModalDialogCocoa::JSModalDialogCocoa(JavaScriptAppModalDialog* dialog) |
| 100 : dialog_(dialog), | 99 : dialog_(dialog), |
| 101 helper_(NULL) { | 100 helper_(NULL) { |
| 102 // 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" |
| 103 // 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 |
| 104 // "Alternate" button in NSRunAlertPanel. | 103 // "Alternate" button in NSRunAlertPanel. |
| 105 NSString* default_button = l10n_util::GetNSStringWithFixup(IDS_APP_OK); | 104 NSString* default_button = l10n_util::GetNSStringWithFixup(IDS_APP_OK); |
| 106 NSString* other_button = l10n_util::GetNSStringWithFixup(IDS_APP_CANCEL); | 105 NSString* other_button = l10n_util::GetNSStringWithFixup(IDS_APP_CANCEL); |
| 107 bool text_field = false; | 106 bool text_field = false; |
| 108 bool one_button = false; | 107 bool one_button = false; |
| 109 switch (dialog_->dialog_flags()) { | 108 switch (dialog_->javascript_message_type()) { |
| 110 case ui::MessageBoxFlags::kIsJavascriptAlert: | 109 case ui::JAVASCRIPT_MESSAGE_TYPE_ALERT: |
| 111 one_button = true; | 110 one_button = true; |
| 112 break; | 111 break; |
| 113 case ui::MessageBoxFlags::kIsJavascriptConfirm: | 112 case ui::JAVASCRIPT_MESSAGE_TYPE_CONFIRM: |
| 114 if (dialog_->is_before_unload_dialog()) { | 113 if (dialog_->is_before_unload_dialog()) { |
| 115 default_button = l10n_util::GetNSStringWithFixup( | 114 default_button = l10n_util::GetNSStringWithFixup( |
| 116 IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL); | 115 IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL); |
| 117 other_button = l10n_util::GetNSStringWithFixup( | 116 other_button = l10n_util::GetNSStringWithFixup( |
| 118 IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL); | 117 IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL); |
| 119 } | 118 } |
| 120 break; | 119 break; |
| 121 case ui::MessageBoxFlags::kIsJavascriptPrompt: | 120 case ui::JAVASCRIPT_MESSAGE_TYPE_PROMPT: |
| 122 text_field = true; | 121 text_field = true; |
| 123 break; | 122 break; |
| 124 | 123 |
| 125 default: | 124 default: |
| 126 NOTREACHED(); | 125 NOTREACHED(); |
| 127 } | 126 } |
| 128 | 127 |
| 129 // 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 |
| 130 // 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 |
| 131 // as it will get a contextInfo parameter. | 130 // as it will get a contextInfo parameter. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 210 |
| 212 //////////////////////////////////////////////////////////////////////////////// | 211 //////////////////////////////////////////////////////////////////////////////// |
| 213 // NativeAppModalDialog, public: | 212 // NativeAppModalDialog, public: |
| 214 | 213 |
| 215 // static | 214 // static |
| 216 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( | 215 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( |
| 217 JavaScriptAppModalDialog* dialog, | 216 JavaScriptAppModalDialog* dialog, |
| 218 gfx::NativeWindow parent_window) { | 217 gfx::NativeWindow parent_window) { |
| 219 return new JSModalDialogCocoa(dialog); | 218 return new JSModalDialogCocoa(dialog); |
| 220 } | 219 } |
| OLD | NEW |