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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 6627063: Ignore JavaScript messages (alert/confirm/prompt) during unload handlers. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_view.h ('k') | content/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/renderer/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 dom_automation_controller_->set_message_sender(this); 1937 dom_automation_controller_->set_message_sender(this);
1938 dom_automation_controller_->set_routing_id(routing_id_); 1938 dom_automation_controller_->set_routing_id(routing_id_);
1939 dom_automation_controller_->BindToJavascript(frame, 1939 dom_automation_controller_->BindToJavascript(frame,
1940 "domAutomationController"); 1940 "domAutomationController");
1941 } 1941 }
1942 1942
1943 bool RenderView::RunJavaScriptMessage(int type, 1943 bool RenderView::RunJavaScriptMessage(int type,
1944 const std::wstring& message, 1944 const std::wstring& message,
1945 const std::wstring& default_value, 1945 const std::wstring& default_value,
1946 const GURL& frame_url, 1946 const GURL& frame_url,
1947 const bool unload_handler_being_run,
1947 std::wstring* result) { 1948 std::wstring* result) {
1948 bool success = false; 1949 bool success = false;
1949 std::wstring result_temp; 1950 std::wstring result_temp;
1950 if (!result) 1951 if (!result)
1951 result = &result_temp; 1952 result = &result_temp;
1952 1953
1953 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( 1954 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage(
1954 routing_id_, message, default_value, frame_url, type, &success, result)); 1955 routing_id_, message, default_value, frame_url, type,
1956 unload_handler_being_run, &success, result));
1955 return success; 1957 return success;
1956 } 1958 }
1957 1959
1958 bool RenderView::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { 1960 bool RenderView::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) {
1959 // Before WebKit asks us to show an alert (etc.), it takes care of doing the 1961 // Before WebKit asks us to show an alert (etc.), it takes care of doing the
1960 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog 1962 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog
1961 // it is particularly important that we do not call willEnterModalLoop as 1963 // it is particularly important that we do not call willEnterModalLoop as
1962 // that would defer resource loads for the dialog itself. 1964 // that would defer resource loads for the dialog itself.
1963 if (RenderThread::current()) // Will be NULL during unit tests. 1965 if (RenderThread::current()) // Will be NULL during unit tests.
1964 RenderThread::current()->DoNotNotifyWebKitOfModalLoop(); 1966 RenderThread::current()->DoNotNotifyWebKitOfModalLoop();
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 2397
2396 return ScheduleFileChooser(ipc_params, chooser_completion); 2398 return ScheduleFileChooser(ipc_params, chooser_completion);
2397 } 2399 }
2398 2400
2399 void RenderView::runModalAlertDialog( 2401 void RenderView::runModalAlertDialog(
2400 WebFrame* frame, const WebString& message) { 2402 WebFrame* frame, const WebString& message) {
2401 RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptAlert, 2403 RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptAlert,
2402 UTF16ToWideHack(message), 2404 UTF16ToWideHack(message),
2403 std::wstring(), 2405 std::wstring(),
2404 frame->url(), 2406 frame->url(),
2407 frame->pageDismissalEventBeingDispatched(),
Charlie Reis 2011/03/08 02:31:56 It seems strange to me to thread a new parameter a
2405 NULL); 2408 NULL);
2406 } 2409 }
2407 2410
2408 bool RenderView::runModalConfirmDialog( 2411 bool RenderView::runModalConfirmDialog(
2409 WebFrame* frame, const WebString& message) { 2412 WebFrame* frame, const WebString& message) {
2410 return RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptConfirm, 2413 return RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptConfirm,
2411 UTF16ToWideHack(message), 2414 UTF16ToWideHack(message),
2412 std::wstring(), 2415 std::wstring(),
2413 frame->url(), 2416 frame->url(),
2417 frame->pageDismissalEventBeingDispatched(),
2414 NULL); 2418 NULL);
2415 } 2419 }
2416 2420
2417 bool RenderView::runModalPromptDialog( 2421 bool RenderView::runModalPromptDialog(
2418 WebFrame* frame, const WebString& message, const WebString& default_value, 2422 WebFrame* frame, const WebString& message, const WebString& default_value,
2419 WebString* actual_value) { 2423 WebString* actual_value) {
2420 std::wstring result; 2424 std::wstring result;
2421 bool ok = RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptPrompt, 2425 bool ok = RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptPrompt,
2422 UTF16ToWideHack(message), 2426 UTF16ToWideHack(message),
2423 UTF16ToWideHack(default_value), 2427 UTF16ToWideHack(default_value),
2424 frame->url(), 2428 frame->url(),
2429 frame->pageDismissalEventBeingDispatched(),
2425 &result); 2430 &result);
2426 if (ok) 2431 if (ok)
2427 actual_value->assign(WideToUTF16Hack(result)); 2432 actual_value->assign(WideToUTF16Hack(result));
2428 return ok; 2433 return ok;
2429 } 2434 }
2430 2435
2431 bool RenderView::runModalBeforeUnloadDialog( 2436 bool RenderView::runModalBeforeUnloadDialog(
2432 WebFrame* frame, const WebString& message) { 2437 WebFrame* frame, const WebString& message) {
2433 bool success = false; 2438 bool success = false;
2434 // This is an ignored return value, but is included so we can accept the same 2439 // This is an ignored return value, but is included so we can accept the same
(...skipping 3276 matching lines...) Expand 10 before | Expand all | Expand 10 after
5711 const webkit_glue::CustomContextMenuContext& custom_context) { 5716 const webkit_glue::CustomContextMenuContext& custom_context) {
5712 if (custom_context.is_pepper_menu) 5717 if (custom_context.is_pepper_menu)
5713 pepper_delegate_.OnContextMenuClosed(custom_context); 5718 pepper_delegate_.OnContextMenuClosed(custom_context);
5714 else 5719 else
5715 context_menu_node_.reset(); 5720 context_menu_node_.reset();
5716 } 5721 }
5717 5722
5718 void RenderView::OnNetworkStateChanged(bool online) { 5723 void RenderView::OnNetworkStateChanged(bool online) {
5719 WebNetworkStateNotifier::setOnLine(online); 5724 WebNetworkStateNotifier::setOnLine(online);
5720 } 5725 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.h ('k') | content/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698