| 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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 if (instant_controller_) | 1041 if (instant_controller_) |
| 1042 instant_controller_->TabDeactivated(contents); | 1042 instant_controller_->TabDeactivated(contents); |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 void Browser::ActiveTabChanged(WebContents* old_contents, | 1045 void Browser::ActiveTabChanged(WebContents* old_contents, |
| 1046 WebContents* new_contents, | 1046 WebContents* new_contents, |
| 1047 int index, | 1047 int index, |
| 1048 int reason) { | 1048 int reason) { |
| 1049 content::RecordAction(UserMetricsAction("ActiveTabChanged")); | 1049 content::RecordAction(UserMetricsAction("ActiveTabChanged")); |
| 1050 | 1050 |
| 1051 // First let the BrowserWindow do its handling. On e.g. views this changes | 1051 // Update the bookmark state, since the BrowserWindow may query it during |
| 1052 // the focused object, which should happen before we update the toolbar below, | 1052 // OnActiveTabChanged() below. |
| 1053 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); |
| 1054 |
| 1055 // Let the BrowserWindow do its handling. On e.g. views this changes the |
| 1056 // focused object, which should happen before we update the toolbar below, |
| 1053 // since the omnibox expects the correct element to already be focused when it | 1057 // since the omnibox expects the correct element to already be focused when it |
| 1054 // is updated. | 1058 // is updated. |
| 1055 window_->OnActiveTabChanged(old_contents, new_contents, index, reason); | 1059 window_->OnActiveTabChanged(old_contents, new_contents, index, reason); |
| 1056 | 1060 |
| 1057 // Discarded tabs always get reloaded. | 1061 // Discarded tabs always get reloaded. |
| 1058 if (tab_strip_model_->IsTabDiscarded(index)) { | 1062 if (tab_strip_model_->IsTabDiscarded(index)) { |
| 1059 LOG(WARNING) << "Reloading discarded tab at " << index; | 1063 LOG(WARNING) << "Reloading discarded tab at " << index; |
| 1060 static int reload_count = 0; | 1064 static int reload_count = 0; |
| 1061 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1065 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1062 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); | 1066 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 | 1100 |
| 1097 // Update sessions. Don't force creation of sessions. If sessions doesn't | 1101 // Update sessions. Don't force creation of sessions. If sessions doesn't |
| 1098 // exist, the change will be picked up by sessions when created. | 1102 // exist, the change will be picked up by sessions when created. |
| 1099 SessionService* session_service = | 1103 SessionService* session_service = |
| 1100 SessionServiceFactory::GetForProfileIfExisting(profile_); | 1104 SessionServiceFactory::GetForProfileIfExisting(profile_); |
| 1101 if (session_service && !tab_strip_model_->closing_all()) { | 1105 if (session_service && !tab_strip_model_->closing_all()) { |
| 1102 session_service->SetSelectedTabInWindow(session_id(), | 1106 session_service->SetSelectedTabInWindow(session_id(), |
| 1103 tab_strip_model_->active_index()); | 1107 tab_strip_model_->active_index()); |
| 1104 } | 1108 } |
| 1105 | 1109 |
| 1106 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); | |
| 1107 | |
| 1108 // This needs to be called after UpdateSearchState(). | 1110 // This needs to be called after UpdateSearchState(). |
| 1109 if (instant_controller_) | 1111 if (instant_controller_) |
| 1110 instant_controller_->ActiveTabChanged(); | 1112 instant_controller_->ActiveTabChanged(); |
| 1111 | 1113 |
| 1112 autofill::TabAutofillManagerDelegate::FromWebContents(new_contents)-> | 1114 autofill::TabAutofillManagerDelegate::FromWebContents(new_contents)-> |
| 1113 TabActivated(reason); | 1115 TabActivated(reason); |
| 1114 } | 1116 } |
| 1115 | 1117 |
| 1116 void Browser::TabMoved(WebContents* contents, | 1118 void Browser::TabMoved(WebContents* contents, |
| 1117 int from_index, | 1119 int from_index, |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2293 if (contents && !allow_js_access) { | 2295 if (contents && !allow_js_access) { |
| 2294 contents->web_contents()->GetController().LoadURL( | 2296 contents->web_contents()->GetController().LoadURL( |
| 2295 target_url, | 2297 target_url, |
| 2296 content::Referrer(), | 2298 content::Referrer(), |
| 2297 content::PAGE_TRANSITION_LINK, | 2299 content::PAGE_TRANSITION_LINK, |
| 2298 std::string()); // No extra headers. | 2300 std::string()); // No extra headers. |
| 2299 } | 2301 } |
| 2300 | 2302 |
| 2301 return contents != NULL; | 2303 return contents != NULL; |
| 2302 } | 2304 } |
| OLD | NEW |