Chromium Code Reviews| 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 // First, determine the new bookmark state, so that it can be queried by |
| 1052 // the focused object, which should happen before we update the toolbar below, | 1052 // BrowserWindow::BookmarkBarStateChanged() when it's invoked from |
| 1053 // BrowserWindow::OnActiveTabChanged() below. | |
| 1054 // Note that UpdateBookmarkBarState() won't invoke | |
| 1055 // BrowserWindow::BookmarkBarStateChanged() for | |
| 1056 // BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH reason. | |
|
Peter Kasting
2013/10/01 20:44:11
Nit: Can we just say:
Update the bookmark bar sta
kuan
2013/10/02 00:15:37
Done.
| |
| 1057 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); | |
| 1058 | |
| 1059 // Let the BrowserWindow do its handling. On e.g. views this changes the | |
| 1060 // 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 | 1061 // since the omnibox expects the correct element to already be focused when it |
| 1054 // is updated. | 1062 // is updated. |
| 1055 window_->OnActiveTabChanged(old_contents, new_contents, index, reason); | 1063 window_->OnActiveTabChanged(old_contents, new_contents, index, reason); |
| 1056 | 1064 |
| 1057 // Discarded tabs always get reloaded. | 1065 // Discarded tabs always get reloaded. |
| 1058 if (tab_strip_model_->IsTabDiscarded(index)) { | 1066 if (tab_strip_model_->IsTabDiscarded(index)) { |
| 1059 LOG(WARNING) << "Reloading discarded tab at " << index; | 1067 LOG(WARNING) << "Reloading discarded tab at " << index; |
| 1060 static int reload_count = 0; | 1068 static int reload_count = 0; |
| 1061 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1069 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1062 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); | 1070 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 | 1104 |
| 1097 // Update sessions. Don't force creation of sessions. If sessions doesn't | 1105 // Update sessions. Don't force creation of sessions. If sessions doesn't |
| 1098 // exist, the change will be picked up by sessions when created. | 1106 // exist, the change will be picked up by sessions when created. |
| 1099 SessionService* session_service = | 1107 SessionService* session_service = |
| 1100 SessionServiceFactory::GetForProfileIfExisting(profile_); | 1108 SessionServiceFactory::GetForProfileIfExisting(profile_); |
| 1101 if (session_service && !tab_strip_model_->closing_all()) { | 1109 if (session_service && !tab_strip_model_->closing_all()) { |
| 1102 session_service->SetSelectedTabInWindow(session_id(), | 1110 session_service->SetSelectedTabInWindow(session_id(), |
| 1103 tab_strip_model_->active_index()); | 1111 tab_strip_model_->active_index()); |
| 1104 } | 1112 } |
| 1105 | 1113 |
| 1106 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); | |
| 1107 | |
| 1108 // This needs to be called after UpdateSearchState(). | 1114 // This needs to be called after UpdateSearchState(). |
| 1109 if (instant_controller_) | 1115 if (instant_controller_) |
| 1110 instant_controller_->ActiveTabChanged(); | 1116 instant_controller_->ActiveTabChanged(); |
| 1111 | 1117 |
| 1112 autofill::TabAutofillManagerDelegate::FromWebContents(new_contents)-> | 1118 autofill::TabAutofillManagerDelegate::FromWebContents(new_contents)-> |
| 1113 TabActivated(reason); | 1119 TabActivated(reason); |
| 1114 } | 1120 } |
| 1115 | 1121 |
| 1116 void Browser::TabMoved(WebContents* contents, | 1122 void Browser::TabMoved(WebContents* contents, |
| 1117 int from_index, | 1123 int from_index, |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2293 if (contents && !allow_js_access) { | 2299 if (contents && !allow_js_access) { |
| 2294 contents->web_contents()->GetController().LoadURL( | 2300 contents->web_contents()->GetController().LoadURL( |
| 2295 target_url, | 2301 target_url, |
| 2296 content::Referrer(), | 2302 content::Referrer(), |
| 2297 content::PAGE_TRANSITION_LINK, | 2303 content::PAGE_TRANSITION_LINK, |
| 2298 std::string()); // No extra headers. | 2304 std::string()); // No extra headers. |
| 2299 } | 2305 } |
| 2300 | 2306 |
| 2301 return contents != NULL; | 2307 return contents != NULL; |
| 2302 } | 2308 } |
| OLD | NEW |