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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.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/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 // BrowserView, views::ClientView overrides: 1768 // BrowserView, views::ClientView overrides:
1769 1769
1770 bool BrowserView::CanClose() { 1770 bool BrowserView::CanClose() {
1771 // You cannot close a frame for which there is an active originating drag 1771 // You cannot close a frame for which there is an active originating drag
1772 // session. 1772 // session.
1773 if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) 1773 if (tabstrip_ && !tabstrip_->IsTabStripCloseable())
1774 return false; 1774 return false;
1775 1775
1776 // Give beforeunload handlers the chance to cancel the close before we hide 1776 // Give beforeunload handlers the chance to cancel the close before we hide
1777 // the window below. 1777 // the window below.
1778 if (!browser_->ShouldCloseWindow()) 1778 if (!browser->ShouldCloseWindow()) {
1779 return false; 1779 if (browser_->tab_strip_model()->empty()) {
1780 1780 // The browser needs to finish running unload handlers.
1781 if (!browser_->tab_strip_model()->empty()) { 1781 // Hide the window (so it appears to have closed immediately), and
1782 // Tab strip isn't empty. Hide the frame (so it appears to have closed 1782 // the browser will call us back again when it is ready to close.
1783 // immediately) and close all the tabs, allowing the renderers to shut 1783 frame_->Hide();
1784 // down. When the tab strip is empty we'll be called back again. 1784 }
1785 frame_->Hide();
1786 browser_->OnWindowClosing();
1787 return false; 1785 return false;
1788 } 1786 }
1789 1787
1790 // Empty TabStripModel, it's now safe to allow the Window to be closed. 1788 // Empty TabStripModel, it's now safe to allow the Window to be closed.
1791 content::NotificationService::current()->Notify( 1789 content::NotificationService::current()->Notify(
1792 chrome::NOTIFICATION_WINDOW_CLOSED, 1790 chrome::NOTIFICATION_WINDOW_CLOSED,
1793 content::Source<gfx::NativeWindow>(frame_->GetNativeWindow()), 1791 content::Source<gfx::NativeWindow>(frame_->GetNativeWindow()),
1794 content::NotificationService::NoDetails()); 1792 content::NotificationService::NoDetails());
1795 return true; 1793 return true;
1796 } 1794 }
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 modal_browser->window()->Activate(); 2587 modal_browser->window()->Activate();
2590 } 2588 }
2591 2589
2592 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); 2590 AppModalDialogQueue::GetInstance()->ActivateModalDialog();
2593 } 2591 }
2594 2592
2595 void BrowserView::MaybeStackBookmarkBarAtTop() { 2593 void BrowserView::MaybeStackBookmarkBarAtTop() {
2596 if (bookmark_bar_view_.get()) 2594 if (bookmark_bar_view_.get())
2597 bookmark_bar_view_->MaybeStackAtTop(); 2595 bookmark_bar_view_->MaybeStackAtTop();
2598 } 2596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698