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

Unified Diff: chrome/browser/ui/browser.cc

Issue 23536075: Fix multiple problems with omnibox text handling across focus changes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser.cc
===================================================================
--- chrome/browser/ui/browser.cc (revision 224205)
+++ chrome/browser/ui/browser.cc (working copy)
@@ -1047,71 +1047,6 @@
instant_controller_->TabDeactivated(contents);
}
-void Browser::ActiveTabChanged(WebContents* old_contents,
- WebContents* new_contents,
- int index,
- int reason) {
- content::RecordAction(UserMetricsAction("ActiveTabChanged"));
-
- // Discarded tabs always get reloaded.
- if (tab_strip_model_->IsTabDiscarded(index)) {
- LOG(WARNING) << "Reloading discarded tab at " << index;
- static int reload_count = 0;
- UMA_HISTOGRAM_CUSTOM_COUNTS(
- "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50);
- chrome::Reload(this, CURRENT_TAB);
- }
-
- // If we have any update pending, do it now.
- if (chrome_updater_factory_.HasWeakPtrs() && old_contents)
- ProcessPendingUIUpdates();
-
- // Propagate the profile to the location bar.
- UpdateToolbar((reason & CHANGE_REASON_REPLACED) == 0);
-
- // Propagate tab state to toolbar, tab-strip, etc.
- UpdateSearchState(new_contents);
-
- // Update reload/stop state.
- command_controller_->LoadingStateChanged(new_contents->IsLoading(), true);
-
- // Update commands to reflect current state.
- command_controller_->TabStateChanged();
-
- // Reset the status bubble.
- StatusBubble* status_bubble = GetStatusBubble();
- if (status_bubble) {
- status_bubble->Hide();
-
- // Show the loading state (if any).
- status_bubble->SetStatus(CoreTabHelper::FromWebContents(
- tab_strip_model_->GetActiveWebContents())->GetStatusText());
- }
-
- if (HasFindBarController()) {
- find_bar_controller_->ChangeWebContents(new_contents);
- find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true);
- }
-
- // Update sessions. Don't force creation of sessions. If sessions doesn't
- // exist, the change will be picked up by sessions when created.
- SessionService* session_service =
- SessionServiceFactory::GetForProfileIfExisting(profile_);
- if (session_service && !tab_strip_model_->closing_all()) {
- session_service->SetSelectedTabInWindow(session_id(),
- tab_strip_model_->active_index());
- }
-
- UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH);
-
- // This needs to be called after UpdateSearchState().
- if (instant_controller_)
- instant_controller_->ActiveTabChanged();
-
- autofill::TabAutofillManagerDelegate::FromWebContents(new_contents)->
- TabActivated(reason);
-}
-
void Browser::TabMoved(WebContents* contents,
int from_index,
int to_index) {
@@ -1177,6 +1112,71 @@
instant_controller_.reset();
}
+void Browser::OnActiveTabChanged(WebContents* old_contents,
+ WebContents* new_contents,
+ int index,
+ int reason) {
+ content::RecordAction(UserMetricsAction("ActiveTabChanged"));
+
+ // Discarded tabs always get reloaded.
+ if (tab_strip_model_->IsTabDiscarded(index)) {
+ LOG(WARNING) << "Reloading discarded tab at " << index;
+ static int reload_count = 0;
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50);
+ chrome::Reload(this, CURRENT_TAB);
+ }
+
+ // If we have any update pending, do it now.
+ if (chrome_updater_factory_.HasWeakPtrs() && old_contents)
+ ProcessPendingUIUpdates();
+
+ // Propagate the profile to the location bar.
+ UpdateToolbar((reason & CHANGE_REASON_REPLACED) == 0);
+
+ // Propagate tab state to toolbar, tab-strip, etc.
+ UpdateSearchState(new_contents);
+
+ // Update reload/stop state.
+ command_controller_->LoadingStateChanged(new_contents->IsLoading(), true);
+
+ // Update commands to reflect current state.
+ command_controller_->TabStateChanged();
+
+ // Reset the status bubble.
+ StatusBubble* status_bubble = GetStatusBubble();
+ if (status_bubble) {
+ status_bubble->Hide();
+
+ // Show the loading state (if any).
+ status_bubble->SetStatus(CoreTabHelper::FromWebContents(
+ tab_strip_model_->GetActiveWebContents())->GetStatusText());
+ }
+
+ if (HasFindBarController()) {
+ find_bar_controller_->ChangeWebContents(new_contents);
+ find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true);
+ }
+
+ // Update sessions. Don't force creation of sessions. If sessions doesn't
+ // exist, the change will be picked up by sessions when created.
+ SessionService* session_service =
+ SessionServiceFactory::GetForProfileIfExisting(profile_);
+ if (session_service && !tab_strip_model_->closing_all()) {
+ session_service->SetSelectedTabInWindow(session_id(),
+ tab_strip_model_->active_index());
+ }
+
+ UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH);
+
+ // This needs to be called after UpdateSearchState().
+ if (instant_controller_)
+ instant_controller_->ActiveTabChanged();
+
+ autofill::TabAutofillManagerDelegate::FromWebContents(new_contents)->
+ TabActivated(reason);
+}
+
bool Browser::CanOverscrollContent() const {
#if defined(USE_AURA)
bool overscroll_enabled = CommandLine::ForCurrentProcess()->

Powered by Google App Engine
This is Rietveld 408576698