Index: chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc |
diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc |
index 3fd204f9917c84592fb7aa8e0569d9aaf838a51b..e8901c677391faa6dbdd1db3d349d4e85c9b9216 100644 |
--- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc |
+++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc |
@@ -12,6 +12,9 @@ |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/search/search.h" |
+#include "chrome/browser/ui/search/search_delegate.h" |
+#include "chrome/browser/ui/search/search_model.h" |
#include "chrome/browser/ui/tab_contents/tab_contents.h" |
#include "chrome/browser/ui/tabs/tab_menu_model.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
@@ -166,6 +169,8 @@ BrowserTabStripController::BrowserTabStripController(Browser* browser, |
browser_(browser), |
hover_tab_selector_(model) { |
model_->AddObserver(this); |
+ browser_->search_model()->AddObserver(this); |
+ browser_->search_delegate()->toolbar_search_animator().AddObserver(this); |
local_pref_registrar_.Init(g_browser_process->local_state()); |
local_pref_registrar_.Add(prefs::kTabStripLayoutType, this); |
@@ -179,6 +184,8 @@ BrowserTabStripController::~BrowserTabStripController() { |
context_menu_contents_->Cancel(); |
model_->RemoveObserver(this); |
+ browser_->search_delegate()->toolbar_search_animator().RemoveObserver(this); |
+ browser_->search_model()->RemoveObserver(this); |
} |
void BrowserTabStripController::InitFromModel(TabStrip* tabstrip) { |
@@ -433,6 +440,48 @@ void BrowserTabStripController::TabBlockedStateChanged( |
} |
//////////////////////////////////////////////////////////////////////////////// |
+// BrowserTabStripController, chrome::search::SearchModelObserver: |
+ |
+void BrowserTabStripController::ModeChanged(const chrome::search::Mode& mode) { |
+ // Mode has changed, set tab data based on new mode, which will trigger |
+ // repainting of tab's background. |
+ int active_index = GetActiveIndex(); |
+ DCHECK_NE(active_index, -1); |
+ SetTabDataAt(browser_->GetTabContentsAt(active_index), active_index); |
+} |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// BrowserTabStripController, chrome::search::ToolbarSearchAnimator::Observer: |
+ |
+void BrowserTabStripController::OnToolbarBackgroundAnimatorProgressed() { |
+ // We're fading in the tab background, set tab data based on new background |
+ // state and possibly opacity value, which will trigger repainting of tab's |
+ // background. |
+ int active_index = GetActiveIndex(); |
+ DCHECK_NE(active_index, -1); |
+ SetTabDataAt(browser_->GetTabContentsAt(active_index), active_index); |
+} |
+ |
+void BrowserTabStripController::OnToolbarBackgroundAnimatorCanceled( |
+ TabContents* tab_contents) { |
+ // Fade in of tab background has been canceled, which can happen in 2 |
+ // scenarios: |
+ // 1) a deactivated or detached or closing tab, whose |tab_contents| is the |
+ // the formal parameter: make sure |tab_contents| still exist in tab model. |
+ // 2) mode change of active tab, as indicated by a NULL |tab_contents|: make |
+ // sure active tab exists, and retrieve its |tab_contents|. |
+ // If we proceed, set tab data so that |TabRendererData::background_state| and |
+ // |TabRendererData::search_background_opacity| will be reset. |
+ // Repainting of tab's background will be triggered in the process. |
+ int index = tab_contents ? model_->GetIndexOfTabContents(tab_contents) : |
+ GetActiveIndex(); |
+ if (index == -1) |
+ return; |
+ SetTabDataAt(tab_contents ? tab_contents : browser_->GetTabContentsAt(index), |
+ index); |
+} |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
// BrowserTabStripController, content::NotificationObserver implementation: |
void BrowserTabStripController::Observe(int type, |
@@ -474,6 +523,19 @@ void BrowserTabStripController::SetTabRendererDataFromModel( |
data->mini = model_->IsMiniTab(model_index); |
data->blocked = model_->IsTabBlocked(model_index); |
data->app = tab_contents->extension_tab_helper()->is_app(); |
+ data->mode = browser_->search_model()->mode().mode; |
+ if (data->mode == chrome::search::Mode::MODE_SEARCH) { |
+ // Get current state of background animation to paint for SEARCH mode. |
+ browser_->search_delegate()->toolbar_search_animator(). |
+ GetCurrentBackgroundState(&data->background_state, |
+ &data->search_background_opacity); |
+ } else { |
+ data->background_state = |
+ chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_DEFAULT; |
+ // Valid opacity value of double data type is 0f to 1f, so use -1f to |
+ // indicate an invalid value. |
+ data->search_background_opacity = -1.0f; |
+ } |
} |
void BrowserTabStripController::SetTabDataAt( |