Commit 908253ae authored by Yulun Wu's avatar Yulun Wu Committed by Chromium LUCI CQ

Update icons to use themed colors.

Bug: 1154906
Change-Id: Iccfe3922f1139e552e78dd4f283f19f94d4e0958
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575558Reviewed-by: default avatarYulun Wu <yulunwu@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Yulun Wu <yulunwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834947}
parent 3aeaa3a5
......@@ -168,8 +168,6 @@ static_library("test_support") {
"test/app_list_test_model.h",
"test/app_list_test_view_delegate.cc",
"test/app_list_test_view_delegate.h",
"test/test_app_list_color_provider.cc",
"test/test_app_list_color_provider.h",
"test/test_search_result.cc",
"test/test_search_result.h",
"views/test/apps_grid_view_test_api.cc",
......@@ -237,6 +235,7 @@ test("app_list_unittests") {
":test_support",
"//ash/keyboard/ui",
"//ash/public/cpp",
"//ash/public/cpp:test_support",
"//ash/public/cpp/app_list/vector_icons",
"//ash/search_box",
"//base",
......
......@@ -222,6 +222,12 @@ SkColor AppListColorProviderImpl::GetFolderItemFocusRingColor() const {
gfx::kGoogleBlue600);
}
SkColor AppListColorProviderImpl::GetPrimaryIconColor(
SkColor default_color) const {
return DeprecatedGetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary, default_color);
}
float AppListColorProviderImpl::GetFolderBackgrounBlurSigma() const {
return static_cast<float>(AshColorProvider::LayerBlurSigma::kBlurDefault);
}
......
......@@ -48,6 +48,7 @@ class AppListColorProviderImpl : public AppListColorProvider {
SkColor GetSearchResultViewInkDropColor() const override;
SkColor GetFocusRingColor() const override;
SkColor GetFolderItemFocusRingColor() const override;
SkColor GetPrimaryIconColor(SkColor default_color) const override;
float GetFolderBackgrounBlurSigma() const override;
private:
......
......@@ -9,11 +9,11 @@
#include <vector>
#include "ash/app_list/test/app_list_test_view_delegate.h"
#include "ash/app_list/test/test_app_list_color_provider.h"
#include "ash/app_list/views/app_list_item_view.h"
#include "ash/app_list/views/app_list_view.h"
#include "ash/app_list/views/apps_grid_view.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/test/test_app_list_color_provider.h"
#include "ash/wm/container_finder.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/app_list/test/test_app_list_color_provider.h"
#include "ash/public/cpp/test/test_app_list_color_provider.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
......
......@@ -5,6 +5,7 @@
#include "ash/clipboard/views/clipboard_history_file_item_view.h"
#include "ash/public/cpp/file_icon_util.h"
#include "ash/style/ash_color_provider.h"
#include "base/files/file_path.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/view_class_properties.h"
......@@ -33,7 +34,10 @@ std::unique_ptr<ClipboardHistoryFileItemView::ContentsView>
ClipboardHistoryFileItemView::CreateContentsView() {
auto file_icon = std::make_unique<views::ImageView>();
const std::string copied_file_name = base::UTF16ToUTF8(text());
file_icon->SetImage(GetIconForPath(base::FilePath(copied_file_name)));
file_icon->SetImage(GetIconForPath(
base::FilePath(copied_file_name),
ash::AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
file_icon->SetImageSize(kIconSize);
file_icon->SetProperty(views::kMarginsKey, kIconMargin);
auto contents_view = ClipboardHistoryTextItemView::CreateContentsView();
......
......@@ -388,6 +388,8 @@ source_set("unit_tests") {
source_set("test_support") {
testonly = true
sources = [
"test/test_app_list_color_provider.cc",
"test/test_app_list_color_provider.h",
"test/test_image_downloader.cc",
"test/test_image_downloader.h",
"test/test_keyboard_controller_observer.cc",
......
......@@ -51,7 +51,7 @@ class ASH_PUBLIC_EXPORT AppListColorProvider {
virtual SkColor GetSearchResultViewInkDropColor() const = 0;
virtual SkColor GetFocusRingColor() const = 0;
virtual SkColor GetFolderItemFocusRingColor() const = 0;
virtual SkColor GetPrimaryIconColor(SkColor default_color) const = 0;
virtual float GetFolderBackgrounBlurSigma() const = 0;
protected:
......
......@@ -56,24 +56,18 @@ ASH_PUBLIC_EXPORT int GetChipResourceIdForIconType(IconType icon);
} // namespace internal
// Returns the file type icon for the specified `filepath`. Note that `color` is
// only used if the file type icon does not provide its own color.
ASH_PUBLIC_EXPORT gfx::ImageSkia GetIconForPath(
const base::FilePath& filepath,
SkColor color = gfx::kGoogleGrey700);
// Returns the file type icon for the specified `filepath`.
ASH_PUBLIC_EXPORT gfx::ImageSkia GetIconForPath(const base::FilePath& filepath,
SkColor color);
// Returns the file type chip icon for the specified `filepath`. Note that
// `color` is only used if the file type chip icon does not provide its own
// color.
// Returns the file type chip icon for the specified `filepath`.
ASH_PUBLIC_EXPORT gfx::ImageSkia GetChipIconForPath(
const base::FilePath& filepath,
SkColor color = gfx::kGoogleGrey700);
SkColor color);
// Returns the file type icon for the specified `icon_type`. Note that `color`
// is only used if the file type icon does not provide its own color.
ASH_PUBLIC_EXPORT gfx::ImageSkia GetIconFromType(
const std::string& icon_type,
SkColor color = gfx::kGoogleGrey700);
// Returns the file type icon for the specified `icon_type`.
ASH_PUBLIC_EXPORT gfx::ImageSkia GetIconFromType(const std::string& icon_type,
SkColor color);
} // namespace ash
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/app_list/test/test_app_list_color_provider.h"
#include "ash/public/cpp/test/test_app_list_color_provider.h"
#include "ui/gfx/color_palette.h"
......@@ -140,6 +140,11 @@ SkColor TestAppListColorProvider::GetFolderItemFocusRingColor() const {
return gfx::kGoogleBlue600;
}
SkColor TestAppListColorProvider::GetPrimaryIconColor(
SkColor default_color) const {
return default_color;
}
float TestAppListColorProvider::GetFolderBackgrounBlurSigma() const {
return 30.0f;
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_APP_LIST_TEST_TEST_APP_LIST_COLOR_PROVIDER_H_
#define ASH_APP_LIST_TEST_TEST_APP_LIST_COLOR_PROVIDER_H_
#ifndef ASH_PUBLIC_CPP_TEST_TEST_APP_LIST_COLOR_PROVIDER_H_
#define ASH_PUBLIC_CPP_TEST_TEST_APP_LIST_COLOR_PROVIDER_H_
#include "ash/public/cpp/app_list/app_list_color_provider.h"
......@@ -48,9 +48,10 @@ class TestAppListColorProvider : public AppListColorProvider {
SkColor GetSearchResultViewInkDropColor() const override;
SkColor GetFocusRingColor() const override;
SkColor GetFolderItemFocusRingColor() const override;
SkColor GetPrimaryIconColor(SkColor default_color) const override;
float GetFolderBackgrounBlurSigma() const override;
};
} // namespace ash
#endif // ASH_APP_LIST_TEST_TEST_APP_LIST_COLOR_PROVIDER_H_
#endif // ASH_PUBLIC_CPP_TEST_TEST_APP_LIST_COLOR_PROVIDER_H_
......@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
#include "ash/public/cpp/app_list/app_list_color_provider.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/file_icon_util.h"
#include "base/bind.h"
......@@ -72,10 +73,14 @@ FileResult::FileResult(const std::string& schema,
SetDisplayType(display_type);
switch (display_type) {
case DisplayType::kChip:
SetChipIcon(ash::GetChipIconForPath(filepath));
SetChipIcon(ash::GetChipIconForPath(
filepath, ash::AppListColorProvider::Get()->GetPrimaryIconColor(
/*default_color*/ gfx::kGoogleGrey700)));
break;
case DisplayType::kList:
SetIcon(ash::GetIconForPath(filepath));
SetIcon(ash::GetIconForPath(
filepath, ash::AppListColorProvider::Get()->GetPrimaryIconColor(
/*default_color*/ gfx::kGoogleGrey700)));
break;
default:
NOTREACHED();
......
......@@ -6,6 +6,7 @@
#include <utility>
#include "ash/public/cpp/app_list/app_list_color_provider.h"
#include "ash/public/cpp/app_list/app_list_config.h"
#include "ash/public/cpp/app_list/app_list_metrics.h"
#include "ash/public/cpp/file_icon_util.h"
......@@ -79,7 +80,9 @@ void LauncherSearchResult::Initialize() {
SetResultType(ResultType::kLauncher);
SetMetricsType(ash::LAUNCHER_SEARCH_PROVIDER_RESULT);
SetIcon(ash::GetIconFromType(icon_type_));
SetIcon(ash::GetIconFromType(
icon_type_, ash::AppListColorProvider::Get()->GetPrimaryIconColor(
gfx::kGoogleGrey700)));
}
std::string LauncherSearchResult::GetSearchResultId() {
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/ui/app_list/search/zero_state_file_provider.h"
#include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/test/test_app_list_color_provider.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
......@@ -37,9 +38,14 @@ class ZeroStateFileProviderTest : public testing::Test {
void SetUp() override {
profile_ = std::make_unique<TestingProfile>();
provider_ = std::make_unique<ZeroStateFileProvider>(profile_.get());
app_list_color_provider_ =
std::make_unique<ash::TestAppListColorProvider>();
Wait();
}
void TearDown() override { app_list_color_provider_.reset(); }
base::FilePath Path(const std::string& filename) {
return profile_->GetPath().AppendASCII(filename);
}
......@@ -64,6 +70,7 @@ class ZeroStateFileProviderTest : public testing::Test {
std::unique_ptr<Profile> profile_;
std::unique_ptr<ZeroStateFileProvider> provider_;
std::unique_ptr<ash::TestAppListColorProvider> app_list_color_provider_;
};
TEST_F(ZeroStateFileProviderTest, NoResultsWithQuery) {
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/ui/app_list/search/zero_state_file_result.h"
#include "ash/public/cpp/test/test_app_list_color_provider.h"
#include "base/files/file_path.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
......@@ -23,6 +24,7 @@ class ZeroStateFileResultTest : public testing::Test {
~ZeroStateFileResultTest() override = default;
ash::TestAppListColorProvider app_list_color_provider_;
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<Profile> profile_;
};
......
......@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
#include "ash/public/cpp/app_list/app_list_color_provider.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/file_icon_util.h"
#include "base/bind.h"
......@@ -62,8 +63,12 @@ ZeroStateFileResult::ZeroStateFileResult(const base::FilePath& filepath,
l10n_util::GetStringUTF16(IDS_FILEMANAGER_APP_NAME), true);
base::i18n::SanitizeUserSuppliedString(&sanitized_name);
SetDetails(sanitized_name);
SetIcon(ash::GetIconForPath(filepath));
SetChipIcon(ash::GetChipIconForPath(filepath));
SetIcon(ash::GetIconForPath(
filepath, ash::AppListColorProvider::Get()->GetPrimaryIconColor(
gfx::kGoogleGrey700)));
SetChipIcon(ash::GetChipIconForPath(
filepath, ash::AppListColorProvider::Get()->GetPrimaryIconColor(
gfx::kGoogleGrey700)));
}
ZeroStateFileResult::~ZeroStateFileResult() = default;
......
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