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

Side by Side Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 5610005: Makes instant run before unload listeners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome
Patch Set: Fix comments and reset session id appropriately Created 10 years 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
OLDNEW
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
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 // TODO(creis): Should we fire even for interstitial pages?
846 return notify_disconnection() &&
847 !showing_interstitial_page() &&
848 !render_view_host()->SuddenTerminationAllowed();
849 }
850
844 void TabContents::OpenURL(const GURL& url, const GURL& referrer, 851 void TabContents::OpenURL(const GURL& url, const GURL& referrer,
845 WindowOpenDisposition disposition, 852 WindowOpenDisposition disposition,
846 PageTransition::Type transition) { 853 PageTransition::Type transition) {
847 if (delegate_) 854 if (delegate_)
848 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); 855 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition);
849 } 856 }
850 857
851 bool TabContents::NavigateToPendingEntry( 858 bool TabContents::NavigateToPendingEntry(
852 NavigationController::ReloadType reload_type) { 859 NavigationController::ReloadType reload_type) {
853 return NavigateToEntry(*controller_.pending_entry(), reload_type); 860 return NavigateToEntry(*controller_.pending_entry(), reload_type);
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 default_prompt, show_suppress_checkbox, reply_msg); 2795 default_prompt, show_suppress_checkbox, reply_msg);
2789 } else { 2796 } else {
2790 // If we are suppressing messages, just reply as is if the user immediately 2797 // If we are suppressing messages, just reply as is if the user immediately
2791 // pressed "Cancel". 2798 // pressed "Cancel".
2792 OnMessageBoxClosed(reply_msg, false, std::wstring()); 2799 OnMessageBoxClosed(reply_msg, false, std::wstring());
2793 } 2800 }
2794 } 2801 }
2795 2802
2796 void TabContents::RunBeforeUnloadConfirm(const std::wstring& message, 2803 void TabContents::RunBeforeUnloadConfirm(const std::wstring& message,
2797 IPC::Message* reply_msg) { 2804 IPC::Message* reply_msg) {
2805 if (delegate())
2806 delegate()->WillRunBeforeUnloadConfirm();
2798 if (delegate() && delegate()->ShouldSuppressDialogs()) { 2807 if (delegate() && delegate()->ShouldSuppressDialogs()) {
2799 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, 2808 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true,
2800 std::wstring()); 2809 std::wstring());
2801 return; 2810 return;
2802 } 2811 }
2803 is_showing_before_unload_dialog_ = true; 2812 is_showing_before_unload_dialog_ = true;
2804 RunBeforeUnloadDialog(this, message, reply_msg); 2813 RunBeforeUnloadDialog(this, message, reply_msg);
2805 } 2814 }
2806 2815
2807 void TabContents::ShowModalHTMLDialog(const GURL& url, int width, int height, 2816 void TabContents::ShowModalHTMLDialog(const GURL& url, int width, int height,
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
3253 } 3262 }
3254 3263
3255 void TabContents::set_encoding(const std::string& encoding) { 3264 void TabContents::set_encoding(const std::string& encoding) {
3256 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); 3265 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding);
3257 } 3266 }
3258 3267
3259 void TabContents::SetAppIcon(const SkBitmap& app_icon) { 3268 void TabContents::SetAppIcon(const SkBitmap& app_icon) {
3260 app_icon_ = app_icon; 3269 app_icon_ = app_icon;
3261 NotifyNavigationStateChanged(INVALIDATE_TITLE); 3270 NotifyNavigationStateChanged(INVALIDATE_TITLE);
3262 } 3271 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/tab_contents/tab_contents_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698