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 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1245 // instant preview state. | 1245 // instant preview state. |
1246 // ModeChanged() updates bookmark bar state for all mode transitions except | 1246 // ModeChanged() updates bookmark bar state for all mode transitions except |
1247 // when transitioning from |NTP| to |SEARCH_SUGGESTIONS|, because that needs | 1247 // when transitioning from |NTP| to |SEARCH_SUGGESTIONS|, because that needs |
1248 // to be done when the suggestions are ready. | 1248 // to be done when the suggestions are ready. |
1249 // If |mode| is |SEARCH_SUGGESTIONS| and bookmark bar is still showing | 1249 // If |mode| is |SEARCH_SUGGESTIONS| and bookmark bar is still showing |
1250 // attached, the previous mode is definitely NTP; it won't be |DEFAULT| | 1250 // attached, the previous mode is definitely NTP; it won't be |DEFAULT| |
1251 // because ModeChanged() would have handled that transition by hiding the | 1251 // because ModeChanged() would have handled that transition by hiding the |
1252 // bookmark bar. | 1252 // bookmark bar. |
1253 if (mode.is_search_suggestions() && | 1253 if (mode.is_search_suggestions() && |
1254 bookmark_bar_state_ == BookmarkBar::SHOW) { | 1254 bookmark_bar_state_ == BookmarkBar::SHOW) { |
1255 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INSTANT_PREVIEW_STATE); | 1255 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
1256 } | 1256 } |
1257 } | 1257 } |
1258 | 1258 |
1259 /////////////////////////////////////////////////////////////////////////////// | 1259 /////////////////////////////////////////////////////////////////////////////// |
1260 // Browser, content::WebContentsDelegate implementation: | 1260 // Browser, content::WebContentsDelegate implementation: |
1261 | 1261 |
1262 WebContents* Browser::OpenURLFromTab(WebContents* source, | 1262 WebContents* Browser::OpenURLFromTab(WebContents* source, |
1263 const OpenURLParams& params) { | 1263 const OpenURLParams& params) { |
1264 chrome::NavigateParams nav_params(this, params.url, params.transition); | 1264 chrome::NavigateParams nav_params(this, params.url, params.transition); |
1265 nav_params.source_contents = source; | 1265 nav_params.source_contents = source; |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2222 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); | 2222 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); |
2223 BookmarkTabHelper* bookmark_tab_helper = | 2223 BookmarkTabHelper* bookmark_tab_helper = |
2224 web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL; | 2224 web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL; |
2225 if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar()) | 2225 if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar()) |
2226 state = BookmarkBar::DETACHED; | 2226 state = BookmarkBar::DETACHED; |
2227 else | 2227 else |
2228 state = BookmarkBar::HIDDEN; | 2228 state = BookmarkBar::HIDDEN; |
2229 } | 2229 } |
2230 | 2230 |
2231 // Don't allow the bookmark bar to be shown in suggestions mode. | 2231 // Don't allow the bookmark bar to be shown in suggestions mode. |
2232 #if !defined(OS_MACOSX) | |
2232 if (search_model_->mode().is_search_suggestions()) | 2233 if (search_model_->mode().is_search_suggestions()) |
2233 state = BookmarkBar::HIDDEN; | 2234 state = BookmarkBar::HIDDEN; |
2235 #endif | |
Nico
2013/01/23 21:00:04
Why is this different on OS X than elsewhere? This
| |
2234 | 2236 |
2235 if (state == bookmark_bar_state_) | 2237 if (state == bookmark_bar_state_) |
2236 return; | 2238 return; |
2237 | 2239 |
2238 bookmark_bar_state_ = state; | 2240 bookmark_bar_state_ = state; |
2239 | 2241 |
2240 if (!window_) | 2242 if (!window_) |
2241 return; // This is called from the constructor when window_ is NULL. | 2243 return; // This is called from the constructor when window_ is NULL. |
2242 | 2244 |
2243 if (reason == BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH) { | 2245 if (reason == BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH) { |
2244 // Don't notify BrowserWindow on a tab switch as at the time this is invoked | 2246 // Don't notify BrowserWindow on a tab switch as at the time this is invoked |
2245 // BrowserWindow hasn't yet switched tabs. The BrowserWindow implementations | 2247 // BrowserWindow hasn't yet switched tabs. The BrowserWindow implementations |
2246 // end up querying state once they process the tab switch. | 2248 // end up querying state once they process the tab switch. |
2247 return; | 2249 return; |
2248 } | 2250 } |
2249 | 2251 |
2250 // Don't animate if mode is |NTP| because the bookmark is attached at top when | 2252 bool shouldAnimate = reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE; |
2251 // pref is on and detached at bottom when off. | 2253 window_->BookmarkBarStateChanged(shouldAnimate ? |
2252 BookmarkBar::AnimateChangeType animate_type = | |
2253 (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE || | |
2254 reason == BOOKMARK_BAR_STATE_CHANGE_INSTANT_PREVIEW_STATE) ? | |
2255 BookmarkBar::ANIMATE_STATE_CHANGE : | 2254 BookmarkBar::ANIMATE_STATE_CHANGE : |
2256 BookmarkBar::DONT_ANIMATE_STATE_CHANGE; | 2255 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
2257 window_->BookmarkBarStateChanged(animate_type); | |
2258 } | 2256 } |
2259 | 2257 |
2260 bool Browser::ShouldHideUIForFullscreen() const { | 2258 bool Browser::ShouldHideUIForFullscreen() const { |
2261 // On Mac, fullscreen mode has most normal things (in a slide-down panel). On | 2259 // On Mac, fullscreen mode has most normal things (in a slide-down panel). On |
2262 // other platforms, we hide some controls when in fullscreen mode. | 2260 // other platforms, we hide some controls when in fullscreen mode. |
2263 #if defined(OS_MACOSX) | 2261 #if defined(OS_MACOSX) |
2264 return false; | 2262 return false; |
2265 #endif | 2263 #endif |
2266 return window_ && window_->IsFullscreen(); | 2264 return window_ && window_->IsFullscreen(); |
2267 } | 2265 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2340 if (contents && !allow_js_access) { | 2338 if (contents && !allow_js_access) { |
2341 contents->web_contents()->GetController().LoadURL( | 2339 contents->web_contents()->GetController().LoadURL( |
2342 target_url, | 2340 target_url, |
2343 content::Referrer(), | 2341 content::Referrer(), |
2344 content::PAGE_TRANSITION_LINK, | 2342 content::PAGE_TRANSITION_LINK, |
2345 std::string()); // No extra headers. | 2343 std::string()); // No extra headers. |
2346 } | 2344 } |
2347 | 2345 |
2348 return contents != NULL; | 2346 return contents != NULL; |
2349 } | 2347 } |
OLD | NEW |