diff --git a/ui/app_list/BUILD.gn b/ui/app_list/BUILD.gn index 58b0f1ed4310fb..5ff7cecd0293e2 100644 --- a/ui/app_list/BUILD.gn +++ b/ui/app_list/BUILD.gn @@ -290,7 +290,6 @@ test("app_list_unittests") { ] deps += [ "//ui/accessibility", - "//ui/app_list/vector_icons", "//ui/views", "//ui/views:test_support", ] diff --git a/ui/app_list/app_list_constants.cc b/ui/app_list/app_list_constants.cc index b9162fa2a7c5f8..12c3ad2cf4c697 100644 --- a/ui/app_list/app_list_constants.cc +++ b/ui/app_list/app_list_constants.cc @@ -160,14 +160,6 @@ const char kSearchResultDistanceFromOrigin[] = // The height of tiles in search result. const int kSearchTileHeight = 92; -// The size of the search icon in the search box. -const int kSearchIconSize = 24; - -// Default color used when wallpaper customized color is not available for -// searchbox, #000 at 87% opacity. -const SkColor kDefaultSearchboxColor = - SkColorSetARGBMacro(0xDE, 0x00, 0x00, 0x00); - gfx::ShadowValue GetShadowForZHeight(int z_height) { if (z_height <= 0) return gfx::ShadowValue(); diff --git a/ui/app_list/app_list_constants.h b/ui/app_list/app_list_constants.h index 50edc2d31ecfb3..807a31e6f73f10 100644 --- a/ui/app_list/app_list_constants.h +++ b/ui/app_list/app_list_constants.h @@ -110,9 +110,6 @@ APP_LIST_EXPORT extern const char kSearchResultDistanceFromOrigin[]; APP_LIST_EXPORT extern const int kSearchTileHeight; -APP_LIST_EXPORT extern const int kSearchIconSize; -APP_LIST_EXPORT extern const SkColor kDefaultSearchboxColor; - // Returns the shadow values for a view at |z_height|. APP_LIST_EXPORT gfx::ShadowValue GetShadowForZHeight(int z_height); diff --git a/ui/app_list/test/app_list_test_view_delegate.cc b/ui/app_list/test/app_list_test_view_delegate.cc index 6133b93bbaf6e8..9202127bb14450 100644 --- a/ui/app_list/test/app_list_test_view_delegate.cc +++ b/ui/app_list/test/app_list_test_view_delegate.cc @@ -89,9 +89,5 @@ void AppListTestViewDelegate::ReplaceTestModel(int item_count) { model_->PopulateApps(item_count); } -void AppListTestViewDelegate::SetSearchEngineIsGoogle(bool is_google) { - model_->SetSearchEngineIsGoogle(is_google); -} - } // namespace test } // namespace app_list diff --git a/ui/app_list/test/app_list_test_view_delegate.h b/ui/app_list/test/app_list_test_view_delegate.h index d3d73afb3bba8a..5cafa04f75baab 100644 --- a/ui/app_list/test/app_list_test_view_delegate.h +++ b/ui/app_list/test/app_list_test_view_delegate.h @@ -47,9 +47,6 @@ class AppListTestViewDelegate : public AppListViewDelegate { // value to 0. int GetStopSpeechRecognitionCountAndReset(); - // Sets whether the search engine is Google or not. - void SetSearchEngineIsGoogle(bool is_google); - // AppListViewDelegate overrides: AppListModel* GetModel() override; SpeechUIModel* GetSpeechUI() override; diff --git a/ui/app_list/vector_icons/BUILD.gn b/ui/app_list/vector_icons/BUILD.gn index 74d76c32ac8f22..87a6c2c7f13ecf 100644 --- a/ui/app_list/vector_icons/BUILD.gn +++ b/ui/app_list/vector_icons/BUILD.gn @@ -20,8 +20,6 @@ aggregate_vector_icons("app_list_vector_icons") { "ic_google_black.icon", "ic_mic_black.1x.icon", "ic_mic_black.icon", - "ic_search_engine_not_google.1x.icon", - "ic_search_engine_not_google.icon", ] } diff --git a/ui/app_list/vector_icons/ic_search_engine_not_google.1x.icon b/ui/app_list/vector_icons/ic_search_engine_not_google.1x.icon deleted file mode 100644 index 5606e25cc23b7d..00000000000000 --- a/ui/app_list/vector_icons/ic_search_engine_not_google.1x.icon +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -CANVAS_DIMENSIONS, 24, -MOVE_TO, 15.5f, 14, -LINE_TO, 14.71f, 14, -LINE_TO, 14.43f, 13.73f, -CUBIC_TO, 15.41f, 12.59f, 16, 11.11f, 16, 9.5f, -CUBIC_TO, 16, 5.91f, 13.09f, 3, 9.5f, 3, -CUBIC_TO, 5.91f, 3, 3, 5.91f, 3, 9.5f, -CUBIC_TO, 3, 13.09f, 5.91f, 16, 9.5f, 16, -CUBIC_TO, 11.11f, 16, 12.59f, 15.41f, 13.73f, 14.43f, -LINE_TO, 14, 14.71f, -LINE_TO, 14, 15.5f, -LINE_TO, 19, 20.49f, -LINE_TO, 20.49f, 19, -LINE_TO, 15.5f, 14, -CLOSE, -MOVE_TO, 9.5f, 14, -CUBIC_TO, 7.01f, 14, 5, 11.99f, 5, 9.5f, -CUBIC_TO, 5, 7.01f, 7.01f, 5, 9.5f, 5, -CUBIC_TO, 11.99f, 5, 14, 7.01f, 14, 9.5f, -CUBIC_TO, 14, 11.99f, 11.99f, 14, 9.5f, 14, -CLOSE, -END diff --git a/ui/app_list/vector_icons/ic_search_engine_not_google.icon b/ui/app_list/vector_icons/ic_search_engine_not_google.icon deleted file mode 100644 index 3fd6c52c641043..00000000000000 --- a/ui/app_list/vector_icons/ic_search_engine_not_google.icon +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -MOVE_TO, 31, 28, -LINE_TO, 29.42f, 28, -LINE_TO, 28.86f, 27.46f, -CUBIC_TO, 30.82f, 25.18f, 32, 22.22f, 32, 19, -CUBIC_TO, 32, 11.82f, 26.18f, 6, 19, 6, -CUBIC_TO, 11.82f, 6, 6, 11.82f, 6, 19, -CUBIC_TO, 6, 26.18f, 11.82f, 32, 19, 32, -CUBIC_TO, 22.22f, 32, 25.18f, 30.82f, 27.46f, 28.86f, -LINE_TO, 28, 29.42f, -LINE_TO, 28, 31, -LINE_TO, 38, 40.98f, -LINE_TO, 40.98f, 38, -LINE_TO, 31, 28, -CLOSE, -MOVE_TO, 19, 28, -CUBIC_TO, 14.02f, 28, 10, 23.98f, 10, 19, -CUBIC_TO, 10, 14.02f, 14.02f, 10, 19, 10, -CUBIC_TO, 23.98f, 10, 28, 14.02f, 28, 19, -CUBIC_TO, 28, 23.98f, 23.98f, 28, 19, 28, -CLOSE, -END diff --git a/ui/app_list/views/search_box_view.cc b/ui/app_list/views/search_box_view.cc index 13f53aaebad9b1..f7af6774112fff 100644 --- a/ui/app_list/views/search_box_view.cc +++ b/ui/app_list/views/search_box_view.cc @@ -58,8 +58,14 @@ constexpr SkColor kHintTextColor = SkColorSetARGBMacro(0xFF, 0xA0, 0xA0, 0xA0); constexpr int kBackgroundBorderCornerRadius = 2; constexpr int kBackgroundBorderCornerRadiusFullscreen = 24; +constexpr int kGoogleIconSize = 24; constexpr int kMicIconSize = 24; +// Default color used when wallpaper customized color is not available for +// searchbox, #000 at 87% opacity. +constexpr SkColor kDefaultSearchboxColor = + SkColorSetARGBMacro(0xDE, 0x00, 0x00, 0x00); + constexpr int kLightVibrantBlendAlpha = 0xB3; // Color of placeholder text in zero query state. @@ -146,7 +152,7 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, view_delegate_(view_delegate), model_(nullptr), content_container_(new views::View), - search_icon_(nullptr), + google_icon_(nullptr), back_button_(nullptr), speech_button_(nullptr), search_box_(new views::Textfield), @@ -189,10 +195,11 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, content_container_->AddChildView(back_button_); if (is_fullscreen_app_list_enabled_) { - search_icon_ = new views::ImageView(); - UpdateSearchIcon(view_delegate_->GetModel()->search_engine_is_google(), - kDefaultSearchboxColor); - content_container_->AddChildView(search_icon_); + google_icon_ = new views::ImageView(); + google_icon_->SetImage(gfx::CreateVectorIcon( + kIcGoogleBlackIcon, kGoogleIconSize, kDefaultSearchboxColor)); + content_container_->AddChildView(google_icon_); + search_box_->set_placeholder_text_color(kDefaultSearchboxColor); search_box_->set_placeholder_text_draw_flags( gfx::Canvas::TEXT_ALIGN_CENTER); @@ -220,8 +227,6 @@ void SearchBoxView::ModelChanged() { model_ = view_delegate_->GetModel(); DCHECK(model_); - if (is_fullscreen_app_list_enabled_) - UpdateSearchIcon(model_->search_engine_is_google(), kDefaultSearchboxColor); model_->search_box()->AddObserver(this); SpeechRecognitionButtonPropChanged(); HintTextChanged(); @@ -351,7 +356,7 @@ void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) { if (!is_fullscreen_app_list_enabled_) return; - search_icon_->SetVisible(!show_back_button); + google_icon_->SetVisible(!show_back_button); back_button_->SetVisible(show_back_button); content_container_->Layout(); } @@ -595,24 +600,29 @@ void SearchBoxView::WallpaperProminentColorsChanged() { prominent_colors.size()); const SkColor dark_muted = prominent_colors[static_cast(ColorProfileType::DARK_MUTED)]; - const SkColor search_box_color = - SK_ColorTRANSPARENT == dark_muted ? kDefaultSearchboxColor : dark_muted; - UpdateSearchIcon(model_->search_engine_is_google(), search_box_color); + const bool dark_muted_available = SK_ColorTRANSPARENT != dark_muted; + google_icon_->SetImage(gfx::CreateVectorIcon( + kIcGoogleBlackIcon, kGoogleIconSize, + dark_muted_available ? dark_muted : kDefaultSearchboxColor)); speech_button_->SetImage( views::Button::STATE_NORMAL, - gfx::CreateVectorIcon(kIcMicBlackIcon, kMicIconSize, search_box_color)); - search_box_->set_placeholder_text_color(search_box_color); + gfx::CreateVectorIcon( + kIcMicBlackIcon, kMicIconSize, + dark_muted_available ? dark_muted : kDefaultSearchboxColor)); + search_box_->set_placeholder_text_color( + dark_muted_available ? dark_muted : kDefaultSearchboxColor); const SkColor light_vibrant = prominent_colors[static_cast(ColorProfileType::LIGHT_VIBRANT)]; const SkColor light_vibrant_mixed = color_utils::AlphaBlend( SK_ColorWHITE, light_vibrant, kLightVibrantBlendAlpha); - const SkColor background_color = SK_ColorTRANSPARENT == light_vibrant - ? kSearchBoxBackgroundDefault - : light_vibrant_mixed; - content_container_->SetBackground( - base::MakeUnique(background_color)); - search_box_->SetBackgroundColor(background_color); + const bool light_vibrant_available = SK_ColorTRANSPARENT != light_vibrant; + content_container_->SetBackground(base::MakeUnique( + light_vibrant_available ? light_vibrant_mixed + : kSearchBoxBackgroundDefault)); + search_box_->SetBackgroundColor(light_vibrant_available + ? light_vibrant_mixed + : kSearchBoxBackgroundDefault); SchedulePaint(); } @@ -623,12 +633,4 @@ void SearchBoxView::OnSpeechRecognitionStateChanged( SchedulePaint(); } -void SearchBoxView::UpdateSearchIcon(bool is_google, - const SkColor& search_box_color) { - const gfx::VectorIcon& icon = - is_google ? kIcGoogleBlackIcon : kIcSearchEngineNotGoogleIcon; - search_icon_->SetImage( - gfx::CreateVectorIcon(icon, kSearchIconSize, search_box_color)); -} - } // namespace app_list diff --git a/ui/app_list/views/search_box_view.h b/ui/app_list/views/search_box_view.h index 95359ea0c890bc..d48a58aeadd614 100644 --- a/ui/app_list/views/search_box_view.h +++ b/ui/app_list/views/search_box_view.h @@ -107,9 +107,6 @@ class APP_LIST_EXPORT SearchBoxView : public views::View, void OnGestureEvent(ui::GestureEvent* event) override; void OnMouseEvent(ui::MouseEvent* event) override; - // Used only in the tests to get the current search icon. - views::ImageView* get_search_icon_for_test() { return search_icon_; } - private: // Updates model text and selection model with current Textfield info. void UpdateModel(); @@ -117,9 +114,6 @@ class APP_LIST_EXPORT SearchBoxView : public views::View, // Fires query change notification. void NotifyQueryChanged(); - // Updates the search icon. - void UpdateSearchIcon(bool is_google, const SkColor& search_box_color); - // Overridden from views::TextfieldController: void ContentsChanged(views::Textfield* sender, const base::string16& new_contents) override; @@ -149,7 +143,7 @@ class APP_LIST_EXPORT SearchBoxView : public views::View, AppListModel* model_; // Owned by the profile-keyed service. views::View* content_container_; // Owned by views hierarchy. - views::ImageView* search_icon_; // Owned by views hierarchy. + views::ImageView* google_icon_; // Owned by views hierarchy. SearchBoxImageButton* back_button_; // Owned by views hierarchy. SearchBoxImageButton* speech_button_; // Owned by views hierarchy. views::Textfield* search_box_; // Owned by views hierarchy. diff --git a/ui/app_list/views/search_box_view_unittest.cc b/ui/app_list/views/search_box_view_unittest.cc index 8f1f0446727d61..e24ac55699cb6f 100644 --- a/ui/app_list/views/search_box_view_unittest.cc +++ b/ui/app_list/views/search_box_view_unittest.cc @@ -9,16 +9,8 @@ #include "base/macros.h" #include "base/strings/utf_string_conversions.h" -#include "base/test/scoped_feature_list.h" -#include "ui/app_list/app_list_constants.h" -#include "ui/app_list/app_list_features.h" #include "ui/app_list/test/app_list_test_view_delegate.h" -#include "ui/app_list/vector_icons/vector_icons.h" #include "ui/app_list/views/search_box_view_delegate.h" -#include "ui/gfx/image/image_skia.h" -#include "ui/gfx/image/image_unittest_util.h" -#include "ui/gfx/paint_vector_icon.h" -#include "ui/views/controls/image_view.h" #include "ui/views/controls/textfield/textfield.h" #include "ui/views/test/widget_test.h" @@ -135,43 +127,6 @@ class SearchBoxViewTest : public views::test::WidgetTest, DISALLOW_COPY_AND_ASSIGN(SearchBoxViewTest); }; -class SearchBoxViewFullScreenTest : public views::test::WidgetTest { - public: - SearchBoxViewFullScreenTest() {} - ~SearchBoxViewFullScreenTest() override {} - - // Overridden from testing::Test: - void SetUp() override { - views::test::WidgetTest::SetUp(); - scoped_feature_list_.InitAndEnableFeature( - app_list::features::kEnableFullscreenAppList); - widget_ = CreateTopLevelPlatformWidget(); - widget_->SetBounds(gfx::Rect(0, 0, 300, 200)); - view_ = new SearchBoxView(nullptr, &view_delegate_); - } - - void TearDown() override { - widget_->CloseNow(); - views::test::WidgetTest::TearDown(); - } - - protected: - SearchBoxView* view() { return view_; } - - void SetSearchEngineIsGoogle(bool is_google) { - view_delegate_.SetSearchEngineIsGoogle(is_google); - } - - private: - base::test::ScopedFeatureList scoped_feature_list_; - - AppListTestViewDelegate view_delegate_; - views::Widget* widget_; - SearchBoxView* view_; - - DISALLOW_COPY_AND_ASSIGN(SearchBoxViewFullScreenTest); -}; - TEST_F(SearchBoxViewTest, Basic) { KeyPress(ui::VKEY_A); EXPECT_EQ("a", GetLastQueryAndReset()); @@ -209,29 +164,5 @@ TEST_F(SearchBoxViewTest, CancelAutoLaunch) { EXPECT_EQ(base::TimeDelta(), GetAutoLaunchTimeout()); } -TEST_F(SearchBoxViewFullScreenTest, SearchEngineGoogle) { - SetSearchEngineIsGoogle(true); - gfx::ImageSkia expected_icon = gfx::CreateVectorIcon( - kIcGoogleBlackIcon, kSearchIconSize, kDefaultSearchboxColor); - view()->ModelChanged(); - - gfx::ImageSkia actual_icon = view()->get_search_icon_for_test()->GetImage(); - - EXPECT_TRUE(gfx::test::AreBitmapsEqual(*expected_icon.bitmap(), - *actual_icon.bitmap())); -} - -TEST_F(SearchBoxViewFullScreenTest, SearchEngineNotGoogle) { - SetSearchEngineIsGoogle(false); - gfx::ImageSkia expected_icon = gfx::CreateVectorIcon( - kIcSearchEngineNotGoogleIcon, kSearchIconSize, kDefaultSearchboxColor); - view()->ModelChanged(); - - gfx::ImageSkia actual_icon = view()->get_search_icon_for_test()->GetImage(); - - EXPECT_TRUE(gfx::test::AreBitmapsEqual(*expected_icon.bitmap(), - *actual_icon.bitmap())); -} - } // namespace test } // namespace app_list