| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "chrome/browser/download/download_shelf.h" | 52 #include "chrome/browser/download/download_shelf.h" |
| 53 #include "chrome/browser/extensions/browser_extension_window_controller.h" | 53 #include "chrome/browser/extensions/browser_extension_window_controller.h" |
| 54 #include "chrome/browser/extensions/extension_prefs.h" | 54 #include "chrome/browser/extensions/extension_prefs.h" |
| 55 #include "chrome/browser/extensions/extension_service.h" | 55 #include "chrome/browser/extensions/extension_service.h" |
| 56 #include "chrome/browser/extensions/extension_system.h" | 56 #include "chrome/browser/extensions/extension_system.h" |
| 57 #include "chrome/browser/extensions/tab_helper.h" | 57 #include "chrome/browser/extensions/tab_helper.h" |
| 58 #include "chrome/browser/favicon/favicon_tab_helper.h" | 58 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 59 #include "chrome/browser/file_select_helper.h" | 59 #include "chrome/browser/file_select_helper.h" |
| 60 #include "chrome/browser/first_run/first_run.h" | 60 #include "chrome/browser/first_run/first_run.h" |
| 61 #include "chrome/browser/google/google_url_tracker.h" | 61 #include "chrome/browser/google/google_url_tracker.h" |
| 62 #include "chrome/browser/instant/instant_controller.h" |
| 62 #include "chrome/browser/lifetime/application_lifetime.h" | 63 #include "chrome/browser/lifetime/application_lifetime.h" |
| 63 #include "chrome/browser/net/url_fixer_upper.h" | 64 #include "chrome/browser/net/url_fixer_upper.h" |
| 64 #include "chrome/browser/notifications/notification_ui_manager.h" | 65 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 65 #include "chrome/browser/pepper_broker_infobar_delegate.h" | 66 #include "chrome/browser/pepper_broker_infobar_delegate.h" |
| 66 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 67 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 67 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 68 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 68 #include "chrome/browser/profiles/profile.h" | 69 #include "chrome/browser/profiles/profile.h" |
| 69 #include "chrome/browser/profiles/profile_destroyer.h" | 70 #include "chrome/browser/profiles/profile_destroyer.h" |
| 70 #include "chrome/browser/profiles/profile_manager.h" | 71 #include "chrome/browser/profiles/profile_manager.h" |
| 71 #include "chrome/browser/profiles/profile_metrics.h" | 72 #include "chrome/browser/profiles/profile_metrics.h" |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 | 1001 |
| 1001 void Browser::TabDeactivated(WebContents* contents) { | 1002 void Browser::TabDeactivated(WebContents* contents) { |
| 1002 fullscreen_controller_->OnTabDeactivated(contents); | 1003 fullscreen_controller_->OnTabDeactivated(contents); |
| 1003 search_delegate_->OnTabDeactivated(contents); | 1004 search_delegate_->OnTabDeactivated(contents); |
| 1004 | 1005 |
| 1005 // Save what the user's currently typing, so it can be restored when we | 1006 // Save what the user's currently typing, so it can be restored when we |
| 1006 // switch back to this tab. | 1007 // switch back to this tab. |
| 1007 window_->GetLocationBar()->SaveStateToContents(contents); | 1008 window_->GetLocationBar()->SaveStateToContents(contents); |
| 1008 | 1009 |
| 1009 if (instant_controller_) | 1010 if (instant_controller_) |
| 1010 instant_controller_->TabDeactivated(contents); | 1011 instant_controller_->instant()->TabDeactivated(contents); |
| 1011 } | 1012 } |
| 1012 | 1013 |
| 1013 void Browser::ActiveTabChanged(WebContents* old_contents, | 1014 void Browser::ActiveTabChanged(WebContents* old_contents, |
| 1014 WebContents* new_contents, | 1015 WebContents* new_contents, |
| 1015 int index, | 1016 int index, |
| 1016 bool user_gesture) { | 1017 bool user_gesture) { |
| 1017 // On some platforms we want to automatically reload tabs that are | 1018 // On some platforms we want to automatically reload tabs that are |
| 1018 // killed when the user selects them. | 1019 // killed when the user selects them. |
| 1019 bool did_reload = false; | 1020 bool did_reload = false; |
| 1020 if (user_gesture && ShouldReloadCrashedTab(new_contents)) { | 1021 if (user_gesture && ShouldReloadCrashedTab(new_contents)) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 SessionServiceFactory::GetForProfileIfExisting(profile_); | 1073 SessionServiceFactory::GetForProfileIfExisting(profile_); |
| 1073 if (session_service && !tab_strip_model_->closing_all()) { | 1074 if (session_service && !tab_strip_model_->closing_all()) { |
| 1074 session_service->SetSelectedTabInWindow(session_id(), | 1075 session_service->SetSelectedTabInWindow(session_id(), |
| 1075 tab_strip_model_->active_index()); | 1076 tab_strip_model_->active_index()); |
| 1076 } | 1077 } |
| 1077 | 1078 |
| 1078 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); | 1079 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); |
| 1079 | 1080 |
| 1080 // This needs to be called after UpdateSearchState(). | 1081 // This needs to be called after UpdateSearchState(). |
| 1081 if (instant_controller_) | 1082 if (instant_controller_) |
| 1082 instant_controller_->ActiveTabChanged(); | 1083 instant_controller_->instant()->ActiveTabChanged(); |
| 1083 } | 1084 } |
| 1084 | 1085 |
| 1085 void Browser::TabMoved(WebContents* contents, | 1086 void Browser::TabMoved(WebContents* contents, |
| 1086 int from_index, | 1087 int from_index, |
| 1087 int to_index) { | 1088 int to_index) { |
| 1088 DCHECK(from_index >= 0 && to_index >= 0); | 1089 DCHECK(from_index >= 0 && to_index >= 0); |
| 1089 // Notify the history service. | 1090 // Notify the history service. |
| 1090 SyncHistoryWithTabs(std::min(from_index, to_index)); | 1091 SyncHistoryWithTabs(std::min(from_index, to_index)); |
| 1091 } | 1092 } |
| 1092 | 1093 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 GlobalErrorServiceFactory::GetForProfile(profile()); | 1217 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 1217 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 1218 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 1218 if (error) | 1219 if (error) |
| 1219 error->ShowBubbleView(this); | 1220 error->ShowBubbleView(this); |
| 1220 } | 1221 } |
| 1221 | 1222 |
| 1222 void Browser::ShowFirstRunBubble() { | 1223 void Browser::ShowFirstRunBubble() { |
| 1223 window()->GetLocationBar()->ShowFirstRunBubble(); | 1224 window()->GetLocationBar()->ShowFirstRunBubble(); |
| 1224 } | 1225 } |
| 1225 | 1226 |
| 1226 void Browser::MaybeUpdateBookmarkBarStateForInstantOverlay( | 1227 void Browser::MaybeUpdateBookmarkBarStateForInstantOverlay() { |
| 1227 const chrome::search::Mode& mode) { | |
| 1228 // This is invoked by a platform-specific implementation of | 1228 // This is invoked by a platform-specific implementation of |
| 1229 // |InstantOverlayController| to update bookmark bar state according to | 1229 // |InstantOverlayController| to update bookmark bar state according to |
| 1230 // Instant overlay state. | 1230 // Instant overlay state. |
| 1231 // ModeChanged() updates bookmark bar state for all mode transitions except | 1231 // ModeChanged() updates bookmark bar state for all mode transitions except |
| 1232 // when new mode is |SEARCH_SUGGESTIONS|, because that needs to be done when | 1232 // when new mode is |SEARCH_SUGGESTIONS|, because that needs to be done when |
| 1233 // the suggestions are ready. | 1233 // the suggestions are ready. |
| 1234 if (mode.is_search_suggestions() && | 1234 if (bookmark_bar_state_ == BookmarkBar::SHOW) |
| 1235 bookmark_bar_state_ == BookmarkBar::SHOW) { | |
| 1236 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1235 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 1237 } | |
| 1238 } | 1236 } |
| 1239 | 1237 |
| 1240 void Browser::ShowDownload(content::DownloadItem* download) { | 1238 void Browser::ShowDownload(content::DownloadItem* download) { |
| 1241 if (!window()) | 1239 if (!window()) |
| 1242 return; | 1240 return; |
| 1243 | 1241 |
| 1244 // If the download occurs in a new tab, and it's not a save page | 1242 // If the download occurs in a new tab, and it's not a save page |
| 1245 // download (started before initial navigation completed) close it. | 1243 // download (started before initial navigation completed) close it. |
| 1246 WebContents* source = download->GetWebContents(); | 1244 WebContents* source = download->GetWebContents(); |
| 1247 if (source && source->GetController().IsInitialNavigation() && | 1245 if (source && source->GetController().IsInitialNavigation() && |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 // is |DEFAULT|; other origins require more complex logic to be implemented | 1817 // is |DEFAULT|; other origins require more complex logic to be implemented |
| 1820 // to prevent jankiness caused by hiding bookmark bar, so just hide the | 1818 // to prevent jankiness caused by hiding bookmark bar, so just hide the |
| 1821 // bookmark bar immediately and tolerate the jankiness for a while. | 1819 // bookmark bar immediately and tolerate the jankiness for a while. |
| 1822 // For other mode transitions, update bookmark bar state accordingly. | 1820 // For other mode transitions, update bookmark bar state accordingly. |
| 1823 if (new_mode.is_search_suggestions() && | 1821 if (new_mode.is_search_suggestions() && |
| 1824 new_mode.is_origin_default() && | 1822 new_mode.is_origin_default() && |
| 1825 bookmark_bar_state_ == BookmarkBar::SHOW) { | 1823 bookmark_bar_state_ == BookmarkBar::SHOW) { |
| 1826 return; | 1824 return; |
| 1827 } | 1825 } |
| 1828 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1826 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 1827 |
| 1828 if (instant_controller_) |
| 1829 instant_controller_->instant()->SearchModeChanged(old_mode, new_mode); |
| 1829 } | 1830 } |
| 1830 | 1831 |
| 1831 /////////////////////////////////////////////////////////////////////////////// | 1832 /////////////////////////////////////////////////////////////////////////////// |
| 1832 // Browser, Command and state updating (private): | 1833 // Browser, Command and state updating (private): |
| 1833 | 1834 |
| 1834 void Browser::OnDevToolsDisabledChanged() { | 1835 void Browser::OnDevToolsDisabledChanged() { |
| 1835 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) | 1836 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) |
| 1836 content::DevToolsManager::GetInstance()->CloseAllClientHosts(); | 1837 content::DevToolsManager::GetInstance()->CloseAllClientHosts(); |
| 1837 } | 1838 } |
| 1838 | 1839 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 if (contents && !allow_js_access) { | 2243 if (contents && !allow_js_access) { |
| 2243 contents->web_contents()->GetController().LoadURL( | 2244 contents->web_contents()->GetController().LoadURL( |
| 2244 target_url, | 2245 target_url, |
| 2245 content::Referrer(), | 2246 content::Referrer(), |
| 2246 content::PAGE_TRANSITION_LINK, | 2247 content::PAGE_TRANSITION_LINK, |
| 2247 std::string()); // No extra headers. | 2248 std::string()); // No extra headers. |
| 2248 } | 2249 } |
| 2249 | 2250 |
| 2250 return contents != NULL; | 2251 return contents != NULL; |
| 2251 } | 2252 } |
| OLD | NEW |