OLD | NEW |
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 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2418 const std::string& target) { | 2418 const std::string& target) { |
2419 if (delegate()) | 2419 if (delegate()) |
2420 delegate()->ForwardMessageToExternalHost(message, origin, target); | 2420 delegate()->ForwardMessageToExternalHost(message, origin, target); |
2421 } | 2421 } |
2422 | 2422 |
2423 void TabContents::RunJavaScriptMessage( | 2423 void TabContents::RunJavaScriptMessage( |
2424 const std::wstring& message, | 2424 const std::wstring& message, |
2425 const std::wstring& default_prompt, | 2425 const std::wstring& default_prompt, |
2426 const GURL& frame_url, | 2426 const GURL& frame_url, |
2427 const int flags, | 2427 const int flags, |
| 2428 const bool unload_handler_being_run, |
2428 IPC::Message* reply_msg, | 2429 IPC::Message* reply_msg, |
2429 bool* did_suppress_message) { | 2430 bool* did_suppress_message) { |
2430 // Suppress javascript messages when requested and when inside a constrained | 2431 // Suppress javascript messages when requested and when inside a constrained |
2431 // popup window (because that activates them and breaks them out of the | 2432 // popup window (because that activates them and breaks them out of the |
2432 // constrained window jail). | 2433 // constrained window jail). |
2433 // Also suppress messages when showing an interstitial. The interstitial is | 2434 // Also suppress messages when showing an interstitial. The interstitial is |
2434 // shown over the previous page, we don't want the hidden page dialogs to | 2435 // shown over the previous page, we don't want the hidden page dialogs to |
2435 // interfere with the interstitial. | 2436 // interfere with the interstitial. |
| 2437 // Also suppress messages during beforeunload/unload event handlers. |
2436 bool suppress_this_message = | 2438 bool suppress_this_message = |
2437 suppress_javascript_messages_ || | 2439 suppress_javascript_messages_ || |
2438 showing_interstitial_page() || | 2440 showing_interstitial_page() || |
| 2441 unload_handler_being_run || |
2439 (delegate() && delegate()->ShouldSuppressDialogs()); | 2442 (delegate() && delegate()->ShouldSuppressDialogs()); |
2440 if (delegate()) | 2443 if (delegate()) |
2441 suppress_this_message |= | 2444 suppress_this_message |= |
2442 (delegate()->GetConstrainingContents(this) != this); | 2445 (delegate()->GetConstrainingContents(this) != this); |
2443 | 2446 |
2444 *did_suppress_message = suppress_this_message; | 2447 *did_suppress_message = suppress_this_message; |
2445 | 2448 |
2446 if (!suppress_this_message) { | 2449 if (!suppress_this_message) { |
2447 base::TimeDelta time_since_last_message( | 2450 base::TimeDelta time_since_last_message( |
2448 base::TimeTicks::Now() - last_javascript_message_dismissal_); | 2451 base::TimeTicks::Now() - last_javascript_message_dismissal_); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2854 } | 2857 } |
2855 | 2858 |
2856 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { | 2859 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { |
2857 prerender::PrerenderManager* pm = profile()->GetPrerenderManager(); | 2860 prerender::PrerenderManager* pm = profile()->GetPrerenderManager(); |
2858 if (pm != NULL) { | 2861 if (pm != NULL) { |
2859 if (pm->MaybeUsePreloadedPage(this, url)) | 2862 if (pm->MaybeUsePreloadedPage(this, url)) |
2860 return true; | 2863 return true; |
2861 } | 2864 } |
2862 return false; | 2865 return false; |
2863 } | 2866 } |
OLD | NEW |