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

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: removed images from cl 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
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..7141e78ac65badf372b956eb76b2c2421be99d6c 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,57 @@ 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();
sky 2012/06/26 17:11:27 Might this happen when there is no active tab?
kuan 2012/06/26 23:25:49 Done.
+ SetTabDataAt(browser_->GetTabContentsAt(active_index), active_index);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// BrowserTabStripController, chrome::search::ToolbarSearchAnimator::Observer:
+
+void BrowserTabStripController::BackgroundChanging() {
+ // 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(active_index != -1);
+ if (active_index == -1)
+ return;
+ SetTabDataAt(browser_->GetTabContentsAt(active_index), active_index);
+}
+
+void BrowserTabStripController::BackgroundChanged() {
+ // We've finished fading in the tab background, set tab data so that
+ // |TabRendererData::background_state| and
+ // |TabRendererData::new_background_opacity| will be reset, repainting
+ // of tab's background will be triggered in the process.
+ int active_index = GetActiveIndex();
+ DCHECK(active_index != -1);
+ if (active_index == -1)
+ return;
+ SetTabDataAt(browser_->GetTabContentsAt(active_index), active_index);
+}
+
+void BrowserTabStripController::BackgroundChangeCanceled(
+ TabContents* tab_contents) {
+ // Fade in of tab background has been canceled.
+ // If |tab_contents| is not NULL and tab strip model contains |tab_contents|,
+ // set tab data so that |TabRendererData::background_state| and
+ // |TabRendererData::new_background_opacity| will be reset; repainting
+ // of tab's background will be triggered in the process.
+ if (!tab_contents)
+ return;
+ int index = model_->GetIndexOfTabContents(tab_contents);
+ if (index == -1)
+ return;
+ SetTabDataAt(tab_contents, index);
+}
+
+////////////////////////////////////////////////////////////////////////////////
// BrowserTabStripController, content::NotificationObserver implementation:
void BrowserTabStripController::Observe(int type,
@@ -474,6 +532,21 @@ 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->search_enabled =
+ chrome::search::IsInstantExtendedAPIEnabled(browser_->profile());
+ 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->new_background_opacity);
+ } else {
+ data->background_state = chrome::search::ToolbarSearchAnimator::
+ BACKGROUND_STATE_SHOW_NON_APPLICABLE;
+ // Valid opacity value of int data type is 0 to 255, so use -1 to indicate
+ // an invalid value.
+ data->new_background_opacity = -1;
+ }
}
void BrowserTabStripController::SetTabDataAt(

Powered by Google App Engine
This is Rietveld 408576698