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

Unified Diff: chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc

Issue 10662032: alternate ntp (cros/partial-win): add tab-related stuff and toolbar/tab background change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed scott's comments Created 8 years, 6 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
« no previous file with comments | « chrome/browser/ui/views/tabs/browser_tab_strip_controller.h ('k') | chrome/browser/ui/views/tabs/tab.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « chrome/browser/ui/views/tabs/browser_tab_strip_controller.h ('k') | chrome/browser/ui/views/tabs/tab.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698