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

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

Issue 11876036: Alternate NTP: Don't hide bookmark bar on instant (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests actually pass! Created 7 years, 11 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
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/cocoa/background_gradient_view.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 // instant preview state. 1253 // instant preview state.
1254 // ModeChanged() updates bookmark bar state for all mode transitions except 1254 // ModeChanged() updates bookmark bar state for all mode transitions except
1255 // when transitioning from |NTP| to |SEARCH_SUGGESTIONS|, because that needs 1255 // when transitioning from |NTP| to |SEARCH_SUGGESTIONS|, because that needs
1256 // to be done when the suggestions are ready. 1256 // to be done when the suggestions are ready.
1257 // If |mode| is |SEARCH_SUGGESTIONS| and bookmark bar is still showing 1257 // If |mode| is |SEARCH_SUGGESTIONS| and bookmark bar is still showing
1258 // attached, the previous mode is definitely NTP; it won't be |DEFAULT| 1258 // attached, the previous mode is definitely NTP; it won't be |DEFAULT|
1259 // because ModeChanged() would have handled that transition by hiding the 1259 // because ModeChanged() would have handled that transition by hiding the
1260 // bookmark bar. 1260 // bookmark bar.
1261 if (mode.is_search_suggestions() && 1261 if (mode.is_search_suggestions() &&
1262 bookmark_bar_state_ == BookmarkBar::SHOW) { 1262 bookmark_bar_state_ == BookmarkBar::SHOW) {
1263 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INSTANT_PREVIEW_STATE); 1263 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 /////////////////////////////////////////////////////////////////////////////// 1267 ///////////////////////////////////////////////////////////////////////////////
1268 // Browser, content::WebContentsDelegate implementation: 1268 // Browser, content::WebContentsDelegate implementation:
1269 1269
1270 WebContents* Browser::OpenURLFromTab(WebContents* source, 1270 WebContents* Browser::OpenURLFromTab(WebContents* source,
1271 const OpenURLParams& params) { 1271 const OpenURLParams& params) {
1272 chrome::NavigateParams nav_params(this, params.url, params.transition); 1272 chrome::NavigateParams nav_params(this, params.url, params.transition);
1273 nav_params.source_contents = source; 1273 nav_params.source_contents = source;
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 BookmarkTabHelper* bookmark_tab_helper = 2231 BookmarkTabHelper* bookmark_tab_helper =
2232 web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL; 2232 web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL;
2233 if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar()) 2233 if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar())
2234 state = BookmarkBar::DETACHED; 2234 state = BookmarkBar::DETACHED;
2235 else 2235 else
2236 state = BookmarkBar::HIDDEN; 2236 state = BookmarkBar::HIDDEN;
2237 } 2237 }
2238 2238
2239 // Don't allow the bookmark bar to be shown in suggestions mode or 2239 // Don't allow the bookmark bar to be shown in suggestions mode or
2240 // for instant extended api, non-NTP modes when it's detached. 2240 // for instant extended api, non-NTP modes when it's detached.
2241 if (search_model_->mode().is_search_suggestions() || 2241 // TODO(sail): Stop hidding the bookmark bar on other platforms.
kuan 2013/01/18 14:22:11 since i'm implementing the spacer approach w/out h
kuan 2013/01/18 14:23:16 correction: WITH hiding the bmb.
sail 2013/01/18 16:28:52 Done.
2242 (chrome::search::IsInstantExtendedAPIEnabled(profile_) && 2242 #if !defined(OS_MACOSX)
2243 !search_model_->mode().is_ntp() && state == BookmarkBar::DETACHED)) { 2243 if (chrome::search::IsInstantExtendedAPIEnabled(profile_)) {
2244 state = BookmarkBar::HIDDEN; 2244 if (search_model_->mode().is_search_suggestions() ||
2245 (!search_model_->mode().is_ntp() && state == BookmarkBar::DETACHED)) {
2246 state = BookmarkBar::HIDDEN;
2247 }
2245 } 2248 }
2249 #endif
2246 2250
2247 if (state == bookmark_bar_state_) 2251 if (state == bookmark_bar_state_)
2248 return; 2252 return;
2249 2253
2250 bookmark_bar_state_ = state; 2254 bookmark_bar_state_ = state;
2251 2255
2252 if (!window_) 2256 if (!window_)
2253 return; // This is called from the constructor when window_ is NULL. 2257 return; // This is called from the constructor when window_ is NULL.
2254 2258
2255 if (reason == BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH) { 2259 if (reason == BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH) {
2256 // Don't notify BrowserWindow on a tab switch as at the time this is invoked 2260 // Don't notify BrowserWindow on a tab switch as at the time this is invoked
2257 // BrowserWindow hasn't yet switched tabs. The BrowserWindow implementations 2261 // BrowserWindow hasn't yet switched tabs. The BrowserWindow implementations
2258 // end up querying state once they process the tab switch. 2262 // end up querying state once they process the tab switch.
2259 return; 2263 return;
2260 } 2264 }
2261 2265
2266 bool shouldAnimate = reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE;
2267
2262 // Don't animate if mode is |NTP| because the bookmark is attached at top when 2268 // Don't animate if mode is |NTP| because the bookmark is attached at top when
2263 // pref is on and detached at bottom when off. 2269 // pref is on and detached at bottom when off.
2264 BookmarkBar::AnimateChangeType animate_type = 2270 // TODO(sail) Remove this once other platforms have removed the bottom
2265 ((reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE && 2271 // bookmark bar.
2266 !search_model_->mode().is_ntp()) || 2272 #if !defined(OS_MACOSX)
2267 reason == BOOKMARK_BAR_STATE_CHANGE_INSTANT_PREVIEW_STATE) ? 2273 if (chrome::search::IsInstantExtendedAPIEnabled(profile_))
2274 shouldAnimate = shouldAnimate && !search_model_->mode().is_ntp();
2275 #endif
kuan 2013/01/18 14:22:11 my cl to remove bottom bmb just landed at r177659,
sail 2013/01/18 16:28:52 Done.
2276
2277 window_->BookmarkBarStateChanged(shouldAnimate ?
2268 BookmarkBar::ANIMATE_STATE_CHANGE : 2278 BookmarkBar::ANIMATE_STATE_CHANGE :
2269 BookmarkBar::DONT_ANIMATE_STATE_CHANGE; 2279 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
2270 window_->BookmarkBarStateChanged(animate_type);
2271 } 2280 }
2272 2281
2273 bool Browser::ShouldHideUIForFullscreen() const { 2282 bool Browser::ShouldHideUIForFullscreen() const {
2274 // On Mac, fullscreen mode has most normal things (in a slide-down panel). On 2283 // On Mac, fullscreen mode has most normal things (in a slide-down panel). On
2275 // other platforms, we hide some controls when in fullscreen mode. 2284 // other platforms, we hide some controls when in fullscreen mode.
2276 #if defined(OS_MACOSX) 2285 #if defined(OS_MACOSX)
2277 return false; 2286 return false;
2278 #endif 2287 #endif
2279 return window_ && window_->IsFullscreen(); 2288 return window_ && window_->IsFullscreen();
2280 } 2289 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 if (contents && !allow_js_access) { 2362 if (contents && !allow_js_access) {
2354 contents->web_contents()->GetController().LoadURL( 2363 contents->web_contents()->GetController().LoadURL(
2355 target_url, 2364 target_url,
2356 content::Referrer(), 2365 content::Referrer(),
2357 content::PAGE_TRANSITION_LINK, 2366 content::PAGE_TRANSITION_LINK,
2358 std::string()); // No extra headers. 2367 std::string()); // No extra headers.
2359 } 2368 }
2360 2369
2361 return contents != NULL; 2370 return contents != NULL;
2362 } 2371 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/cocoa/background_gradient_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698