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

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

Issue 819083002: Fix AppModalDialogHelper to deal with a TabStrip without an active tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
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 "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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 218
219 @end 219 @end
220 220
221 //////////////////////////////////////////////////////////////////////////////// 221 ////////////////////////////////////////////////////////////////////////////////
222 // JavaScriptAppModalDialogCocoa, public: 222 // JavaScriptAppModalDialogCocoa, public:
223 223
224 JavaScriptAppModalDialogCocoa::JavaScriptAppModalDialogCocoa( 224 JavaScriptAppModalDialogCocoa::JavaScriptAppModalDialogCocoa(
225 app_modal::JavaScriptAppModalDialog* dialog) 225 app_modal::JavaScriptAppModalDialog* dialog)
226 : dialog_(dialog), 226 : dialog_(dialog),
227 popup_helper_(new AppModalDialogHelper(dialog->web_contents())), 227 popup_helper_(
228 new AppModalDialogHelper(dialog ? dialog->web_contents() : NULL)),
Bernhard Bauer 2014/12/22 13:18:35 nullptr
Bernhard Bauer 2014/12/22 13:18:35 Also, instead of doing this `dialog ? dialog->web_
228 is_showing_(false) { 229 is_showing_(false) {
229 // Determine the names of the dialog buttons based on the flags. "Default" 230 // Determine the names of the dialog buttons based on the flags. "Default"
230 // is the OK button. "Other" is the cancel button. We don't use the 231 // is the OK button. "Other" is the cancel button. We don't use the
231 // "Alternate" button in NSRunAlertPanel. 232 // "Alternate" button in NSRunAlertPanel.
232 NSString* default_button = l10n_util::GetNSStringWithFixup(IDS_APP_OK); 233 NSString* default_button = l10n_util::GetNSStringWithFixup(IDS_APP_OK);
233 NSString* other_button = l10n_util::GetNSStringWithFixup(IDS_APP_CANCEL); 234 NSString* other_button = l10n_util::GetNSStringWithFixup(IDS_APP_CANCEL);
234 bool text_field = false; 235 bool text_field = false;
235 bool one_button = false; 236 bool one_button = false;
236 switch (dialog_->javascript_message_type()) { 237 switch (dialog_->javascript_message_type()) {
Bernhard Bauer 2014/12/22 13:18:35 |dialog_| might be NULL here.
237 case content::JAVASCRIPT_MESSAGE_TYPE_ALERT: 238 case content::JAVASCRIPT_MESSAGE_TYPE_ALERT:
238 one_button = true; 239 one_button = true;
239 break; 240 break;
240 case content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM: 241 case content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM:
241 if (dialog_->is_before_unload_dialog()) { 242 if (dialog_->is_before_unload_dialog()) {
242 if (dialog_->is_reload()) { 243 if (dialog_->is_reload()) {
243 default_button = l10n_util::GetNSStringWithFixup( 244 default_button = l10n_util::GetNSStringWithFixup(
244 IDS_BEFORERELOAD_MESSAGEBOX_OK_BUTTON_LABEL); 245 IDS_BEFORERELOAD_MESSAGEBOX_OK_BUTTON_LABEL);
245 other_button = l10n_util::GetNSStringWithFixup( 246 other_button = l10n_util::GetNSStringWithFixup(
246 IDS_BEFORERELOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL); 247 IDS_BEFORERELOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogCocoaFactory); 466 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogCocoaFactory);
466 }; 467 };
467 468
468 } // namespace 469 } // namespace
469 470
470 void InstallChromeJavaScriptNativeDialogFactory() { 471 void InstallChromeJavaScriptNativeDialogFactory() {
471 app_modal::JavaScriptDialogManager::GetInstance()-> 472 app_modal::JavaScriptDialogManager::GetInstance()->
472 SetNativeDialogFactory( 473 SetNativeDialogFactory(
473 make_scoped_ptr(new ChromeJavaScriptNativeDialogCocoaFactory)); 474 make_scoped_ptr(new ChromeJavaScriptNativeDialogCocoaFactory));
474 } 475 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698