| 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 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1807 location_bar->UpdateContentSettingsIcons(); | 1793 location_bar->UpdateContentSettingsIcons(); |
| 1808 } | 1794 } |
| 1809 break; | 1795 break; |
| 1810 } | 1796 } |
| 1811 | 1797 |
| 1812 default: | 1798 default: |
| 1813 NOTREACHED() << "Got a notification we didn't register for."; | 1799 NOTREACHED() << "Got a notification we didn't register for."; |
| 1814 } | 1800 } |
| 1815 } | 1801 } |
| 1816 | 1802 |
| 1817 void Browser::ModeChanged(const chrome::search::Mode& old_mode, | 1803 void Browser::ModelChanged( |
| 1818 const chrome::search::Mode& new_mode) { | 1804 const chrome::search::SearchModel::State& old_state, |
| 1819 // If new mode is |SEARCH_SUGGESTIONS|, don't update bookmark bar state now; | 1805 const chrome::search::SearchModel::State& new_state) { |
| 1820 // wait till the Instant overlay is ready to show suggestions before hiding | 1806 if (chrome::search::SearchModel::ShouldChangeTopBarsVisibility(old_state, |
| 1821 // the bookmark bar (in MaybeUpdateBookmarkBarStateForInstantOverlay()). | 1807 new_state)) { |
| 1822 // TODO(kuan): but for now, only delay updating bookmark bar state if origin | 1808 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 1823 // is |DEFAULT|; other origins require more complex logic to be implemented | |
| 1824 // to prevent jankiness caused by hiding bookmark bar, so just hide the | |
| 1825 // bookmark bar immediately and tolerate the jankiness for a while. | |
| 1826 // For other mode transitions, update bookmark bar state accordingly. | |
| 1827 if (new_mode.is_search_suggestions() && | |
| 1828 new_mode.is_origin_default() && | |
| 1829 bookmark_bar_state_ == BookmarkBar::SHOW) { | |
| 1830 return; | |
| 1831 } | 1809 } |
| 1832 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | |
| 1833 } | 1810 } |
| 1834 | 1811 |
| 1835 /////////////////////////////////////////////////////////////////////////////// | 1812 /////////////////////////////////////////////////////////////////////////////// |
| 1836 // Browser, Command and state updating (private): | 1813 // Browser, Command and state updating (private): |
| 1837 | 1814 |
| 1838 void Browser::OnDevToolsDisabledChanged() { | 1815 void Browser::OnDevToolsDisabledChanged() { |
| 1839 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) | 1816 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) |
| 1840 content::DevToolsManager::GetInstance()->CloseAllClientHosts(); | 1817 content::DevToolsManager::GetInstance()->CloseAllClientHosts(); |
| 1841 } | 1818 } |
| 1842 | 1819 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2132 } else { | 2109 } else { |
| 2133 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); | 2110 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); |
| 2134 BookmarkTabHelper* bookmark_tab_helper = | 2111 BookmarkTabHelper* bookmark_tab_helper = |
| 2135 web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL; | 2112 web_contents ? BookmarkTabHelper::FromWebContents(web_contents) : NULL; |
| 2136 if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar()) | 2113 if (bookmark_tab_helper && bookmark_tab_helper->ShouldShowBookmarkBar()) |
| 2137 state = BookmarkBar::DETACHED; | 2114 state = BookmarkBar::DETACHED; |
| 2138 else | 2115 else |
| 2139 state = BookmarkBar::HIDDEN; | 2116 state = BookmarkBar::HIDDEN; |
| 2140 } | 2117 } |
| 2141 | 2118 |
| 2142 // Don't allow the bookmark bar to be shown in suggestions mode. | 2119 // Bookmark bar may need to be hidden for |SEARCH_SUGGESTIONS| and |
| 2120 // |SEARCH_RESULTS| modes as per SearchBox API or Instant overlay or if it's |
| 2121 // detached. |
| 2122 // TODO(sail): remove conditional MACOSX flag when bookmark bar is actually |
| 2123 // hidden on mac; for now, mac keeps the bookmark bar shown but changes its |
| 2124 // z-order to stack it below contents. |
| 2143 #if !defined(OS_MACOSX) | 2125 #if !defined(OS_MACOSX) |
| 2144 if (search_model_->mode().is_search_suggestions()) | 2126 if (search_model_->mode().is_search() && |
| 2127 (state == BookmarkBar::DETACHED || !search_model_->top_bars_visible())) { |
| 2145 state = BookmarkBar::HIDDEN; | 2128 state = BookmarkBar::HIDDEN; |
| 2146 #endif | 2129 } |
| 2147 | 2130 #else |
| 2148 // Don't allow detached bookmark bar to be shown in suggestions or results | 2131 // TODO(sail): remove this when the above block is enabled for mac. |
| 2149 // modes. | |
| 2150 if (state == BookmarkBar::DETACHED && search_model_->mode().is_search()) | 2132 if (state == BookmarkBar::DETACHED && search_model_->mode().is_search()) |
| 2151 state = BookmarkBar::HIDDEN; | 2133 state = BookmarkBar::HIDDEN; |
| 2134 #endif // !defined(OS_MACOSX) |
| 2152 | 2135 |
| 2153 if (state == bookmark_bar_state_) | 2136 if (state == bookmark_bar_state_) |
| 2154 return; | 2137 return; |
| 2155 | 2138 |
| 2156 bookmark_bar_state_ = state; | 2139 bookmark_bar_state_ = state; |
| 2157 | 2140 |
| 2158 if (!window_) | 2141 if (!window_) |
| 2159 return; // This is called from the constructor when window_ is NULL. | 2142 return; // This is called from the constructor when window_ is NULL. |
| 2160 | 2143 |
| 2161 if (reason == BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH) { | 2144 if (reason == BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2251 if (contents && !allow_js_access) { | 2234 if (contents && !allow_js_access) { |
| 2252 contents->web_contents()->GetController().LoadURL( | 2235 contents->web_contents()->GetController().LoadURL( |
| 2253 target_url, | 2236 target_url, |
| 2254 content::Referrer(), | 2237 content::Referrer(), |
| 2255 content::PAGE_TRANSITION_LINK, | 2238 content::PAGE_TRANSITION_LINK, |
| 2256 std::string()); // No extra headers. | 2239 std::string()); // No extra headers. |
| 2257 } | 2240 } |
| 2258 | 2241 |
| 2259 return contents != NULL; | 2242 return contents != NULL; |
| 2260 } | 2243 } |
| OLD | NEW |