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

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

Issue 1714573002: Remove the ability of webpages to specify strings for the onbeforeunload dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 4 years, 9 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
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 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 DCHECK(dialog); 76 DCHECK(dialog);
77 self = [super init]; 77 self = [super init];
78 if (self) 78 if (self)
79 nativeDialog_ = dialog; 79 nativeDialog_ = dialog;
80 return self; 80 return self;
81 } 81 }
82 82
83 - (NSAlert*)alert { 83 - (NSAlert*)alert {
84 if (!alert_) { 84 if (!alert_) {
85 alert_.reset([[NSAlert alloc] init]); 85 alert_.reset([[NSAlert alloc] init]);
86 // Set a blank icon. 86 if (!nativeDialog_->dialog()->is_before_unload_dialog()) {
87 NSImage* image = 87 // Set a blank icon for dialogs with text provided by the page.
88 [[[NSImage alloc] initWithSize:NSMakeSize(1, 1)] autorelease]; 88 // "onbeforeunload" dialogs don't have text provided by the page, so it's
89 [alert_ setIcon:image]; 89 // OK to use the app icon.
90 NSImage* image =
91 [[[NSImage alloc] initWithSize:NSMakeSize(1, 1)] autorelease];
92 [alert_ setIcon:image];
93 }
90 } 94 }
91 return alert_; 95 return alert_;
92 } 96 }
93 97
94 - (void)addTextFieldWithPrompt:(NSString*)prompt { 98 - (void)addTextFieldWithPrompt:(NSString*)prompt {
95 DCHECK(!textField_); 99 DCHECK(!textField_);
96 textField_.reset( 100 textField_.reset(
97 [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 22)]); 101 [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 22)]);
98 [[textField_ cell] setLineBreakMode:NSLineBreakByTruncatingTail]; 102 [[textField_ cell] setLineBreakMode:NSLineBreakByTruncatingTail];
99 [[self alert] setAccessoryView:textField_]; 103 [[self alert] setAccessoryView:textField_];
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogCocoaFactory); 468 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogCocoaFactory);
465 }; 469 };
466 470
467 } // namespace 471 } // namespace
468 472
469 void InstallChromeJavaScriptNativeDialogFactory() { 473 void InstallChromeJavaScriptNativeDialogFactory() {
470 app_modal::JavaScriptDialogManager::GetInstance()-> 474 app_modal::JavaScriptDialogManager::GetInstance()->
471 SetNativeDialogFactory( 475 SetNativeDialogFactory(
472 make_scoped_ptr(new ChromeJavaScriptNativeDialogCocoaFactory)); 476 make_scoped_ptr(new ChromeJavaScriptNativeDialogCocoaFactory));
473 } 477 }
OLDNEW
« no previous file with comments | « android_webview/ui/grit_components_whitelist.txt ('k') | components/app_modal/javascript_dialog_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698