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

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

Issue 12631008: alternate ntp: implement Show/HideBars API to reduce jank when showing/hiding bars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed flashing bars for DEFAULT->SUGGESTIONS->SERP Created 7 years, 9 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/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 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 GlobalErrorServiceFactory::GetForProfile(profile()); 1218 GlobalErrorServiceFactory::GetForProfile(profile());
1219 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); 1219 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView();
1220 if (error) 1220 if (error)
1221 error->ShowBubbleView(this); 1221 error->ShowBubbleView(this);
1222 } 1222 }
1223 1223
1224 void Browser::ShowFirstRunBubble() { 1224 void Browser::ShowFirstRunBubble() {
1225 window()->GetLocationBar()->ShowFirstRunBubble(); 1225 window()->GetLocationBar()->ShowFirstRunBubble();
1226 } 1226 }
1227 1227
1228 void Browser::MaybeUpdateBookmarkBarStateForInstantOverlay(
1229 const chrome::search::Mode& mode) {
1230 // This is invoked by a platform-specific implementation of
1231 // |InstantOverlayController| to update bookmark bar state according to
1232 // Instant overlay state.
1233 // ModeChanged() updates bookmark bar state for all mode transitions except
1234 // when new mode is |SEARCH_SUGGESTIONS|, because that needs to be done when
1235 // the suggestions are ready.
1236 if (mode.is_search_suggestions() &&
1237 bookmark_bar_state_ == BookmarkBar::SHOW) {
1238 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
1239 }
1240 }
1241
1242 void Browser::ShowDownload(content::DownloadItem* download) { 1228 void Browser::ShowDownload(content::DownloadItem* download) {
1243 if (!window()) 1229 if (!window())
1244 return; 1230 return;
1245 1231
1246 // If the download occurs in a new tab, and it's not a save page 1232 // If the download occurs in a new tab, and it's not a save page
1247 // download (started before initial navigation completed) close it. 1233 // download (started before initial navigation completed) close it.
1248 WebContents* source = download->GetWebContents(); 1234 WebContents* source = download->GetWebContents();
1249 if (source && source->GetController().IsInitialNavigation() && 1235 if (source && source->GetController().IsInitialNavigation() &&
1250 tab_strip_model_->count() > 1 && !download->IsSavePackageDownload()) { 1236 tab_strip_model_->count() > 1 && !download->IsSavePackageDownload()) {
1251 CloseContents(source); 1237 CloseContents(source);
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 location_bar->UpdateContentSettingsIcons(); 1791 location_bar->UpdateContentSettingsIcons();
1806 } 1792 }
1807 break; 1793 break;
1808 } 1794 }
1809 1795
1810 default: 1796 default:
1811 NOTREACHED() << "Got a notification we didn't register for."; 1797 NOTREACHED() << "Got a notification we didn't register for.";
1812 } 1798 }
1813 } 1799 }
1814 1800
1815 void Browser::ModeChanged(const chrome::search::Mode& old_mode, 1801 void Browser::ModelChanged(
1816 const chrome::search::Mode& new_mode) { 1802 const chrome::search::SearchModel::State& old_state,
1817 // If new mode is |SEARCH_SUGGESTIONS|, don't update bookmark bar state now; 1803 const chrome::search::SearchModel::State& new_state) {
1818 // wait till the Instant overlay is ready to show suggestions before hiding 1804 if (chrome::search::SearchModel::ShouldChangeTopBarsVisibility(old_state,
1819 // the bookmark bar (in MaybeUpdateBookmarkBarStateForInstantOverlay()). 1805 new_state)) {
1820 // TODO(kuan): but for now, only delay updating bookmark bar state if origin 1806 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
1821 // is |DEFAULT|; other origins require more complex logic to be implemented
1822 // to prevent jankiness caused by hiding bookmark bar, so just hide the
1823 // bookmark bar immediately and tolerate the jankiness for a while.
1824 // For other mode transitions, update bookmark bar state accordingly.
1825 if (new_mode.is_search_suggestions() &&
1826 new_mode.is_origin_default() &&
1827 bookmark_bar_state_ == BookmarkBar::SHOW) {
1828 return;
1829 } 1807 }
1830 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
1831 } 1808 }
1832 1809
1833 /////////////////////////////////////////////////////////////////////////////// 1810 ///////////////////////////////////////////////////////////////////////////////
1834 // Browser, Command and state updating (private): 1811 // Browser, Command and state updating (private):
1835 1812
1836 void Browser::OnDevToolsDisabledChanged() { 1813 void Browser::OnDevToolsDisabledChanged() {
1837 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) 1814 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled))
1838 content::DevToolsManager::GetInstance()->CloseAllClientHosts(); 1815 content::DevToolsManager::GetInstance()->CloseAllClientHosts();
1839 } 1816 }
1840 1817
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 } else { 2107 } else {
2131 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); 2108 WebContents* web_contents = tab_strip_model_->GetActiveWebContents();
2132 BookmarkTabHelper* bookmark_tab_helper = 2109 BookmarkTabHelper* bookmark_tab_helper =
2133 web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL; 2110 web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL;
2134 if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar()) 2111 if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar())
2135 state = BookmarkBar::DETACHED; 2112 state = BookmarkBar::DETACHED;
2136 else 2113 else
2137 state = BookmarkBar::HIDDEN; 2114 state = BookmarkBar::HIDDEN;
2138 } 2115 }
2139 2116
2140 // Don't allow the bookmark bar to be shown in suggestions mode. 2117 // Bookmark bar may need to be hidden for |SEARCH_SUGGESTIONS| and
2118 // |SEARCH_RESULTS| modes as per SearchBox API or Instant overlay or if it's
2119 // detached.
2120 // TODO(sail): remove conditional MACOSX flag when bookmark bar is actually
2121 // hidden on mac; for now, mac keeps the bookmark bar shown but changes its
2122 // z-order.
2141 #if !defined(OS_MACOSX) 2123 #if !defined(OS_MACOSX)
2142 if (search_model_->mode().is_search_suggestions()) 2124 if (search_model_->mode().is_search() &&
2125 (state == BookmarkBar::DETACHED ||
2126 (state != BookmarkBar::HIDDEN && !search_model_->top_bars_visible()))) {
Peter Kasting 2013/03/15 05:32:01 Nit: You can simplify this by removing "state != B
kuan 2013/03/15 15:53:49 Done.
2143 state = BookmarkBar::HIDDEN; 2127 state = BookmarkBar::HIDDEN;
2144 #endif 2128 }
2145 2129 #else
2146 // Don't allow detached bookmark bar to be shown in suggestions or results 2130 // TODO(sail): remove this when the above block is enabled for mac.
2147 // modes.
2148 if (state == BookmarkBar::DETACHED && search_model_->mode().is_search()) 2131 if (state == BookmarkBar::DETACHED && search_model_->mode().is_search())
2149 state = BookmarkBar::HIDDEN; 2132 state = BookmarkBar::HIDDEN;
2133 #endif // !defined(OS_MACOSX)
2150 2134
2151 if (state == bookmark_bar_state_) 2135 if (state == bookmark_bar_state_)
2152 return; 2136 return;
2153 2137
2154 bookmark_bar_state_ = state; 2138 bookmark_bar_state_ = state;
2155 2139
2156 if (!window_) 2140 if (!window_)
2157 return; // This is called from the constructor when window_ is NULL. 2141 return; // This is called from the constructor when window_ is NULL.
2158 2142
2159 if (reason == BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH) { 2143 if (reason == BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 if (contents && !allow_js_access) { 2233 if (contents && !allow_js_access) {
2250 contents->web_contents()->GetController().LoadURL( 2234 contents->web_contents()->GetController().LoadURL(
2251 target_url, 2235 target_url,
2252 content::Referrer(), 2236 content::Referrer(),
2253 content::PAGE_TRANSITION_LINK, 2237 content::PAGE_TRANSITION_LINK,
2254 std::string()); // No extra headers. 2238 std::string()); // No extra headers.
2255 } 2239 }
2256 2240
2257 return contents != NULL; 2241 return contents != NULL;
2258 } 2242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698