| 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 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 if (instant_controller_) | 1046 if (instant_controller_) |
| 1047 instant_controller_->TabDeactivated(contents); | 1047 instant_controller_->TabDeactivated(contents); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 void Browser::ActiveTabChanged(WebContents* old_contents, | 1050 void Browser::ActiveTabChanged(WebContents* old_contents, |
| 1051 WebContents* new_contents, | 1051 WebContents* new_contents, |
| 1052 int index, | 1052 int index, |
| 1053 int reason) { | 1053 int reason) { |
| 1054 content::RecordAction(UserMetricsAction("ActiveTabChanged")); | 1054 content::RecordAction(UserMetricsAction("ActiveTabChanged")); |
| 1055 | 1055 |
| 1056 // Switch the find bar to the new tab if necessary. This must be done before |
| 1057 // changing focus for unittests to pass. |
| 1058 // TODO(pkasting): http://crbug.com/297385 Move this to near the end of this |
| 1059 // function (where it used to be) once the find bar properly restores |
| 1060 // selections across tab changes. |
| 1061 if (HasFindBarController()) { |
| 1062 find_bar_controller_->ChangeWebContents(new_contents); |
| 1063 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); |
| 1064 } |
| 1065 |
| 1066 // Let the BrowserWindow do its handling. On e.g. views this changes the |
| 1067 // focused object, which should happen before we update the toolbar below, |
| 1068 // since the omnibox expects the correct element to already be focused when it |
| 1069 // is updated. |
| 1070 window_->OnActiveTabChanged(old_contents, new_contents, index, reason); |
| 1071 |
| 1056 // Discarded tabs always get reloaded. | 1072 // Discarded tabs always get reloaded. |
| 1057 if (tab_strip_model_->IsTabDiscarded(index)) { | 1073 if (tab_strip_model_->IsTabDiscarded(index)) { |
| 1058 LOG(WARNING) << "Reloading discarded tab at " << index; | 1074 LOG(WARNING) << "Reloading discarded tab at " << index; |
| 1059 static int reload_count = 0; | 1075 static int reload_count = 0; |
| 1060 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1076 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1061 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); | 1077 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); |
| 1062 chrome::Reload(this, CURRENT_TAB); | 1078 chrome::Reload(this, CURRENT_TAB); |
| 1063 } | 1079 } |
| 1064 | 1080 |
| 1065 // If we have any update pending, do it now. | 1081 // If we have any update pending, do it now. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1081 // Reset the status bubble. | 1097 // Reset the status bubble. |
| 1082 StatusBubble* status_bubble = GetStatusBubble(); | 1098 StatusBubble* status_bubble = GetStatusBubble(); |
| 1083 if (status_bubble) { | 1099 if (status_bubble) { |
| 1084 status_bubble->Hide(); | 1100 status_bubble->Hide(); |
| 1085 | 1101 |
| 1086 // Show the loading state (if any). | 1102 // Show the loading state (if any). |
| 1087 status_bubble->SetStatus(CoreTabHelper::FromWebContents( | 1103 status_bubble->SetStatus(CoreTabHelper::FromWebContents( |
| 1088 tab_strip_model_->GetActiveWebContents())->GetStatusText()); | 1104 tab_strip_model_->GetActiveWebContents())->GetStatusText()); |
| 1089 } | 1105 } |
| 1090 | 1106 |
| 1091 if (HasFindBarController()) { | |
| 1092 find_bar_controller_->ChangeWebContents(new_contents); | |
| 1093 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | |
| 1094 } | |
| 1095 | |
| 1096 // Update sessions. Don't force creation of sessions. If sessions doesn't | 1107 // Update sessions. Don't force creation of sessions. If sessions doesn't |
| 1097 // exist, the change will be picked up by sessions when created. | 1108 // exist, the change will be picked up by sessions when created. |
| 1098 SessionService* session_service = | 1109 SessionService* session_service = |
| 1099 SessionServiceFactory::GetForProfileIfExisting(profile_); | 1110 SessionServiceFactory::GetForProfileIfExisting(profile_); |
| 1100 if (session_service && !tab_strip_model_->closing_all()) { | 1111 if (session_service && !tab_strip_model_->closing_all()) { |
| 1101 session_service->SetSelectedTabInWindow(session_id(), | 1112 session_service->SetSelectedTabInWindow(session_id(), |
| 1102 tab_strip_model_->active_index()); | 1113 tab_strip_model_->active_index()); |
| 1103 } | 1114 } |
| 1104 | 1115 |
| 1105 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); | 1116 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2292 if (contents && !allow_js_access) { | 2303 if (contents && !allow_js_access) { |
| 2293 contents->web_contents()->GetController().LoadURL( | 2304 contents->web_contents()->GetController().LoadURL( |
| 2294 target_url, | 2305 target_url, |
| 2295 content::Referrer(), | 2306 content::Referrer(), |
| 2296 content::PAGE_TRANSITION_LINK, | 2307 content::PAGE_TRANSITION_LINK, |
| 2297 std::string()); // No extra headers. | 2308 std::string()); // No extra headers. |
| 2298 } | 2309 } |
| 2299 | 2310 |
| 2300 return contents != NULL; | 2311 return contents != NULL; |
| 2301 } | 2312 } |
| OLD | NEW |