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 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 void Browser::ShowFirstRunBubble() { | 1237 void Browser::ShowFirstRunBubble() { |
1238 window()->GetLocationBar()->ShowFirstRunBubble(); | 1238 window()->GetLocationBar()->ShowFirstRunBubble(); |
1239 } | 1239 } |
1240 | 1240 |
1241 void Browser::MaybeUpdateBookmarkBarStateForInstantPreview( | 1241 void Browser::MaybeUpdateBookmarkBarStateForInstantPreview( |
1242 const chrome::search::Mode& mode) { | 1242 const chrome::search::Mode& mode) { |
1243 // This is invoked by a platform-specific implementation of | 1243 // This is invoked by a platform-specific implementation of |
1244 // |InstantPreviewController| to update bookmark bar state according to | 1244 // |InstantPreviewController| to update bookmark bar state according to |
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 new mode is |SEARCH_SUGGESTIONS|, because that needs to be done when |
1248 // to be done when the suggestions are ready. | 1248 // the suggestions are ready. |
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| | |
1251 // because ModeChanged() would have handled that transition by hiding the | |
1252 // bookmark bar. | |
1253 if (mode.is_search_suggestions() && | 1249 if (mode.is_search_suggestions() && |
1254 bookmark_bar_state_ == BookmarkBar::SHOW) { | 1250 bookmark_bar_state_ == BookmarkBar::SHOW) { |
1255 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1251 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
1256 } | 1252 } |
1257 } | 1253 } |
1258 | 1254 |
1259 /////////////////////////////////////////////////////////////////////////////// | 1255 /////////////////////////////////////////////////////////////////////////////// |
1260 // Browser, content::WebContentsDelegate implementation: | 1256 // Browser, content::WebContentsDelegate implementation: |
1261 | 1257 |
1262 WebContents* Browser::OpenURLFromTab(WebContents* source, | 1258 WebContents* Browser::OpenURLFromTab(WebContents* source, |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1902 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
1907 break; | 1903 break; |
1908 | 1904 |
1909 default: | 1905 default: |
1910 NOTREACHED() << "Got a notification we didn't register for."; | 1906 NOTREACHED() << "Got a notification we didn't register for."; |
1911 } | 1907 } |
1912 } | 1908 } |
1913 | 1909 |
1914 void Browser::ModeChanged(const chrome::search::Mode& old_mode, | 1910 void Browser::ModeChanged(const chrome::search::Mode& old_mode, |
1915 const chrome::search::Mode& new_mode) { | 1911 const chrome::search::Mode& new_mode) { |
1916 // If mode is transitioning from |NTP| to |SEARCH_SUGGESTIONS|, don't update | 1912 // If new mode is |SEARCH_SUGGESTIONS|, don't update bookmark bar state now; |
1917 // bookmark bar state now; wait till the instant preview is ready to show | 1913 // wait till the instant preview is ready to show suggestions before hiding |
1918 // suggestions before starting the animation to hide the bookmark bar (in | 1914 // the bookmark bar (in MaybeUpdateBookmarkBarStateForInstantPreview()). |
1919 // MaybeUpdateBookmarkBarStateForInstantPreview()). | 1915 // TODO(kuan): but for now, only delay updating bookmark bar state if origin |
| 1916 // is |DEFAULT|; other origins require more complex logic to be implemented |
| 1917 // to prevent jankiness caused by hiding bookmark bar, so just hide the |
| 1918 // bookmark bar immediately and tolerate the jankiness for a while. |
1920 // For other mode transitions, update bookmark bar state accordingly. | 1919 // For other mode transitions, update bookmark bar state accordingly. |
1921 if (old_mode.is_ntp() && new_mode.is_search_suggestions() && | 1920 if (new_mode.is_search_suggestions() && |
| 1921 new_mode.is_origin_default() && |
1922 bookmark_bar_state_ == BookmarkBar::SHOW) { | 1922 bookmark_bar_state_ == BookmarkBar::SHOW) { |
1923 return; | 1923 return; |
1924 } | 1924 } |
1925 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1925 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
1926 } | 1926 } |
1927 | 1927 |
1928 /////////////////////////////////////////////////////////////////////////////// | 1928 /////////////////////////////////////////////////////////////////////////////// |
1929 // Browser, Command and state updating (private): | 1929 // Browser, Command and state updating (private): |
1930 | 1930 |
1931 void Browser::OnDevToolsDisabledChanged() { | 1931 void Browser::OnDevToolsDisabledChanged() { |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2338 if (contents && !allow_js_access) { | 2338 if (contents && !allow_js_access) { |
2339 contents->web_contents()->GetController().LoadURL( | 2339 contents->web_contents()->GetController().LoadURL( |
2340 target_url, | 2340 target_url, |
2341 content::Referrer(), | 2341 content::Referrer(), |
2342 content::PAGE_TRANSITION_LINK, | 2342 content::PAGE_TRANSITION_LINK, |
2343 std::string()); // No extra headers. | 2343 std::string()); // No extra headers. |
2344 } | 2344 } |
2345 | 2345 |
2346 return contents != NULL; | 2346 return contents != NULL; |
2347 } | 2347 } |
OLD | NEW |