Commit ad65e1a0 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Removed dependency on GetThemeProviderForProfile() from the tabstrip.

Removed the call to GetThemeProviderForProfile() from the webui
tabstrip and replaced it with a call to GetThemeProvider() accessed
through its embedder object.

The intention is to ensure colors are obtained via the ThemeProvider
object accessed via the widget hosting the given ui element. This
paves the way forward for the rolling out of the color pipeline
project.

Bug: None
Change-Id: If298faae91f509c8448ef6b2bdd81b24fa2074c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1990337
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729827}
parent 3fac9e43
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "components/feature_engagement/public/tracker.h" #include "components/feature_engagement/public/tracker.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/theme_provider.h"
#include "ui/gfx/animation/tween.h" #include "ui/gfx/animation/tween.h"
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
...@@ -354,6 +355,10 @@ TabStripUILayout WebUITabStripContainerView::GetLayout() { ...@@ -354,6 +355,10 @@ TabStripUILayout WebUITabStripContainerView::GetLayout() {
tab_contents_container_->size()); tab_contents_container_->size());
} }
const ui::ThemeProvider* WebUITabStripContainerView::GetThemeProvider() {
return View::GetThemeProvider();
}
void WebUITabStripContainerView::AddedToWidget() { void WebUITabStripContainerView::AddedToWidget() {
GetWidget()->GetNativeView()->AddPreTargetHandler(auto_closer_.get()); GetWidget()->GetNativeView()->AddPreTargetHandler(auto_closer_.get());
} }
......
...@@ -30,6 +30,7 @@ class Tracker; ...@@ -30,6 +30,7 @@ class Tracker;
namespace ui { namespace ui {
class MenuModel; class MenuModel;
class ThemeProvider;
} // namespace ui } // namespace ui
namespace views { namespace views {
...@@ -95,6 +96,7 @@ class WebUITabStripContainerView : public TabStripUIEmbedder, ...@@ -95,6 +96,7 @@ class WebUITabStripContainerView : public TabStripUIEmbedder,
gfx::Point point, gfx::Point point,
std::unique_ptr<ui::MenuModel> menu_model) override; std::unique_ptr<ui::MenuModel> menu_model) override;
TabStripUILayout GetLayout() override; TabStripUILayout GetLayout() override;
const ui::ThemeProvider* GetThemeProvider() override;
// views::View: // views::View:
void AddedToWidget() override; void AddedToWidget() override;
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "ui/base/accelerators/accelerator.h" #include "ui/base/accelerators/accelerator.h"
#include "ui/base/default_theme_provider.h"
#include "ui/base/models/menu_model.h" #include "ui/base/models/menu_model.h"
#include "ui/base/theme_provider.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h" #include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/point_f.h"
...@@ -36,11 +38,18 @@ namespace { ...@@ -36,11 +38,18 @@ namespace {
class MockTabStripUIEmbedder : public TabStripUIEmbedder { class MockTabStripUIEmbedder : public TabStripUIEmbedder {
public: public:
MockTabStripUIEmbedder() : theme_provider_(new ui::DefaultThemeProvider()) {}
MOCK_CONST_METHOD0(GetAcceleratorProvider, const ui::AcceleratorProvider*()); MOCK_CONST_METHOD0(GetAcceleratorProvider, const ui::AcceleratorProvider*());
MOCK_METHOD0(CloseContainer, void()); MOCK_METHOD0(CloseContainer, void());
MOCK_METHOD2(ShowContextMenuAtPoint, MOCK_METHOD2(ShowContextMenuAtPoint,
void(gfx::Point, std::unique_ptr<ui::MenuModel>)); void(gfx::Point, std::unique_ptr<ui::MenuModel>));
MOCK_METHOD0(GetLayout, TabStripUILayout()); MOCK_METHOD0(GetLayout, TabStripUILayout());
const ui::ThemeProvider* GetThemeProvider() override {
return theme_provider_.get();
}
private:
const std::unique_ptr<ui::ThemeProvider> theme_provider_;
}; };
} // namespace } // namespace
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#include "ui/base/models/menu_model.h" #include "ui/base/models/menu_model.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
namespace ui {
class ThemeProvider;
} // namespace ui
// Interface to be implemented by the embedder. Provides native UI // Interface to be implemented by the embedder. Provides native UI
// functionality such as showing context menus. // functionality such as showing context menus.
class TabStripUIEmbedder { class TabStripUIEmbedder {
...@@ -26,6 +30,8 @@ class TabStripUIEmbedder { ...@@ -26,6 +30,8 @@ class TabStripUIEmbedder {
std::unique_ptr<ui::MenuModel> menu_model) = 0; std::unique_ptr<ui::MenuModel> menu_model) = 0;
virtual TabStripUILayout GetLayout() = 0; virtual TabStripUILayout GetLayout() = 0;
virtual const ui::ThemeProvider* GetThemeProvider() = 0;
}; };
#endif // CHROME_BROWSER_UI_WEBUI_TAB_STRIP_TAB_STRIP_UI_EMBEDDER_H_ #endif // CHROME_BROWSER_UI_WEBUI_TAB_STRIP_TAB_STRIP_UI_EMBEDDER_H_
...@@ -393,40 +393,39 @@ void TabStripUIHandler::HandleGetThemeColors(const base::ListValue* args) { ...@@ -393,40 +393,39 @@ void TabStripUIHandler::HandleGetThemeColors(const base::ListValue* args) {
AllowJavascript(); AllowJavascript();
const base::Value& callback_id = args->GetList()[0]; const base::Value& callback_id = args->GetList()[0];
const ui::ThemeProvider& tp = const ui::ThemeProvider* tp = embedder_->GetThemeProvider();
ThemeService::GetThemeProviderForProfile(browser_->profile());
// This should return an object of CSS variables to rgba values so that // This should return an object of CSS variables to rgba values so that
// the WebUI can use the CSS variables to color the tab strip // the WebUI can use the CSS variables to color the tab strip
base::DictionaryValue colors; base::DictionaryValue colors;
colors.SetString("--tabstrip-background-color", colors.SetString("--tabstrip-background-color",
color_utils::SkColorToRgbaString( color_utils::SkColorToRgbaString(
tp.GetColor(ThemeProperties::COLOR_FRAME))); tp->GetColor(ThemeProperties::COLOR_FRAME)));
colors.SetString("--tabstrip-tab-background-color", colors.SetString("--tabstrip-tab-background-color",
color_utils::SkColorToRgbaString( color_utils::SkColorToRgbaString(
tp.GetColor(ThemeProperties::COLOR_TOOLBAR))); tp->GetColor(ThemeProperties::COLOR_TOOLBAR)));
colors.SetString("--tabstrip-tab-text-color", colors.SetString("--tabstrip-tab-text-color",
color_utils::SkColorToRgbaString( color_utils::SkColorToRgbaString(
tp.GetColor(ThemeProperties::COLOR_TAB_TEXT))); tp->GetColor(ThemeProperties::COLOR_TAB_TEXT)));
colors.SetString("--tabstrip-tab-separator-color", colors.SetString("--tabstrip-tab-separator-color",
color_utils::SkColorToRgbaString( color_utils::SkColorToRgbaString(SkColorSetA(
SkColorSetA(tp.GetColor(ThemeProperties::COLOR_TAB_TEXT), tp->GetColor(ThemeProperties::COLOR_TAB_TEXT),
/* 16% opacity */ 0.16 * 255))); /* 16% opacity */ 0.16 * 255)));
colors.SetString("--tabstrip-tab-loading-spinning-color", colors.SetString("--tabstrip-tab-loading-spinning-color",
color_utils::SkColorToRgbaString(tp.GetColor( color_utils::SkColorToRgbaString(tp->GetColor(
ThemeProperties::COLOR_TAB_THROBBER_SPINNING))); ThemeProperties::COLOR_TAB_THROBBER_SPINNING)));
colors.SetString("--tabstrip-tab-waiting-spinning-color", colors.SetString("--tabstrip-tab-waiting-spinning-color",
color_utils::SkColorToRgbaString(tp.GetColor( color_utils::SkColorToRgbaString(tp->GetColor(
ThemeProperties::COLOR_TAB_THROBBER_WAITING))); ThemeProperties::COLOR_TAB_THROBBER_WAITING)));
colors.SetString("--tabstrip-indicator-recording-color", colors.SetString("--tabstrip-indicator-recording-color",
color_utils::SkColorToRgbaString(tp.GetColor( color_utils::SkColorToRgbaString(tp->GetColor(
ThemeProperties::COLOR_TAB_ALERT_RECORDING))); ThemeProperties::COLOR_TAB_ALERT_RECORDING)));
colors.SetString("--tabstrip-indicator-pip-color", colors.SetString("--tabstrip-indicator-pip-color",
color_utils::SkColorToRgbaString( color_utils::SkColorToRgbaString(
tp.GetColor(ThemeProperties::COLOR_TAB_PIP_PLAYING))); tp->GetColor(ThemeProperties::COLOR_TAB_PIP_PLAYING)));
colors.SetString("--tabstrip-indicator-capturing-color", colors.SetString("--tabstrip-indicator-capturing-color",
color_utils::SkColorToRgbaString(tp.GetColor( color_utils::SkColorToRgbaString(tp->GetColor(
ThemeProperties::COLOR_TAB_ALERT_CAPTURING))); ThemeProperties::COLOR_TAB_ALERT_CAPTURING)));
colors.SetString("--tabstrip-tab-blocked-color", colors.SetString("--tabstrip-tab-blocked-color",
color_utils::SkColorToRgbaString( color_utils::SkColorToRgbaString(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment