Chromium Code Reviews| 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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 833 void TabContents::HideContents() { | 833 void TabContents::HideContents() { |
| 834 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call | 834 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call |
| 835 // our superclass HideContents(), because some callers want to be very picky | 835 // our superclass HideContents(), because some callers want to be very picky |
| 836 // about the order in which these get called. In addition to making the code | 836 // about the order in which these get called. In addition to making the code |
| 837 // here practically impossible to understand, this also means we end up | 837 // here practically impossible to understand, this also means we end up |
| 838 // calling TabContents::WasHidden() twice if callers call both versions of | 838 // calling TabContents::WasHidden() twice if callers call both versions of |
| 839 // HideContents() on a TabContents. | 839 // HideContents() on a TabContents. |
| 840 WasHidden(); | 840 WasHidden(); |
| 841 } | 841 } |
| 842 | 842 |
| 843 bool TabContents::NeedToFireBeforeUnload() { | |
| 844 return notify_disconnection() && | |
| 845 !showing_interstitial_page() && | |
|
Charlie Reis
2010/12/08 01:26:12
Why is this line necessary? I think we run unload
sky
2010/12/08 03:04:22
No idea there. This code comes directly from Brows
Charlie Reis
2010/12/08 05:50:11
Oh! Well, it doesn't sound right to me, since the
| |
| 846 !render_view_host()->SuddenTerminationAllowed(); | |
|
Charlie Reis
2010/12/08 01:26:12
Doesn't this catch both the beforeunload and unloa
sky
2010/12/08 03:04:22
Yes.
Charlie Reis
2010/12/08 05:50:11
Yep, the improved comment is enough-- thanks.
| |
| 847 } | |
| 848 | |
| 843 void TabContents::OpenURL(const GURL& url, const GURL& referrer, | 849 void TabContents::OpenURL(const GURL& url, const GURL& referrer, |
| 844 WindowOpenDisposition disposition, | 850 WindowOpenDisposition disposition, |
| 845 PageTransition::Type transition) { | 851 PageTransition::Type transition) { |
| 846 if (delegate_) | 852 if (delegate_) |
| 847 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); | 853 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); |
| 848 } | 854 } |
| 849 | 855 |
| 850 bool TabContents::NavigateToPendingEntry( | 856 bool TabContents::NavigateToPendingEntry( |
| 851 NavigationController::ReloadType reload_type) { | 857 NavigationController::ReloadType reload_type) { |
| 852 return NavigateToEntry(*controller_.pending_entry(), reload_type); | 858 return NavigateToEntry(*controller_.pending_entry(), reload_type); |
| (...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2778 default_prompt, show_suppress_checkbox, reply_msg); | 2784 default_prompt, show_suppress_checkbox, reply_msg); |
| 2779 } else { | 2785 } else { |
| 2780 // If we are suppressing messages, just reply as is if the user immediately | 2786 // If we are suppressing messages, just reply as is if the user immediately |
| 2781 // pressed "Cancel". | 2787 // pressed "Cancel". |
| 2782 OnMessageBoxClosed(reply_msg, false, std::wstring()); | 2788 OnMessageBoxClosed(reply_msg, false, std::wstring()); |
| 2783 } | 2789 } |
| 2784 } | 2790 } |
| 2785 | 2791 |
| 2786 void TabContents::RunBeforeUnloadConfirm(const std::wstring& message, | 2792 void TabContents::RunBeforeUnloadConfirm(const std::wstring& message, |
| 2787 IPC::Message* reply_msg) { | 2793 IPC::Message* reply_msg) { |
| 2794 if (delegate()) | |
| 2795 delegate()->WillRunBeforeUnloadConfirm(); | |
| 2788 if (delegate() && delegate()->ShouldSuppressDialogs()) { | 2796 if (delegate() && delegate()->ShouldSuppressDialogs()) { |
| 2789 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, | 2797 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, |
| 2790 std::wstring()); | 2798 std::wstring()); |
| 2791 return; | 2799 return; |
| 2792 } | 2800 } |
| 2793 is_showing_before_unload_dialog_ = true; | 2801 is_showing_before_unload_dialog_ = true; |
| 2794 RunBeforeUnloadDialog(this, message, reply_msg); | 2802 RunBeforeUnloadDialog(this, message, reply_msg); |
| 2795 } | 2803 } |
| 2796 | 2804 |
| 2797 void TabContents::ShowModalHTMLDialog(const GURL& url, int width, int height, | 2805 void TabContents::ShowModalHTMLDialog(const GURL& url, int width, int height, |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3243 } | 3251 } |
| 3244 | 3252 |
| 3245 void TabContents::set_encoding(const std::string& encoding) { | 3253 void TabContents::set_encoding(const std::string& encoding) { |
| 3246 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 3254 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
| 3247 } | 3255 } |
| 3248 | 3256 |
| 3249 void TabContents::SetAppIcon(const SkBitmap& app_icon) { | 3257 void TabContents::SetAppIcon(const SkBitmap& app_icon) { |
| 3250 app_icon_ = app_icon; | 3258 app_icon_ = app_icon; |
| 3251 NotifyNavigationStateChanged(INVALIDATE_TITLE); | 3259 NotifyNavigationStateChanged(INVALIDATE_TITLE); |
| 3252 } | 3260 } |
| OLD | NEW |