OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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. |
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)) { | |
dhollowa
2013/01/18 00:55:11
nit: no {} needed now
sail
2013/01/18 01:37:09
I find braces around if statements with multi-line
dhollowa
2013/01/18 15:59:58
That's fine.
| |
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 shouldAnimate = shouldAnimate && !search_model_->mode().is_ntp(); |
dhollowa
2013/01/18 00:55:11
I guess this should be wrapped in an if (IsInstant
sail
2013/01/18 01:37:09
Done.
Good catch.
| |
2274 #endif | |
2275 | |
2276 window_->BookmarkBarStateChanged(shouldAnimate ? | |
2268 BookmarkBar::ANIMATE_STATE_CHANGE : | 2277 BookmarkBar::ANIMATE_STATE_CHANGE : |
2269 BookmarkBar::DONT_ANIMATE_STATE_CHANGE; | 2278 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
2270 window_->BookmarkBarStateChanged(animate_type); | |
2271 } | 2279 } |
2272 | 2280 |
2273 bool Browser::ShouldHideUIForFullscreen() const { | 2281 bool Browser::ShouldHideUIForFullscreen() const { |
2274 // On Mac, fullscreen mode has most normal things (in a slide-down panel). On | 2282 // 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. | 2283 // other platforms, we hide some controls when in fullscreen mode. |
2276 #if defined(OS_MACOSX) | 2284 #if defined(OS_MACOSX) |
2277 return false; | 2285 return false; |
2278 #endif | 2286 #endif |
2279 return window_ && window_->IsFullscreen(); | 2287 return window_ && window_->IsFullscreen(); |
2280 } | 2288 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2353 if (contents && !allow_js_access) { | 2361 if (contents && !allow_js_access) { |
2354 contents->web_contents()->GetController().LoadURL( | 2362 contents->web_contents()->GetController().LoadURL( |
2355 target_url, | 2363 target_url, |
2356 content::Referrer(), | 2364 content::Referrer(), |
2357 content::PAGE_TRANSITION_LINK, | 2365 content::PAGE_TRANSITION_LINK, |
2358 std::string()); // No extra headers. | 2366 std::string()); // No extra headers. |
2359 } | 2367 } |
2360 | 2368 |
2361 return contents != NULL; | 2369 return contents != NULL; |
2362 } | 2370 } |
OLD | NEW |