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

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: Keep original TabsNeedBeforeUnloadFired implementation. Created 8 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 /////////////////////////////////////////////////////////////////////////////// 594 ///////////////////////////////////////////////////////////////////////////////
595 // Browser, OnBeforeUnload handling: 595 // Browser, OnBeforeUnload handling:
596 596
597 bool Browser::ShouldCloseWindow() { 597 bool Browser::ShouldCloseWindow() {
598 if (!CanCloseWithInProgressDownloads()) 598 if (!CanCloseWithInProgressDownloads())
599 return false; 599 return false;
600 600
601 return unload_controller_->ShouldCloseWindow(); 601 return unload_controller_->ShouldCloseWindow();
602 } 602 }
603 603
604 bool Browser::TabsNeedBeforeUnloadFired() {
605 return unload_controller_->TabsNeedBeforeUnloadFired();
606 }
607
604 bool Browser::IsAttemptingToCloseBrowser() const { 608 bool Browser::IsAttemptingToCloseBrowser() const {
605 return unload_controller_->is_attempting_to_close_browser(); 609 return unload_controller_->is_attempting_to_close_browser();
606 } 610 }
607 611
608 void Browser::OnWindowClosing() { 612 void Browser::OnWindowClosing() {
609 if (!ShouldCloseWindow())
610 return;
611
612 // Application should shutdown on last window close if the user is explicitly 613 // Application should shutdown on last window close if the user is explicitly
613 // trying to quit, or if there is nothing keeping the browser alive (such as 614 // trying to quit, or if there is nothing keeping the browser alive (such as
614 // AppController on the Mac, or BackgroundContentsService for background 615 // AppController on the Mac, or BackgroundContentsService for background
615 // pages). 616 // pages).
616 bool should_quit_if_last_browser = 617 bool should_quit_if_last_browser =
617 browser_shutdown::IsTryingToQuit() || !browser::WillKeepAlive(); 618 browser_shutdown::IsTryingToQuit() || !browser::WillKeepAlive();
618 619
619 if (should_quit_if_last_browser && BrowserList::size() == 1) 620 if (should_quit_if_last_browser && BrowserList::size() == 1)
620 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); 621 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE);
621 622
(...skipping 17 matching lines...) Expand all
639 640
640 // TODO(sky): convert session/tab restore to use notification. 641 // TODO(sky): convert session/tab restore to use notification.
641 content::NotificationService::current()->Notify( 642 content::NotificationService::current()->Notify(
642 chrome::NOTIFICATION_BROWSER_CLOSING, 643 chrome::NOTIFICATION_BROWSER_CLOSING,
643 content::Source<Browser>(this), 644 content::Source<Browser>(this),
644 content::NotificationService::NoDetails()); 645 content::NotificationService::NoDetails());
645 646
646 chrome::CloseAllTabs(this); 647 chrome::CloseAllTabs(this);
647 } 648 }
648 649
650 void Browser::OnUnloadProcessingCompleted() {
651 CloseFrame();
652 }
653
649 void Browser::OnWindowActivated() { 654 void Browser::OnWindowActivated() {
650 // On some platforms we want to automatically reload tabs that are 655 // On some platforms we want to automatically reload tabs that are
651 // killed when the user selects them. 656 // killed when the user selects them.
652 WebContents* contents = chrome::GetActiveWebContents(this); 657 WebContents* contents = chrome::GetActiveWebContents(this);
653 if (contents && ShouldReloadCrashedTab(contents)) 658 if (contents && ShouldReloadCrashedTab(contents))
654 chrome::Reload(this, CURRENT_TAB); 659 chrome::Reload(this, CURRENT_TAB);
655 } 660 }
656 661
657 //////////////////////////////////////////////////////////////////////////////// 662 ////////////////////////////////////////////////////////////////////////////////
658 // In-progress download termination handling: 663 // In-progress download termination handling:
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 return true; 1215 return true;
1211 } 1216 }
1212 return window()->PreHandleKeyboardEvent(event, is_keyboard_shortcut); 1217 return window()->PreHandleKeyboardEvent(event, is_keyboard_shortcut);
1213 } 1218 }
1214 1219
1215 void Browser::HandleKeyboardEvent(content::WebContents* source, 1220 void Browser::HandleKeyboardEvent(content::WebContents* source,
1216 const NativeWebKeyboardEvent& event) { 1221 const NativeWebKeyboardEvent& event) {
1217 window()->HandleKeyboardEvent(event); 1222 window()->HandleKeyboardEvent(event);
1218 } 1223 }
1219 1224
1220 bool Browser::TabsNeedBeforeUnloadFired() {
1221 return unload_controller_->TabsNeedBeforeUnloadFired();
1222 }
1223
1224 bool Browser::IsMouseLocked() const { 1225 bool Browser::IsMouseLocked() const {
1225 return fullscreen_controller_->IsMouseLocked(); 1226 return fullscreen_controller_->IsMouseLocked();
1226 } 1227 }
1227 1228
1228 void Browser::OnWindowDidShow() { 1229 void Browser::OnWindowDidShow() {
1229 if (window_has_shown_) 1230 if (window_has_shown_)
1230 return; 1231 return;
1231 window_has_shown_ = true; 1232 window_has_shown_ = true;
1232 1233
1233 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and 1234 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 if (contents && !allow_js_access) { 2346 if (contents && !allow_js_access) {
2346 contents->web_contents()->GetController().LoadURL( 2347 contents->web_contents()->GetController().LoadURL(
2347 target_url, 2348 target_url,
2348 content::Referrer(), 2349 content::Referrer(),
2349 content::PAGE_TRANSITION_LINK, 2350 content::PAGE_TRANSITION_LINK,
2350 std::string()); // No extra headers. 2351 std::string()); // No extra headers.
2351 } 2352 }
2352 2353
2353 return contents != NULL; 2354 return contents != NULL;
2354 } 2355 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698