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

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, fixed bookmark background and moved frame code, fixed unittests build b… 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..cf45b4c60b32d76e83422b2fe07877694485a8ff 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(active_index != -1);
sky 2012/06/27 04:18:36 Why both the DCHECK and the return? And why no DCH
kuan 2012/06/27 10:29:52 when reviewing the cl for 1993 repo, u asked me to
kuan 2012/06/27 13:11:33 actually, it was when reviewing THIS cl that u ask
sky 2012/06/27 14:11:44 Ya, sorry. The confusion is on my part too. The qu
dhollowa 2012/06/27 15:05:20 Yes, when there are no tabs then no SearchModel ch
kuan 2012/06/27 16:38:14 so i kept code as is: both DCHECK and conditional
dhollowa 2012/06/27 17:54:59 You can remove the conditional return. |ModeChang
+ if (active_index == -1)
+ return;
+ 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(active_index != -1);
+ if (active_index == -1)
+ return;
+ SetTabDataAt(browser_->GetTabContentsAt(active_index), active_index);
+}
+
+void BrowserTabStripController::OnToolbarBackgroundAnimatorCanceled(
+ 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 +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->new_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->new_background_opacity = -1.0f;
+ }
}
void BrowserTabStripController::SetTabDataAt(

Powered by Google App Engine
This is Rietveld 408576698