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

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

Issue 11016023: Quickly close tabs/window with long-running unload handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch for landing Created 7 years, 6 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 | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // defined(OS_WIN) 10 #endif // defined(OS_WIN)
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 /////////////////////////////////////////////////////////////////////////////// 579 ///////////////////////////////////////////////////////////////////////////////
580 // Browser, OnBeforeUnload handling: 580 // Browser, OnBeforeUnload handling:
581 581
582 bool Browser::ShouldCloseWindow() { 582 bool Browser::ShouldCloseWindow() {
583 if (!CanCloseWithInProgressDownloads()) 583 if (!CanCloseWithInProgressDownloads())
584 return false; 584 return false;
585 585
586 return unload_controller_->ShouldCloseWindow(); 586 return unload_controller_->ShouldCloseWindow();
587 } 587 }
588 588
589 bool Browser::TabsNeedBeforeUnloadFired() {
590 return unload_controller_->TabsNeedBeforeUnloadFired();
591 }
592
593 bool Browser::HasCompletedUnloadProcessing() const {
594 return unload_controller_->HasCompletedUnloadProcessing();
595 }
596
589 bool Browser::IsAttemptingToCloseBrowser() const { 597 bool Browser::IsAttemptingToCloseBrowser() const {
590 return unload_controller_->is_attempting_to_close_browser(); 598 return unload_controller_->is_attempting_to_close_browser();
591 } 599 }
592 600
593 void Browser::OnWindowClosing() { 601 void Browser::OnWindowClosing() {
594 if (!ShouldCloseWindow()) 602 if (!ShouldCloseWindow())
595 return; 603 return;
596 604
597 // Application should shutdown on last window close if the user is explicitly 605 // Application should shutdown on last window close if the user is explicitly
598 // trying to quit, or if there is nothing keeping the browser alive (such as 606 // trying to quit, or if there is nothing keeping the browser alive (such as
(...skipping 23 matching lines...) Expand all
622 #endif 630 #endif
623 631
624 if (tab_restore_service && is_type_tabbed() && tab_strip_model_->count()) 632 if (tab_restore_service && is_type_tabbed() && tab_strip_model_->count())
625 tab_restore_service->BrowserClosing(tab_restore_service_delegate()); 633 tab_restore_service->BrowserClosing(tab_restore_service_delegate());
626 634
627 // TODO(sky): convert session/tab restore to use notification. 635 // TODO(sky): convert session/tab restore to use notification.
628 content::NotificationService::current()->Notify( 636 content::NotificationService::current()->Notify(
629 chrome::NOTIFICATION_BROWSER_CLOSING, 637 chrome::NOTIFICATION_BROWSER_CLOSING,
630 content::Source<Browser>(this), 638 content::Source<Browser>(this),
631 content::NotificationService::NoDetails()); 639 content::NotificationService::NoDetails());
632
633 tab_strip_model_->CloseAllTabs();
634 } 640 }
635 641
636 //////////////////////////////////////////////////////////////////////////////// 642 ////////////////////////////////////////////////////////////////////////////////
637 // In-progress download termination handling: 643 // In-progress download termination handling:
638 644
639 void Browser::InProgressDownloadResponse(bool cancel_downloads) { 645 void Browser::InProgressDownloadResponse(bool cancel_downloads) {
640 if (cancel_downloads) { 646 if (cancel_downloads) {
641 cancel_download_confirmation_state_ = RESPONSE_RECEIVED; 647 cancel_download_confirmation_state_ = RESPONSE_RECEIVED;
642 chrome::CloseWindow(this); 648 chrome::CloseWindow(this);
643 return; 649 return;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 return true; 1166 return true;
1161 } 1167 }
1162 return window()->PreHandleKeyboardEvent(event, is_keyboard_shortcut); 1168 return window()->PreHandleKeyboardEvent(event, is_keyboard_shortcut);
1163 } 1169 }
1164 1170
1165 void Browser::HandleKeyboardEvent(content::WebContents* source, 1171 void Browser::HandleKeyboardEvent(content::WebContents* source,
1166 const NativeWebKeyboardEvent& event) { 1172 const NativeWebKeyboardEvent& event) {
1167 window()->HandleKeyboardEvent(event); 1173 window()->HandleKeyboardEvent(event);
1168 } 1174 }
1169 1175
1170 bool Browser::TabsNeedBeforeUnloadFired() {
1171 return unload_controller_->TabsNeedBeforeUnloadFired();
1172 }
1173
1174 bool Browser::IsMouseLocked() const { 1176 bool Browser::IsMouseLocked() const {
1175 return fullscreen_controller_->IsMouseLocked(); 1177 return fullscreen_controller_->IsMouseLocked();
1176 } 1178 }
1177 1179
1178 void Browser::OnWindowDidShow() { 1180 void Browser::OnWindowDidShow() {
1179 if (window_has_shown_) 1181 if (window_has_shown_)
1180 return; 1182 return;
1181 window_has_shown_ = true; 1183 window_has_shown_ = true;
1182 1184
1183 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and 1185 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 if (contents && !allow_js_access) { 2215 if (contents && !allow_js_access) {
2214 contents->web_contents()->GetController().LoadURL( 2216 contents->web_contents()->GetController().LoadURL(
2215 target_url, 2217 target_url,
2216 content::Referrer(), 2218 content::Referrer(),
2217 content::PAGE_TRANSITION_LINK, 2219 content::PAGE_TRANSITION_LINK,
2218 std::string()); // No extra headers. 2220 std::string()); // No extra headers.
2219 } 2221 }
2220 2222
2221 return contents != NULL; 2223 return contents != NULL;
2222 } 2224 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698