Commit 31adef92 authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

MacView: Use system icons for bookmark bar folders

Cocoa browser's logic for deciding whether to use the light (dark mode)
or regular icon requires converting the theme frame color to an NSColor
in NSCalibratedWhiteColorSpace and checking against an empirical
threshold.

To keep things in Views-land and maintain the same interface, this
change uses the light icon iff color_utils::IsDark returns false
for the given text color.

In practice, I will venture that anywhere this disagrees with Cocoa
is a borderline case anyway.

Bug: 792610
Change-Id: I57b1c0cb90cf06fce4a8a3f31806dedd86791ebc
Reviewed-on: https://chromium-review.googlesource.com/1012966Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551037}
parent cb3b5524
......@@ -38,7 +38,7 @@
#include "ui/gfx/paint_vector_icon.h"
#endif
#if defined(OS_WIN)
#if defined(OS_WIN) || defined(OS_MACOSX)
#include "chrome/grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
#endif
......@@ -297,6 +297,13 @@ gfx::ImageSkia GetBookmarkFolderIcon(SkColor text_color) {
#if defined(OS_WIN)
return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_BOOKMARK_BAR_FOLDER);
#elif defined(OS_MACOSX)
int resource_id = color_utils::IsDark(text_color)
? IDR_BOOKMARK_BAR_FOLDER
: IDR_BOOKMARK_BAR_FOLDER_WHITE;
return *ui::ResourceBundle::GetSharedInstance()
.GetNativeImageNamed(resource_id)
.CopyImageSkia();
#else
return GetFolderIcon(ui::MaterialDesignController::IsTouchOptimizedUiEnabled()
? vector_icons::kFolderTouchIcon
......
......@@ -103,7 +103,6 @@ bool IsValidBookmarkDropLocation(Profile* profile,
#if defined(TOOLKIT_VIEWS)
// |text_color| is the color of associated text and is used to derive the icon's
// color.
// TODO(estade): If Mac wants to use these, return gfx::Image instead.
gfx::ImageSkia GetBookmarkFolderIcon(SkColor text_color);
gfx::ImageSkia GetBookmarkManagedFolderIcon(SkColor text_color);
#endif
......
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