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

Side by Side Diff: content/browser/tab_contents/tab_contents.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: Added a browsertest 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 | « content/browser/tab_contents/tab_contents.h ('k') | no next file » | 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 "content/browser/tab_contents/tab_contents.h" 5 #include "content/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 const std::string& target) { 2399 const std::string& target) {
2400 if (delegate()) 2400 if (delegate())
2401 delegate()->ForwardMessageToExternalHost(message, origin, target); 2401 delegate()->ForwardMessageToExternalHost(message, origin, target);
2402 } 2402 }
2403 2403
2404 void TabContents::RunJavaScriptMessage( 2404 void TabContents::RunJavaScriptMessage(
2405 const std::wstring& message, 2405 const std::wstring& message,
2406 const std::wstring& default_prompt, 2406 const std::wstring& default_prompt,
2407 const GURL& frame_url, 2407 const GURL& frame_url,
2408 const int flags, 2408 const int flags,
2409 const bool unload_handler_being_run,
2409 IPC::Message* reply_msg, 2410 IPC::Message* reply_msg,
2410 bool* did_suppress_message) { 2411 bool* did_suppress_message) {
2411 // Suppress javascript messages when requested and when inside a constrained 2412 // Suppress javascript messages when requested and when inside a constrained
2412 // popup window (because that activates them and breaks them out of the 2413 // popup window (because that activates them and breaks them out of the
2413 // constrained window jail). 2414 // constrained window jail).
2414 // Also suppress messages when showing an interstitial. The interstitial is 2415 // Also suppress messages when showing an interstitial. The interstitial is
2415 // shown over the previous page, we don't want the hidden page dialogs to 2416 // shown over the previous page, we don't want the hidden page dialogs to
2416 // interfere with the interstitial. 2417 // interfere with the interstitial.
2418 // Also suppress messages during beforeunload/unload event handlers.
2417 bool suppress_this_message = 2419 bool suppress_this_message =
2418 suppress_javascript_messages_ || 2420 suppress_javascript_messages_ ||
2419 showing_interstitial_page() || 2421 showing_interstitial_page() ||
2422 unload_handler_being_run ||
2420 (delegate() && delegate()->ShouldSuppressDialogs()); 2423 (delegate() && delegate()->ShouldSuppressDialogs());
2421 if (delegate()) 2424 if (delegate())
2422 suppress_this_message |= 2425 suppress_this_message |=
2423 (delegate()->GetConstrainingContents(this) != this); 2426 (delegate()->GetConstrainingContents(this) != this);
2424 2427
2425 *did_suppress_message = suppress_this_message; 2428 *did_suppress_message = suppress_this_message;
2426 2429
2427 if (!suppress_this_message) { 2430 if (!suppress_this_message) {
2428 base::TimeDelta time_since_last_message( 2431 base::TimeDelta time_since_last_message(
2429 base::TimeTicks::Now() - last_javascript_message_dismissal_); 2432 base::TimeTicks::Now() - last_javascript_message_dismissal_);
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2817 2820
2818 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2821 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2819 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 2822 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
2820 rwh_view->SetSize(view()->GetContainerSize()); 2823 rwh_view->SetSize(view()->GetContainerSize());
2821 } 2824 }
2822 2825
2823 void TabContents::OnOnlineStateChanged(bool online) { 2826 void TabContents::OnOnlineStateChanged(bool online) {
2824 render_view_host()->Send(new ViewMsg_NetworkStateChanged( 2827 render_view_host()->Send(new ViewMsg_NetworkStateChanged(
2825 render_view_host()->routing_id(), online)); 2828 render_view_host()->routing_id(), online));
2826 } 2829 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698