| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 void TabContents::HideContents() { | 834 void TabContents::HideContents() { |
| 835 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call | 835 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call |
| 836 // our superclass HideContents(), because some callers want to be very picky | 836 // our superclass HideContents(), because some callers want to be very picky |
| 837 // about the order in which these get called. In addition to making the code | 837 // about the order in which these get called. In addition to making the code |
| 838 // here practically impossible to understand, this also means we end up | 838 // here practically impossible to understand, this also means we end up |
| 839 // calling TabContents::WasHidden() twice if callers call both versions of | 839 // calling TabContents::WasHidden() twice if callers call both versions of |
| 840 // HideContents() on a TabContents. | 840 // HideContents() on a TabContents. |
| 841 WasHidden(); | 841 WasHidden(); |
| 842 } | 842 } |
| 843 | 843 |
| 844 bool TabContents::NeedToFireBeforeUnload() { |
| 845 return notify_disconnection() && |
| 846 !showing_interstitial_page() && |
| 847 !render_view_host()->SuddenTerminationAllowed(); |
| 848 } |
| 849 |
| 844 void TabContents::OpenURL(const GURL& url, const GURL& referrer, | 850 void TabContents::OpenURL(const GURL& url, const GURL& referrer, |
| 845 WindowOpenDisposition disposition, | 851 WindowOpenDisposition disposition, |
| 846 PageTransition::Type transition) { | 852 PageTransition::Type transition) { |
| 847 if (delegate_) | 853 if (delegate_) |
| 848 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); | 854 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); |
| 849 } | 855 } |
| 850 | 856 |
| 851 bool TabContents::NavigateToPendingEntry( | 857 bool TabContents::NavigateToPendingEntry( |
| 852 NavigationController::ReloadType reload_type) { | 858 NavigationController::ReloadType reload_type) { |
| 853 return NavigateToEntry(*controller_.pending_entry(), reload_type); | 859 return NavigateToEntry(*controller_.pending_entry(), reload_type); |
| (...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2788 default_prompt, show_suppress_checkbox, reply_msg); | 2794 default_prompt, show_suppress_checkbox, reply_msg); |
| 2789 } else { | 2795 } else { |
| 2790 // If we are suppressing messages, just reply as is if the user immediately | 2796 // If we are suppressing messages, just reply as is if the user immediately |
| 2791 // pressed "Cancel". | 2797 // pressed "Cancel". |
| 2792 OnMessageBoxClosed(reply_msg, false, std::wstring()); | 2798 OnMessageBoxClosed(reply_msg, false, std::wstring()); |
| 2793 } | 2799 } |
| 2794 } | 2800 } |
| 2795 | 2801 |
| 2796 void TabContents::RunBeforeUnloadConfirm(const std::wstring& message, | 2802 void TabContents::RunBeforeUnloadConfirm(const std::wstring& message, |
| 2797 IPC::Message* reply_msg) { | 2803 IPC::Message* reply_msg) { |
| 2804 if (delegate()) |
| 2805 delegate()->WillRunBeforeUnloadConfirm(); |
| 2798 if (delegate() && delegate()->ShouldSuppressDialogs()) { | 2806 if (delegate() && delegate()->ShouldSuppressDialogs()) { |
| 2799 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, | 2807 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, |
| 2800 std::wstring()); | 2808 std::wstring()); |
| 2801 return; | 2809 return; |
| 2802 } | 2810 } |
| 2803 is_showing_before_unload_dialog_ = true; | 2811 is_showing_before_unload_dialog_ = true; |
| 2804 RunBeforeUnloadDialog(this, message, reply_msg); | 2812 RunBeforeUnloadDialog(this, message, reply_msg); |
| 2805 } | 2813 } |
| 2806 | 2814 |
| 2807 void TabContents::ShowModalHTMLDialog(const GURL& url, int width, int height, | 2815 void TabContents::ShowModalHTMLDialog(const GURL& url, int width, int height, |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3253 } | 3261 } |
| 3254 | 3262 |
| 3255 void TabContents::set_encoding(const std::string& encoding) { | 3263 void TabContents::set_encoding(const std::string& encoding) { |
| 3256 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 3264 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
| 3257 } | 3265 } |
| 3258 | 3266 |
| 3259 void TabContents::SetAppIcon(const SkBitmap& app_icon) { | 3267 void TabContents::SetAppIcon(const SkBitmap& app_icon) { |
| 3260 app_icon_ = app_icon; | 3268 app_icon_ = app_icon; |
| 3261 NotifyNavigationStateChanged(INVALIDATE_TITLE); | 3269 NotifyNavigationStateChanged(INVALIDATE_TITLE); |
| 3262 } | 3270 } |
| OLD | NEW |