diff options
44 files changed, 86 insertions, 104 deletions
diff --git a/android_webview/DEPS b/android_webview/DEPS index cd20d21..609c15c 100644 --- a/android_webview/DEPS +++ b/android_webview/DEPS @@ -14,6 +14,7 @@ include_rules = [ "+content/public/common", "+crypto", "+gpu", + "+grit/components_strings.h", "+jni", "+net", "+skia", diff --git a/android_webview/browser/aw_contents_client_bridge_base.h b/android_webview/browser/aw_contents_client_bridge_base.h index 6ac592b..00598ba 100644 --- a/android_webview/browser/aw_contents_client_bridge_base.h +++ b/android_webview/browser/aw_contents_client_bridge_base.h @@ -59,7 +59,6 @@ class AwContentsClientBridgeBase { virtual void RunBeforeUnloadDialog( const GURL& origin_url, - const base::string16& message_text, const content::JavaScriptDialogManager::DialogClosedCallback& callback) = 0; diff --git a/android_webview/browser/aw_javascript_dialog_manager.cc b/android_webview/browser/aw_javascript_dialog_manager.cc index afe9bda..acc139e 100644 --- a/android_webview/browser/aw_javascript_dialog_manager.cc +++ b/android_webview/browser/aw_javascript_dialog_manager.cc @@ -39,7 +39,6 @@ void AwJavaScriptDialogManager::RunJavaScriptDialog( void AwJavaScriptDialogManager::RunBeforeUnloadDialog( content::WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) { AwContentsClientBridgeBase* bridge = @@ -50,7 +49,6 @@ void AwJavaScriptDialogManager::RunBeforeUnloadDialog( } bridge->RunBeforeUnloadDialog(web_contents->GetURL(), - message_text, callback); } diff --git a/android_webview/browser/aw_javascript_dialog_manager.h b/android_webview/browser/aw_javascript_dialog_manager.h index e5b3815..9d0bf4a 100644 --- a/android_webview/browser/aw_javascript_dialog_manager.h +++ b/android_webview/browser/aw_javascript_dialog_manager.h @@ -25,7 +25,6 @@ class AwJavaScriptDialogManager : public content::JavaScriptDialogManager { const DialogClosedCallback& callback, bool* did_suppress_message) override; void RunBeforeUnloadDialog(content::WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) override; void CancelActiveAndPendingDialogs( diff --git a/android_webview/native/BUILD.gn b/android_webview/native/BUILD.gn index 6e09894..94c4613 100644 --- a/android_webview/native/BUILD.gn +++ b/android_webview/native/BUILD.gn @@ -14,6 +14,7 @@ source_set("native") { "//cc:cc", "//components/autofill/content/browser:browser", "//components/devtools_http_handler:devtools_http_handler", + "//components/strings", "//components/web_contents_delegate_android:web_contents_delegate_android", "//content/public/common", "//device/battery:mojo_bindings", diff --git a/android_webview/native/aw_contents_client_bridge.cc b/android_webview/native/aw_contents_client_bridge.cc index 4d2fd4dcb..d5b3b44 100644 --- a/android_webview/native/aw_contents_client_bridge.cc +++ b/android_webview/native/aw_contents_client_bridge.cc @@ -17,12 +17,14 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "crypto/scoped_openssl_types.h" +#include "grit/components_strings.h" #include "jni/AwContentsClientBridge_jni.h" #include "net/android/keystore_openssl.h" #include "net/cert/x509_certificate.h" #include "net/ssl/openssl_client_key_store.h" #include "net/ssl/ssl_cert_request_info.h" #include "net/ssl/ssl_client_cert_type.h" +#include "ui/base/l10n/l10n_util.h" #include "url/gurl.h" using base::android::AttachCurrentThread; @@ -318,7 +320,6 @@ void AwContentsClientBridge::RunJavaScriptDialog( void AwContentsClientBridge::RunBeforeUnloadDialog( const GURL& origin_url, - const base::string16& message_text, const content::JavaScriptDialogManager::DialogClosedCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); JNIEnv* env = AttachCurrentThread(); @@ -329,6 +330,9 @@ void AwContentsClientBridge::RunBeforeUnloadDialog( return; } + const base::string16 message_text = + l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_MESSAGE); + int callback_id = pending_js_dialog_callbacks_.Add( new content::JavaScriptDialogManager::DialogClosedCallback(callback)); ScopedJavaLocalRef<jstring> jurl( diff --git a/android_webview/native/aw_contents_client_bridge.h b/android_webview/native/aw_contents_client_bridge.h index 2af63ca..d415dfa 100644 --- a/android_webview/native/aw_contents_client_bridge.h +++ b/android_webview/native/aw_contents_client_bridge.h @@ -51,7 +51,6 @@ class AwContentsClientBridge : public AwContentsClientBridgeBase { override; void RunBeforeUnloadDialog( const GURL& origin_url, - const base::string16& message_text, const content::JavaScriptDialogManager::DialogClosedCallback& callback) override; bool ShouldOverrideUrlLoading(const base::string16& url, diff --git a/android_webview/native/webview_native.gyp b/android_webview/native/webview_native.gyp index 0b57cae..14c371e 100644 --- a/android_webview/native/webview_native.gyp +++ b/android_webview/native/webview_native.gyp @@ -18,6 +18,7 @@ '../../components/components.gyp:autofill_content_browser', '../../components/components.gyp:devtools_http_handler', '../../components/components.gyp:web_contents_delegate_android', + '../../components/components_strings.gyp:components_strings', '../../content/content.gyp:content_common', '../../media/media.gyp:player_android', '../../net/net.gyp:net', diff --git a/android_webview/ui/grit_components_whitelist.txt b/android_webview/ui/grit_components_whitelist.txt index f1739e8..84238b6 100644 --- a/android_webview/ui/grit_components_whitelist.txt +++ b/android_webview/ui/grit_components_whitelist.txt @@ -1,3 +1,4 @@ IDS_POLICY_LIST_ENTRY_ERROR IDS_POLICY_SCHEMA_VALIDATION_ERROR IDS_POLICY_TYPE_ERROR +IDS_BEFOREUNLOAD_MESSAGEBOX_MESSAGE diff --git a/chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.mm b/chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.mm index 51f96a0..a9c7a83 100644 --- a/chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.mm +++ b/chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.mm @@ -83,10 +83,14 @@ const int kMessageTextMaxSlots = 2000; - (NSAlert*)alert { if (!alert_) { alert_.reset([[NSAlert alloc] init]); - // Set a blank icon. - NSImage* image = - [[[NSImage alloc] initWithSize:NSMakeSize(1, 1)] autorelease]; - [alert_ setIcon:image]; + if (!nativeDialog_->dialog()->is_before_unload_dialog()) { + // Set a blank icon for dialogs with text provided by the page. + // "onbeforeunload" dialogs don't have text provided by the page, so it's + // OK to use the app icon. + NSImage* image = + [[[NSImage alloc] initWithSize:NSMakeSize(1, 1)] autorelease]; + [alert_ setIcon:image]; + } } return alert_; } diff --git a/components/app_modal/javascript_dialog_manager.cc b/components/app_modal/javascript_dialog_manager.cc index ec47620..9bd127b 100644 --- a/components/app_modal/javascript_dialog_manager.cc +++ b/components/app_modal/javascript_dialog_manager.cc @@ -57,30 +57,15 @@ bool ShouldDisplaySuppressCheckbox( return extra_data->has_already_shown_a_dialog_; } -enum class DialogType { - JAVASCRIPT, - ON_BEFORE_UNLOAD, -}; - -void LogUMAMessageLengthStats(const base::string16& message, DialogType type) { - if (type == DialogType::JAVASCRIPT) { - UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfJSDialogMessageCharacters", - static_cast<int32_t>(message.length())); - } else { - UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfOnBeforeUnloadMessageCharacters", - static_cast<int32_t>(message.length())); - } +void LogUMAMessageLengthStats(const base::string16& message) { + UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfJSDialogMessageCharacters", + static_cast<int32_t>(message.length())); int32_t newline_count = std::count_if(message.begin(), message.end(), [](const base::char16& c) { return c == '\n'; }); - if (type == DialogType::JAVASCRIPT) { - UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfJSDialogMessageNewlines", - newline_count); - } else { - UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfOnBeforeUnloadMessageNewlines", - newline_count); - } + UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfJSDialogMessageNewlines", + newline_count); } } // namespace @@ -172,7 +157,7 @@ void JavaScriptDialogManager::RunJavaScriptDialog( extensions_client_->OnDialogOpened(web_contents); - LogUMAMessageLengthStats(message_text, DialogType::JAVASCRIPT); + LogUMAMessageLengthStats(message_text); AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( web_contents, &javascript_dialog_extra_data_, @@ -189,7 +174,6 @@ void JavaScriptDialogManager::RunJavaScriptDialog( void JavaScriptDialogManager::RunBeforeUnloadDialog( content::WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) { ChromeJavaScriptDialogExtraData* extra_data = @@ -202,23 +186,33 @@ void JavaScriptDialogManager::RunBeforeUnloadDialog( return; } + // Build the dialog message. We explicitly do _not_ allow the webpage to + // specify the contents of this dialog, because most of the time nowadays it's + // used for scams. + // + // This does not violate the spec. Per + // https://html.spec.whatwg.org/#prompt-to-unload-a-document, step 7: + // + // "The prompt shown by the user agent may include the string of the + // returnValue attribute, or some leading subset thereof." + // + // The prompt MAY include the string. It doesn't any more. Scam web page + // authors have abused this, so we're taking away the toys from everyone. This + // is why we can't have nice things. + const base::string16 title = l10n_util::GetStringUTF16(is_reload ? IDS_BEFORERELOAD_MESSAGEBOX_TITLE : IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE); - const base::string16 footer = l10n_util::GetStringUTF16(is_reload ? - IDS_BEFORERELOAD_MESSAGEBOX_FOOTER : IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); - - base::string16 full_message = - message_text + base::ASCIIToUTF16("\n\n") + footer; + const base::string16 message = + l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_MESSAGE); extensions_client_->OnDialogOpened(web_contents); - LogUMAMessageLengthStats(message_text, DialogType::ON_BEFORE_UNLOAD); AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( web_contents, &javascript_dialog_extra_data_, title, content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, - full_message, + message, base::string16(), // default_prompt_text ShouldDisplaySuppressCheckbox(extra_data), true, // is_before_unload_dialog diff --git a/components/app_modal/javascript_dialog_manager.h b/components/app_modal/javascript_dialog_manager.h index 22f2f79..66bfe7c 100644 --- a/components/app_modal/javascript_dialog_manager.h +++ b/components/app_modal/javascript_dialog_manager.h @@ -52,7 +52,6 @@ class JavaScriptDialogManager : public content::JavaScriptDialogManager { const DialogClosedCallback& callback, bool* did_suppress_message) override; void RunBeforeUnloadDialog(content::WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) override; bool HandleJavaScriptDialog(content::WebContents* web_contents, diff --git a/components/app_modal_strings.grdp b/components/app_modal_strings.grdp index 09cd5ff..ec4a2ac 100644 --- a/components/app_modal_strings.grdp +++ b/components/app_modal_strings.grdp @@ -20,30 +20,27 @@ <!-- "Before Unload" Dialog Box strings --> <message name="IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE" desc="Title for the 'before unload' dialog."> - Confirm Navigation + Do you want to leave this site? </message> - <message name="IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER" desc="Text shown at the bottom of the dialog, after the message provided by the script."> - Are you sure you want to leave this page? + <message name="IDS_BEFOREUNLOAD_MESSAGEBOX_MESSAGE" desc="Text shown as the message of the 'before unload' dialog."> + Changes you made may not be saved. </message> <message name="IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL" desc="The text on the button which navigates the user away from the page."> - Leave this Page + Leave </message> <message name="IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL" desc="The text on the button which cancels the navigation away from the page."> - Stay on this Page + Stay </message> <!-- "Before Reload" Dialog Box strings (same as "Before Unload" but when reloading rather than unloading the page --> - <message name="IDS_BEFORERELOAD_MESSAGEBOX_TITLE" desc="Title for the 'before reload' dialog."> - Confirm Reload - </message> - <message name="IDS_BEFORERELOAD_MESSAGEBOX_FOOTER" desc="Text shown at the bottom of the dialog, after the message provided by the script."> - Are you sure you want to reload this page? + <message name="IDS_BEFORERELOAD_MESSAGEBOX_TITLE" desc="Title for the 'before unload' dialog for reloads."> + Do you want to reload this site? </message> <message name="IDS_BEFORERELOAD_MESSAGEBOX_OK_BUTTON_LABEL" desc="The text on the button which reloads the page."> - Reload this Page + Reload </message> <message name="IDS_BEFORERELOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL" desc="The text on the button which cancels the page reload."> - Don't Reload + Don’t Reload </message> </grit-part> diff --git a/components/test_runner/web_frame_test_proxy.h b/components/test_runner/web_frame_test_proxy.h index 363f5e37..1cbe11f 100644 --- a/components/test_runner/web_frame_test_proxy.h +++ b/components/test_runner/web_frame_test_proxy.h @@ -167,10 +167,9 @@ class WebFrameTestProxy : public Base { return true; } - bool runModalBeforeUnloadDialog(bool is_reload, - const blink::WebString& message) override { + bool runModalBeforeUnloadDialog(bool is_reload) override { base_proxy_->GetDelegate()->PrintMessage( - std::string("CONFIRM NAVIGATION: ") + message.utf8().data() + "\n"); + std::string("CONFIRM NAVIGATION\n")); return !base_proxy_->GetInterfaces() ->TestRunner() ->ShouldStayOnPageAfterHandlingBeforeUnload(); diff --git a/content/browser/frame_host/render_frame_host_delegate.h b/content/browser/frame_host/render_frame_host_delegate.h index 355ee60..1ce4b78 100644 --- a/content/browser/frame_host/render_frame_host_delegate.h +++ b/content/browser/frame_host/render_frame_host_delegate.h @@ -81,7 +81,6 @@ class CONTENT_EXPORT RenderFrameHostDelegate { IPC::Message* reply_msg) {} virtual void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host, - const base::string16& message, bool is_reload, IPC::Message* reply_msg) {} diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index cb35604..10615f4 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc @@ -1441,14 +1441,13 @@ void RenderFrameHostImpl::OnRunJavaScriptMessage( void RenderFrameHostImpl::OnRunBeforeUnloadConfirm( const GURL& frame_url, - const base::string16& message, bool is_reload, IPC::Message* reply_msg) { // While a JS beforeunload dialog is showing, tabs in the same process // shouldn't process input events. GetProcess()->SetIgnoreInputEvents(true); render_view_host_->GetWidget()->StopHangMonitorTimeout(); - delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg); + delegate_->RunBeforeUnloadConfirm(this, is_reload, reply_msg); } void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h index b52ab74..35195ba 100644 --- a/content/browser/frame_host/render_frame_host_impl.h +++ b/content/browser/frame_host/render_frame_host_impl.h @@ -623,7 +623,6 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost, JavaScriptMessageType type, IPC::Message* reply_msg); void OnRunBeforeUnloadConfirm(const GURL& frame_url, - const base::string16& message, bool is_reload, IPC::Message* reply_msg); void OnTextSurroundingSelectionResponse(const base::string16& content, diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc index b09d945..f66c758 100644 --- a/content/browser/frame_host/render_frame_host_manager_unittest.cc +++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc @@ -669,16 +669,16 @@ TEST_F(RenderFrameHostManagerTest, FilterMessagesWhileSwappedOut) { // without showing an actual dialog. MockRenderProcessHost* ntp_process_host = ntp_rfh->GetProcess(); ntp_process_host->sink().ClearMessages(); - const base::string16 msg = base::ASCIIToUTF16("Message"); bool result = false; base::string16 unused; FrameHostMsg_RunBeforeUnloadConfirm before_unload_msg( - ntp_rfh->GetRoutingID(), kChromeURL, msg, false, &result, &unused); + ntp_rfh->GetRoutingID(), kChromeURL, false, &result, &unused); EXPECT_TRUE(ntp_rfh->OnMessageReceived(before_unload_msg)); EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); // Also test RunJavaScriptMessage. ntp_process_host->sink().ClearMessages(); + const base::string16 msg = base::ASCIIToUTF16("Message"); FrameHostMsg_RunJavaScriptMessage js_msg( ntp_rfh->GetRoutingID(), msg, msg, kChromeURL, JAVASCRIPT_MESSAGE_TYPE_CONFIRM, &result, &unused); diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 1f2b90d..feed3fe 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -3882,7 +3882,6 @@ void WebContentsImpl::RunJavaScriptMessage( void WebContentsImpl::RunBeforeUnloadConfirm( RenderFrameHost* render_frame_host, - const base::string16& message, bool is_reload, IPC::Message* reply_msg) { RenderFrameHostImpl* rfhi = @@ -3903,7 +3902,7 @@ void WebContentsImpl::RunBeforeUnloadConfirm( is_showing_before_unload_dialog_ = true; dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); dialog_manager_->RunBeforeUnloadDialog( - this, message, is_reload, + this, is_reload, base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), render_frame_host->GetProcess()->GetID(), render_frame_host->GetRoutingID(), reply_msg, diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 0624277..9907baa 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -419,7 +419,6 @@ class CONTENT_EXPORT WebContentsImpl JavaScriptMessageType type, IPC::Message* reply_msg) override; void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host, - const base::string16& message, bool is_reload, IPC::Message* reply_msg) override; void DidAccessInitialDocument() override; diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc index e95c853..a96c322 100644 --- a/content/browser/web_contents/web_contents_impl_unittest.cc +++ b/content/browser/web_contents/web_contents_impl_unittest.cc @@ -3408,7 +3408,6 @@ class TestJavaScriptDialogManager : public JavaScriptDialogManager { }; void RunBeforeUnloadDialog(WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) override {} diff --git a/content/common/frame_messages.h b/content/common/frame_messages.h index ec76ea6..69c2246 100644 --- a/content/common/frame_messages.h +++ b/content/common/frame_messages.h @@ -1256,9 +1256,8 @@ IPC_SYNC_MESSAGE_ROUTED4_2(FrameHostMsg_RunJavaScriptMessage, // Displays a dialog to confirm that the user wants to navigate away from the // page. Replies true if yes, and false otherwise. The reply string is ignored, // but is included so that we can use OnJavaScriptMessageBoxClosed. -IPC_SYNC_MESSAGE_ROUTED3_2(FrameHostMsg_RunBeforeUnloadConfirm, +IPC_SYNC_MESSAGE_ROUTED2_2(FrameHostMsg_RunBeforeUnloadConfirm, GURL, /* in - originating frame URL */ - base::string16 /* in - alert message */, bool /* in - is a reload */, bool /* out - success */, base::string16 /* out - This is ignored.*/) diff --git a/content/public/browser/javascript_dialog_manager.h b/content/public/browser/javascript_dialog_manager.h index 114418c..2342543 100644 --- a/content/public/browser/javascript_dialog_manager.h +++ b/content/public/browser/javascript_dialog_manager.h @@ -40,7 +40,6 @@ class CONTENT_EXPORT JavaScriptDialogManager { // Displays a dialog asking the user if they want to leave a page. virtual void RunBeforeUnloadDialog(WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) = 0; diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 69c7e94..5ea20a2 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -3627,9 +3627,7 @@ bool RenderFrameImpl::runModalPromptDialog( return ok; } -bool RenderFrameImpl::runModalBeforeUnloadDialog( - bool is_reload, - const blink::WebString& message) { +bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { // If we are swapping out, we have already run the beforeunload handler. // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload // at all, to avoid running it twice. @@ -3647,7 +3645,7 @@ bool RenderFrameImpl::runModalBeforeUnloadDialog( base::string16 ignored_result; render_view()->SendAndRunNestedMessageLoop( new FrameHostMsg_RunBeforeUnloadConfirm( - routing_id_, frame_->document().url(), message, is_reload, + routing_id_, frame_->document().url(), is_reload, &success, &ignored_result)); return success; } diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index f57b159..0d7a3fa 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -522,8 +522,7 @@ class CONTENT_EXPORT RenderFrameImpl bool runModalPromptDialog(const blink::WebString& message, const blink::WebString& default_value, blink::WebString* actual_value) override; - bool runModalBeforeUnloadDialog(bool is_reload, - const blink::WebString& message) override; + bool runModalBeforeUnloadDialog(bool is_reload) override; void showContextMenu(const blink::WebContextMenuData& data) override; void clearContextMenu() override; void willSendRequest(blink::WebLocalFrame* frame, diff --git a/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.cc b/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.cc index 969b680..adea594 100644 --- a/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.cc +++ b/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.cc @@ -35,7 +35,6 @@ void LayoutTestJavaScriptDialogManager::RunJavaScriptDialog( void LayoutTestJavaScriptDialogManager::RunBeforeUnloadDialog( WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) { callback.Run(true, base::string16()); diff --git a/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h b/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h index 04ab714..726bdd2 100644 --- a/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h +++ b/content/shell/browser/layout_test/layout_test_javascript_dialog_manager.h @@ -29,7 +29,6 @@ class LayoutTestJavaScriptDialogManager : public ShellJavaScriptDialogManager { bool* did_suppress_message) override; void RunBeforeUnloadDialog(WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) override; diff --git a/content/shell/browser/shell_javascript_dialog_manager.cc b/content/shell/browser/shell_javascript_dialog_manager.cc index a312e8d..fdd5725 100644 --- a/content/shell/browser/shell_javascript_dialog_manager.cc +++ b/content/shell/browser/shell_javascript_dialog_manager.cc @@ -66,7 +66,6 @@ void ShellJavaScriptDialogManager::RunJavaScriptDialog( void ShellJavaScriptDialogManager::RunBeforeUnloadDialog( WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) { if (!dialog_request_callback_.is_null()) { @@ -83,16 +82,15 @@ void ShellJavaScriptDialogManager::RunBeforeUnloadDialog( return; } - base::string16 new_message_text = - message_text + - base::ASCIIToUTF16("\n\nIs it OK to leave/reload this page?"); + base::string16 message_text = + base::ASCIIToUTF16("Is it OK to leave/reload this page?"); gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow(); dialog_.reset(new ShellJavaScriptDialog(this, parent_window, JAVASCRIPT_MESSAGE_TYPE_CONFIRM, - new_message_text, + message_text, base::string16(), // default callback)); #else diff --git a/content/shell/browser/shell_javascript_dialog_manager.h b/content/shell/browser/shell_javascript_dialog_manager.h index a7c29fb..4231104 100644 --- a/content/shell/browser/shell_javascript_dialog_manager.h +++ b/content/shell/browser/shell_javascript_dialog_manager.h @@ -32,7 +32,6 @@ class ShellJavaScriptDialogManager : public JavaScriptDialogManager { bool* did_suppress_message) override; void RunBeforeUnloadDialog(WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) override; diff --git a/extensions/browser/guest_view/web_view/javascript_dialog_helper.cc b/extensions/browser/guest_view/web_view/javascript_dialog_helper.cc index 1ac3c848..83f69d9 100644 --- a/extensions/browser/guest_view/web_view/javascript_dialog_helper.cc +++ b/extensions/browser/guest_view/web_view/javascript_dialog_helper.cc @@ -72,7 +72,6 @@ void JavaScriptDialogHelper::RunJavaScriptDialog( void JavaScriptDialogHelper::RunBeforeUnloadDialog( content::WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) { // This is called if the guest has a beforeunload event handler. diff --git a/extensions/browser/guest_view/web_view/javascript_dialog_helper.h b/extensions/browser/guest_view/web_view/javascript_dialog_helper.h index 804a206..1d40fb2 100644 --- a/extensions/browser/guest_view/web_view/javascript_dialog_helper.h +++ b/extensions/browser/guest_view/web_view/javascript_dialog_helper.h @@ -28,7 +28,6 @@ class JavaScriptDialogHelper : public content::JavaScriptDialogManager { const DialogClosedCallback& callback, bool* did_suppress_message) override; void RunBeforeUnloadDialog(content::WebContents* web_contents, - const base::string16& message_text, bool is_reload, const DialogClosedCallback& callback) override; bool HandleJavaScriptDialog(content::WebContents* web_contents, diff --git a/third_party/WebKit/LayoutTests/fast/events/before-unload-reloads-expected.txt b/third_party/WebKit/LayoutTests/fast/events/before-unload-reloads-expected.txt index 41933ec3c..6a1b4a8 100644 --- a/third_party/WebKit/LayoutTests/fast/events/before-unload-reloads-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/events/before-unload-reloads-expected.txt @@ -1,3 +1,3 @@ -CONFIRM NAVIGATION: +CONFIRM NAVIGATION This test passes if the FAIL changes to PASS after clicking "Stay on this page". PASS diff --git a/third_party/WebKit/LayoutTests/fast/events/before-unload-returnValue-expected.txt b/third_party/WebKit/LayoutTests/fast/events/before-unload-returnValue-expected.txt index 46b00e6..6aaad7a 100644 --- a/third_party/WebKit/LayoutTests/fast/events/before-unload-returnValue-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/events/before-unload-returnValue-expected.txt @@ -1,4 +1,4 @@ -CONFIRM NAVIGATION: This is beforeunload from the top level frame. +CONFIRM NAVIGATION Tests the returnValue attribute of the BeforeUnloadEvent. On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". diff --git a/third_party/WebKit/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt b/third_party/WebKit/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt index 7ce1153..823a068 100644 --- a/third_party/WebKit/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel-expected.txt @@ -1,3 +1,3 @@ -CONFIRM NAVIGATION: Click 'Stay on Page' -CONFIRM NAVIGATION: Click 'Leave Page' +CONFIRM NAVIGATION +CONFIRM NAVIGATION PASS diff --git a/third_party/WebKit/LayoutTests/fast/loader/show-only-one-beforeunload-dialog-expected.txt b/third_party/WebKit/LayoutTests/fast/loader/show-only-one-beforeunload-dialog-expected.txt index f2bf112..d1c57c7 100644 --- a/third_party/WebKit/LayoutTests/fast/loader/show-only-one-beforeunload-dialog-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/loader/show-only-one-beforeunload-dialog-expected.txt @@ -1,4 +1,4 @@ -CONFIRM NAVIGATION: This is beforeunload from the top level frame. +CONFIRM NAVIGATION CONSOLE ERROR: Blocked attempt to show multiple 'beforeunload' confirmation panels for a single navigation. CONSOLE ERROR: Blocked attempt to show multiple 'beforeunload' confirmation panels for a single navigation. diff --git a/third_party/WebKit/LayoutTests/http/tests/misc/reentrant-beforeunload-expected.txt b/third_party/WebKit/LayoutTests/http/tests/misc/reentrant-beforeunload-expected.txt index cdde7b4..c4388bc 100644 --- a/third_party/WebKit/LayoutTests/http/tests/misc/reentrant-beforeunload-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/misc/reentrant-beforeunload-expected.txt @@ -1,2 +1,2 @@ -CONFIRM NAVIGATION: This should only appear once. +CONFIRM NAVIGATION diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents-expected.txt index 46a17a6..baa38fa 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents-expected.txt @@ -1,4 +1,4 @@ -CONFIRM NAVIGATION: beforeunload in javascriptDialogEvents +CONFIRM NAVIGATION ALERT: alert CONFIRM: confirm PROMPT: prompt, default text: diff --git a/third_party/WebKit/Source/core/loader/EmptyClients.h b/third_party/WebKit/Source/core/loader/EmptyClients.h index 23d0d3b..5b9c4ff 100644 --- a/third_party/WebKit/Source/core/loader/EmptyClients.h +++ b/third_party/WebKit/Source/core/loader/EmptyClients.h @@ -111,7 +111,7 @@ public: void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const String&, unsigned, const String&, const String&) override {} bool canOpenBeforeUnloadConfirmPanel() override { return false; } - bool openBeforeUnloadConfirmPanelDelegate(LocalFrame*, const String&, bool) override { return true; } + bool openBeforeUnloadConfirmPanelDelegate(LocalFrame*, bool) override { return true; } void closeWindowSoon() override {} diff --git a/third_party/WebKit/Source/core/page/ChromeClient.cpp b/third_party/WebKit/Source/core/page/ChromeClient.cpp index 24c6fbd..fc73d76 100644 --- a/third_party/WebKit/Source/core/page/ChromeClient.cpp +++ b/third_party/WebKit/Source/core/page/ChromeClient.cpp @@ -93,8 +93,8 @@ static bool openJavaScriptDialog(LocalFrame* frame, const String& message, Chrom bool ChromeClient::openBeforeUnloadConfirmPanel(const String& message, LocalFrame* frame, bool isReload) { ASSERT(frame); - return openJavaScriptDialog(frame, message, ChromeClient::HTMLDialog, [this, frame, &message, isReload]() { - return openBeforeUnloadConfirmPanelDelegate(frame, message, isReload); + return openJavaScriptDialog(frame, message, ChromeClient::HTMLDialog, [this, frame, isReload]() { + return openBeforeUnloadConfirmPanelDelegate(frame, isReload); }); } diff --git a/third_party/WebKit/Source/core/page/ChromeClient.h b/third_party/WebKit/Source/core/page/ChromeClient.h index 1157ae3..ca79590 100644 --- a/third_party/WebKit/Source/core/page/ChromeClient.h +++ b/third_party/WebKit/Source/core/page/ChromeClient.h @@ -269,7 +269,7 @@ protected: virtual void showMouseOverURL(const HitTestResult&) = 0; virtual void setWindowRect(const IntRect&) = 0; - virtual bool openBeforeUnloadConfirmPanelDelegate(LocalFrame*, const String& message, bool isReload) = 0; + virtual bool openBeforeUnloadConfirmPanelDelegate(LocalFrame*, bool isReload) = 0; virtual bool openJavaScriptAlertDelegate(LocalFrame*, const String&) = 0; virtual bool openJavaScriptConfirmDelegate(LocalFrame*, const String&) = 0; virtual bool openJavaScriptPromptDelegate(LocalFrame*, const String& message, const String& defaultValue, String& result) = 0; diff --git a/third_party/WebKit/Source/web/ChromeClientImpl.cpp b/third_party/WebKit/Source/web/ChromeClientImpl.cpp index 60b805e..2cf2cbf 100644 --- a/third_party/WebKit/Source/web/ChromeClientImpl.cpp +++ b/third_party/WebKit/Source/web/ChromeClientImpl.cpp @@ -399,11 +399,11 @@ bool ChromeClientImpl::canOpenBeforeUnloadConfirmPanel() return !!m_webView->client(); } -bool ChromeClientImpl::openBeforeUnloadConfirmPanelDelegate(LocalFrame* frame, const String& message, bool isReload) +bool ChromeClientImpl::openBeforeUnloadConfirmPanelDelegate(LocalFrame* frame, bool isReload) { notifyPopupOpeningObservers(); WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); - return webframe->client() && webframe->client()->runModalBeforeUnloadDialog(isReload, message); + return webframe->client() && webframe->client()->runModalBeforeUnloadDialog(isReload); } void ChromeClientImpl::closeWindowSoon() diff --git a/third_party/WebKit/Source/web/ChromeClientImpl.h b/third_party/WebKit/Source/web/ChromeClientImpl.h index 5483e30..14b318e 100644 --- a/third_party/WebKit/Source/web/ChromeClientImpl.h +++ b/third_party/WebKit/Source/web/ChromeClientImpl.h @@ -82,7 +82,7 @@ public: const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace) override; bool canOpenBeforeUnloadConfirmPanel() override; - bool openBeforeUnloadConfirmPanelDelegate(LocalFrame*, const String&, bool isReload) override; + bool openBeforeUnloadConfirmPanelDelegate(LocalFrame*, bool isReload) override; void closeWindowSoon() override; bool openJavaScriptAlertDelegate(LocalFrame*, const String&) override; bool openJavaScriptConfirmDelegate(LocalFrame*, const String&) override; diff --git a/third_party/WebKit/public/web/WebFrameClient.h b/third_party/WebKit/public/web/WebFrameClient.h index 0493b746..4741cd8 100644 --- a/third_party/WebKit/public/web/WebFrameClient.h +++ b/third_party/WebKit/public/web/WebFrameClient.h @@ -400,12 +400,10 @@ public: const WebString& message, const WebString& defaultValue, WebString* actualValue) { return false; } - // Displays a modal confirmation dialog containing the given message as - // description and OK/Cancel choices, where 'OK' means that it is okay - // to proceed with closing the view. Returns true if the user selects - // 'OK' or false otherwise. - virtual bool runModalBeforeUnloadDialog( - bool isReload, const WebString& message) { return true; } + // Displays a modal confirmation dialog with OK/Cancel choices, where 'OK' + // means that it is okay to proceed with closing the view. Returns true if + // the user selects 'OK' or false otherwise. + virtual bool runModalBeforeUnloadDialog(bool isReload) { return true; } // UI ------------------------------------------------------------------ diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 444a189..4540b38 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -18134,6 +18134,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. </histogram> <histogram name="JSDialogs.CountOfOnBeforeUnloadMessageCharacters"> + <obsolete> + Deprecated 2016-02. + </obsolete> <owner>avi@chromium.org</owner> <summary> The count of the number of characters in onbeforeunload messages. @@ -18141,6 +18144,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. </histogram> <histogram name="JSDialogs.CountOfOnBeforeUnloadMessageNewlines"> + <obsolete> + Deprecated 2016-02. + </obsolete> <owner>avi@chromium.org</owner> <summary> The count of the number of newlines in onbeforeunload messages. (This does |