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

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: Diff against original patch 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 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 // You cannot close a frame for which there is an active originating drag 1808 // You cannot close a frame for which there is an active originating drag
1809 // session. 1809 // session.
1810 if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) 1810 if (tabstrip_ && !tabstrip_->IsTabStripCloseable())
1811 return false; 1811 return false;
1812 1812
1813 // Give beforeunload handlers the chance to cancel the close before we hide 1813 // Give beforeunload handlers the chance to cancel the close before we hide
1814 // the window below. 1814 // the window below.
1815 if (!browser_->ShouldCloseWindow()) 1815 if (!browser_->ShouldCloseWindow())
1816 return false; 1816 return false;
1817 1817
1818 bool fast_tab_closing_enabled =
1819 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableFastUnload);
1820
1818 if (!browser_->tab_strip_model()->empty()) { 1821 if (!browser_->tab_strip_model()->empty()) {
1819 // Tab strip isn't empty. Hide the frame (so it appears to have closed 1822 // Tab strip isn't empty. Hide the frame (so it appears to have closed
1820 // immediately) and close all the tabs, allowing the renderers to shut 1823 // immediately) and close all the tabs, allowing the renderers to shut
1821 // down. When the tab strip is empty we'll be called back again. 1824 // down. When the tab strip is empty we'll be called back again.
1822 frame_->Hide(); 1825 frame_->Hide();
1823 browser_->OnWindowClosing(); 1826 browser_->OnWindowClosing();
1824 browser_->tab_strip_model()->CloseAllTabs(); 1827 if (fast_tab_closing_enabled)
1828 browser_->tab_strip_model()->CloseAllTabs();
1825 return false; 1829 return false;
1826 } else if (!browser_->HasCompletedUnloadProcessing()) { 1830 } else if (fast_tab_closing_enabled &&
1831 !browser_->HasCompletedUnloadProcessing()) {
1827 // The browser needs to finish running unload handlers. 1832 // The browser needs to finish running unload handlers.
1828 // Hide the frame (so it appears to have closed immediately), and 1833 // Hide the frame (so it appears to have closed immediately), and
1829 // the browser will call us back again when it is ready to close. 1834 // the browser will call us back again when it is ready to close.
1830 frame_->Hide(); 1835 frame_->Hide();
1831 return false; 1836 return false;
1832 } 1837 }
1833 1838
1834 // Empty TabStripModel, it's now safe to allow the Window to be closed. 1839 // Empty TabStripModel, it's now safe to allow the Window to be closed.
1835 content::NotificationService::current()->Notify( 1840 content::NotificationService::current()->Notify(
1836 chrome::NOTIFICATION_WINDOW_CLOSED, 1841 chrome::NOTIFICATION_WINDOW_CLOSED,
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 // The +1 in the next line creates a 1-px gap between icon and arrow tip. 2778 // The +1 in the next line creates a 1-px gap between icon and arrow tip.
2774 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() - 2779 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() -
2775 LocationBarView::kIconInternalPadding + 1); 2780 LocationBarView::kIconInternalPadding + 1);
2776 ConvertPointToTarget(location_icon_view, this, &icon_bottom); 2781 ConvertPointToTarget(location_icon_view, this, &icon_bottom);
2777 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); 2782 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL));
2778 ConvertPointToTarget(infobar_container_, this, &infobar_top); 2783 ConvertPointToTarget(infobar_container_, this, &infobar_top);
2779 top_arrow_height = infobar_top.y() - icon_bottom.y(); 2784 top_arrow_height = infobar_top.y() - icon_bottom.y();
2780 } 2785 }
2781 return top_arrow_height; 2786 return top_arrow_height;
2782 } 2787 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698