Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 11364196: Remove TabContents from TabStripModelObserver::ActiveTabChanged. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_instant_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1061
1062 void Browser::TabDeactivated(WebContents* contents) { 1062 void Browser::TabDeactivated(WebContents* contents) {
1063 fullscreen_controller_->OnTabDeactivated(contents); 1063 fullscreen_controller_->OnTabDeactivated(contents);
1064 search_delegate_->OnTabDeactivated(contents); 1064 search_delegate_->OnTabDeactivated(contents);
1065 1065
1066 // Save what the user's currently typing, so it can be restored when we 1066 // Save what the user's currently typing, so it can be restored when we
1067 // switch back to this tab. 1067 // switch back to this tab.
1068 window_->GetLocationBar()->SaveStateToContents(contents); 1068 window_->GetLocationBar()->SaveStateToContents(contents);
1069 } 1069 }
1070 1070
1071 void Browser::ActiveTabChanged(TabContents* old_contents, 1071 void Browser::ActiveTabChanged(WebContents* old_contents,
1072 TabContents* new_contents, 1072 WebContents* new_contents,
1073 int index, 1073 int index,
1074 bool user_gesture) { 1074 bool user_gesture) {
1075 // On some platforms we want to automatically reload tabs that are 1075 // On some platforms we want to automatically reload tabs that are
1076 // killed when the user selects them. 1076 // killed when the user selects them.
1077 bool did_reload = false; 1077 bool did_reload = false;
1078 if (user_gesture && ShouldReloadCrashedTab(new_contents->web_contents())) { 1078 if (user_gesture && ShouldReloadCrashedTab(new_contents)) {
1079 LOG(WARNING) << "Reloading killed tab at " << index; 1079 LOG(WARNING) << "Reloading killed tab at " << index;
1080 static int reload_count = 0; 1080 static int reload_count = 0;
1081 UMA_HISTOGRAM_CUSTOM_COUNTS( 1081 UMA_HISTOGRAM_CUSTOM_COUNTS(
1082 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); 1082 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50);
1083 chrome::Reload(this, CURRENT_TAB); 1083 chrome::Reload(this, CURRENT_TAB);
1084 did_reload = true; 1084 did_reload = true;
1085 } 1085 }
1086 1086
1087 // Discarded tabs always get reloaded. 1087 // Discarded tabs always get reloaded.
1088 if (!did_reload && tab_strip_model_->IsTabDiscarded(index)) { 1088 if (!did_reload && tab_strip_model_->IsTabDiscarded(index)) {
1089 LOG(WARNING) << "Reloading discarded tab at " << index; 1089 LOG(WARNING) << "Reloading discarded tab at " << index;
1090 static int reload_count = 0; 1090 static int reload_count = 0;
1091 UMA_HISTOGRAM_CUSTOM_COUNTS( 1091 UMA_HISTOGRAM_CUSTOM_COUNTS(
1092 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); 1092 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50);
1093 chrome::Reload(this, CURRENT_TAB); 1093 chrome::Reload(this, CURRENT_TAB);
1094 } 1094 }
1095 1095
1096 // If we have any update pending, do it now. 1096 // If we have any update pending, do it now.
1097 if (chrome_updater_factory_.HasWeakPtrs() && old_contents) 1097 if (chrome_updater_factory_.HasWeakPtrs() && old_contents)
1098 ProcessPendingUIUpdates(); 1098 ProcessPendingUIUpdates();
1099 1099
1100 // Propagate the profile to the location bar. 1100 // Propagate the profile to the location bar.
1101 UpdateToolbar(true); 1101 UpdateToolbar(true);
1102 1102
1103 // Propagate tab state to toolbar, tab-strip, etc. 1103 // Propagate tab state to toolbar, tab-strip, etc.
1104 UpdateSearchState(new_contents); 1104 UpdateSearchState(new_contents);
1105 1105
1106 // Update reload/stop state. 1106 // Update reload/stop state.
1107 command_controller_->LoadingStateChanged( 1107 command_controller_->LoadingStateChanged(new_contents->IsLoading(), true);
1108 new_contents->web_contents()->IsLoading(), true);
1109 1108
1110 // Update commands to reflect current state. 1109 // Update commands to reflect current state.
1111 command_controller_->TabStateChanged(); 1110 command_controller_->TabStateChanged();
1112 1111
1113 // Reset the status bubble. 1112 // Reset the status bubble.
1114 StatusBubble* status_bubble = GetStatusBubble(); 1113 StatusBubble* status_bubble = GetStatusBubble();
1115 if (status_bubble) { 1114 if (status_bubble) {
1116 status_bubble->Hide(); 1115 status_bubble->Hide();
1117 1116
1118 // Show the loading state (if any). 1117 // Show the loading state (if any).
1119 status_bubble->SetStatus( 1118 status_bubble->SetStatus(
1120 CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))-> 1119 CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))->
1121 GetStatusText()); 1120 GetStatusText());
1122 } 1121 }
1123 1122
1124 if (HasFindBarController()) { 1123 if (HasFindBarController()) {
1125 find_bar_controller_->ChangeWebContents(new_contents->web_contents()); 1124 find_bar_controller_->ChangeWebContents(new_contents);
1126 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); 1125 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true);
1127 } 1126 }
1128 1127
1129 // Update sessions. Don't force creation of sessions. If sessions doesn't 1128 // Update sessions. Don't force creation of sessions. If sessions doesn't
1130 // exist, the change will be picked up by sessions when created. 1129 // exist, the change will be picked up by sessions when created.
1131 SessionService* session_service = 1130 SessionService* session_service =
1132 SessionServiceFactory::GetForProfileIfExisting(profile_); 1131 SessionServiceFactory::GetForProfileIfExisting(profile_);
1133 if (session_service && !tab_strip_model_->closing_all()) { 1132 if (session_service && !tab_strip_model_->closing_all()) {
1134 session_service->SetSelectedTabInWindow(session_id(), active_index()); 1133 session_service->SetSelectedTabInWindow(session_id(), active_index());
1135 } 1134 }
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 } 1961 }
1963 1962
1964 /////////////////////////////////////////////////////////////////////////////// 1963 ///////////////////////////////////////////////////////////////////////////////
1965 // Browser, UI update coalescing and handling (private): 1964 // Browser, UI update coalescing and handling (private):
1966 1965
1967 void Browser::UpdateToolbar(bool should_restore_state) { 1966 void Browser::UpdateToolbar(bool should_restore_state) {
1968 window_->UpdateToolbar(chrome::GetActiveTabContents(this), 1967 window_->UpdateToolbar(chrome::GetActiveTabContents(this),
1969 should_restore_state); 1968 should_restore_state);
1970 } 1969 }
1971 1970
1972 void Browser::UpdateSearchState(TabContents* contents) { 1971 void Browser::UpdateSearchState(WebContents* contents) {
1973 if (chrome::search::IsInstantExtendedAPIEnabled(profile_)) 1972 if (chrome::search::IsInstantExtendedAPIEnabled(profile_))
1974 search_delegate_->OnTabActivated(contents->web_contents()); 1973 search_delegate_->OnTabActivated(contents);
1975 } 1974 }
1976 1975
1977 void Browser::ScheduleUIUpdate(const WebContents* source, 1976 void Browser::ScheduleUIUpdate(const WebContents* source,
1978 unsigned changed_flags) { 1977 unsigned changed_flags) {
1979 if (!source) 1978 if (!source)
1980 return; 1979 return;
1981 1980
1982 // Do some synchronous updates. 1981 // Do some synchronous updates.
1983 if (changed_flags & content::INVALIDATE_TYPE_URL && 1982 if (changed_flags & content::INVALIDATE_TYPE_URL &&
1984 source == chrome::GetActiveWebContents(this)) { 1983 source == chrome::GetActiveWebContents(this)) {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 if (contents && !allow_js_access) { 2344 if (contents && !allow_js_access) {
2346 contents->web_contents()->GetController().LoadURL( 2345 contents->web_contents()->GetController().LoadURL(
2347 target_url, 2346 target_url,
2348 content::Referrer(), 2347 content::Referrer(),
2349 content::PAGE_TRANSITION_LINK, 2348 content::PAGE_TRANSITION_LINK,
2350 std::string()); // No extra headers. 2349 std::string()); // No extra headers.
2351 } 2350 }
2352 2351
2353 return contents != NULL; 2352 return contents != NULL;
2354 } 2353 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_instant_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698