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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 17571018: Reland fast tab closure behind a flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased, 2nd attempt to land. Created 7 years, 5 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
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/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 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 // You cannot close a frame for which there is an active originating drag 1774 // You cannot close a frame for which there is an active originating drag
1775 // session. 1775 // session.
1776 if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) 1776 if (tabstrip_ && !tabstrip_->IsTabStripCloseable())
1777 return false; 1777 return false;
1778 1778
1779 // Give beforeunload handlers the chance to cancel the close before we hide 1779 // Give beforeunload handlers the chance to cancel the close before we hide
1780 // the window below. 1780 // the window below.
1781 if (!browser_->ShouldCloseWindow()) 1781 if (!browser_->ShouldCloseWindow())
1782 return false; 1782 return false;
1783 1783
1784 bool fast_tab_closing_enabled =
1785 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableFastUnload);
1786
1784 if (!browser_->tab_strip_model()->empty()) { 1787 if (!browser_->tab_strip_model()->empty()) {
1785 // Tab strip isn't empty. Hide the frame (so it appears to have closed 1788 // Tab strip isn't empty. Hide the frame (so it appears to have closed
1786 // immediately) and close all the tabs, allowing the renderers to shut 1789 // immediately) and close all the tabs, allowing the renderers to shut
1787 // down. When the tab strip is empty we'll be called back again. 1790 // down. When the tab strip is empty we'll be called back again.
1788 frame_->Hide(); 1791 frame_->Hide();
1789 browser_->OnWindowClosing(); 1792 browser_->OnWindowClosing();
1793 if (fast_tab_closing_enabled)
1794 browser_->tab_strip_model()->CloseAllTabs();
1795 return false;
1796 } else if (fast_tab_closing_enabled &&
1797 !browser_->HasCompletedUnloadProcessing()) {
1798 // The browser needs to finish running unload handlers.
1799 // Hide the frame (so it appears to have closed immediately), and
1800 // the browser will call us back again when it is ready to close.
1801 frame_->Hide();
1790 return false; 1802 return false;
1791 } 1803 }
1792 1804
1793 // Empty TabStripModel, it's now safe to allow the Window to be closed. 1805 // Empty TabStripModel, it's now safe to allow the Window to be closed.
1794 content::NotificationService::current()->Notify( 1806 content::NotificationService::current()->Notify(
1795 chrome::NOTIFICATION_WINDOW_CLOSED, 1807 chrome::NOTIFICATION_WINDOW_CLOSED,
1796 content::Source<gfx::NativeWindow>(frame_->GetNativeWindow()), 1808 content::Source<gfx::NativeWindow>(frame_->GetNativeWindow()),
1797 content::NotificationService::NoDetails()); 1809 content::NotificationService::NoDetails());
1798 return true; 1810 return true;
1799 } 1811 }
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
2732 // The +1 in the next line creates a 1-px gap between icon and arrow tip. 2744 // The +1 in the next line creates a 1-px gap between icon and arrow tip.
2733 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() - 2745 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() -
2734 LocationBarView::kIconInternalPadding + 1); 2746 LocationBarView::kIconInternalPadding + 1);
2735 ConvertPointToTarget(location_icon_view, this, &icon_bottom); 2747 ConvertPointToTarget(location_icon_view, this, &icon_bottom);
2736 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); 2748 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL));
2737 ConvertPointToTarget(infobar_container_, this, &infobar_top); 2749 ConvertPointToTarget(infobar_container_, this, &infobar_top);
2738 top_arrow_height = infobar_top.y() - icon_bottom.y(); 2750 top_arrow_height = infobar_top.y() - icon_bottom.y();
2739 } 2751 }
2740 return top_arrow_height; 2752 return top_arrow_height;
2741 } 2753 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698