Commit d3a4647f authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Match location bar color better for find bar.

Because the location bar used to be light even in dark windows, the find bar had
a hack to use the non-incognito NativeTheme object.  Now that the location bar
is dark in incognito, this hack is incorrect.  Remove it.

This also means View::SetNativeTheme() is only called by test code, so this
renames it accordingly so people don't add additional non-test uses.

Bug: none
Change-Id: Id0a3363c0d3457cdfdff5ab81bff9be7ce34f15d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864515Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706727}
parent 0b56ac31
...@@ -49,7 +49,7 @@ class GlobalMediaControlsPromoControllerDialogBrowserTest ...@@ -49,7 +49,7 @@ class GlobalMediaControlsPromoControllerDialogBrowserTest
} }
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
GetMediaToolbarButton()->SetNativeTheme(&test_theme_); GetMediaToolbarButton()->SetNativeThemeForTesting(&test_theme_);
} }
void ShowUi(const std::string& name) override { ShowPromo(); } void ShowUi(const std::string& name) override { ShowPromo(); }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/app/vector_icons/vector_icons.h" #include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/find_bar/find_bar_state.h" #include "chrome/browser/ui/find_bar/find_bar_state.h"
...@@ -312,16 +311,6 @@ gfx::Size FindBarView::CalculatePreferredSize() const { ...@@ -312,16 +311,6 @@ gfx::Size FindBarView::CalculatePreferredSize() const {
return size; return size;
} }
void FindBarView::AddedToWidget() {
// Since the find bar now works/looks like a location bar bubble, make sure it
// doesn't get dark themed in incognito mode.
if (find_bar_host_->browser_view()
->browser()
->profile()
->IsIncognitoProfile())
SetNativeTheme(ui::NativeTheme::GetInstanceForNativeUi());
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// FindBarView, DropdownBarHostDelegate implementation: // FindBarView, DropdownBarHostDelegate implementation:
......
...@@ -81,10 +81,6 @@ class FindBarView : public views::View, ...@@ -81,10 +81,6 @@ class FindBarView : public views::View,
void OnAfterUserAction(views::Textfield* sender) override; void OnAfterUserAction(views::Textfield* sender) override;
void OnAfterPaste() override; void OnAfterPaste() override;
protected:
// views::View overrides:
void AddedToWidget() override;
private: private:
class FindBarButton; class FindBarButton;
class MatchCountLabel; class MatchCountLabel;
......
...@@ -140,7 +140,7 @@ TEST_F(MediaNotificationBackgroundTest, ...@@ -140,7 +140,7 @@ TEST_F(MediaNotificationBackgroundTest,
TEST_F(MediaNotificationBackgroundTest, GetBackgroundColorRespectsTheme) { TEST_F(MediaNotificationBackgroundTest, GetBackgroundColorRespectsTheme) {
TestDarkTheme dark_theme; TestDarkTheme dark_theme;
views::View owner; views::View owner;
owner.SetNativeTheme(&dark_theme); owner.SetNativeThemeForTesting(&dark_theme);
EXPECT_EQ(kDarkBackgroundColor, background()->GetBackgroundColor(owner)); EXPECT_EQ(kDarkBackgroundColor, background()->GetBackgroundColor(owner));
} }
......
...@@ -97,7 +97,7 @@ TEST_F(LabelButtonLabelTest, Colors) { ...@@ -97,7 +97,7 @@ TEST_F(LabelButtonLabelTest, Colors) {
// buttons use label colors. See LabelButton::ResetColorsFromNativeTheme(). // buttons use label colors. See LabelButton::ResetColorsFromNativeTheme().
theme1_.Set(ui::NativeTheme::kColorId_LabelEnabledColor, SK_ColorGREEN); theme1_.Set(ui::NativeTheme::kColorId_LabelEnabledColor, SK_ColorGREEN);
theme1_.Set(ui::NativeTheme::kColorId_LabelDisabledColor, SK_ColorYELLOW); theme1_.Set(ui::NativeTheme::kColorId_LabelDisabledColor, SK_ColorYELLOW);
label_->SetNativeTheme(&theme1_); label_->SetNativeThemeForTesting(&theme1_);
// Setting the theme should paint. // Setting the theme should paint.
EXPECT_EQ(SK_ColorGREEN, last_color_); EXPECT_EQ(SK_ColorGREEN, last_color_);
...@@ -110,7 +110,7 @@ TEST_F(LabelButtonLabelTest, Colors) { ...@@ -110,7 +110,7 @@ TEST_F(LabelButtonLabelTest, Colors) {
// Widget triggers it (which it can do as a friend of RootView). // Widget triggers it (which it can do as a friend of RootView).
theme2_.Set(ui::NativeTheme::kColorId_LabelEnabledColor, SK_ColorBLUE); theme2_.Set(ui::NativeTheme::kColorId_LabelEnabledColor, SK_ColorBLUE);
theme2_.Set(ui::NativeTheme::kColorId_LabelDisabledColor, SK_ColorGRAY); theme2_.Set(ui::NativeTheme::kColorId_LabelDisabledColor, SK_ColorGRAY);
label_->SetNativeTheme(&theme2_); label_->SetNativeThemeForTesting(&theme2_);
EXPECT_EQ(SK_ColorGRAY, last_color_); EXPECT_EQ(SK_ColorGRAY, last_color_);
...@@ -130,7 +130,7 @@ TEST_F(LabelButtonLabelTest, Colors) { ...@@ -130,7 +130,7 @@ TEST_F(LabelButtonLabelTest, Colors) {
EXPECT_EQ(SK_ColorMAGENTA, last_color_); EXPECT_EQ(SK_ColorMAGENTA, last_color_);
// Disabled still overridden after a theme change. // Disabled still overridden after a theme change.
label_->SetNativeTheme(&theme1_); label_->SetNativeThemeForTesting(&theme1_);
EXPECT_EQ(SK_ColorMAGENTA, last_color_); EXPECT_EQ(SK_ColorMAGENTA, last_color_);
// The enabled color still gets its value from the theme. // The enabled color still gets its value from the theme.
......
...@@ -1053,7 +1053,7 @@ const ui::NativeTheme* View::GetNativeTheme() const { ...@@ -1053,7 +1053,7 @@ const ui::NativeTheme* View::GetNativeTheme() const {
return ui::NativeTheme::GetInstanceForNativeUi(); return ui::NativeTheme::GetInstanceForNativeUi();
} }
void View::SetNativeTheme(ui::NativeTheme* theme) { void View::SetNativeThemeForTesting(ui::NativeTheme* theme) {
ui::NativeTheme* original_native_theme = GetNativeTheme(); ui::NativeTheme* original_native_theme = GetNativeTheme();
native_theme_ = theme; native_theme_ = theme;
if (native_theme_ != original_native_theme) if (native_theme_ != original_native_theme)
......
...@@ -872,7 +872,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, ...@@ -872,7 +872,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
const ui::NativeTheme* GetNativeTheme() const; const ui::NativeTheme* GetNativeTheme() const;
// Sets the native theme and informs descendants. // Sets the native theme and informs descendants.
void SetNativeTheme(ui::NativeTheme* theme); void SetNativeThemeForTesting(ui::NativeTheme* theme);
// RTL painting -------------------------------------------------------------- // RTL painting --------------------------------------------------------------
......
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