Commit 3dc1a267 authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

Dark mode: more default favicon updates

Bug: 924505, 935593
Change-Id: Ibb2f747b7a9a9e0516e4a8e18e9c55b712d77f86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1504255
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644340}
parent 7e128f72
......@@ -31,9 +31,7 @@ base::string16 FormatUrlToSubdomain(const GURL& url) {
} // namespace
TabUIHelper::TabUIData::TabUIData(const GURL& url)
: title(FormatUrlToSubdomain(url)),
favicon(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_DEFAULT_FAVICON)) {}
: title(FormatUrlToSubdomain(url)), favicon(favicon::GetDefaultFavicon()) {}
TabUIHelper::TabUIHelper(content::WebContents* contents)
: WebContentsObserver(contents), weak_ptr_factory_(this) {}
......
......@@ -17,6 +17,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/sessions/session_restore.h"
......@@ -130,14 +131,6 @@ gfx::Image CreateFavicon(const gfx::VectorIcon& icon) {
ui::NativeTheme::kColorId_DefaultIconColor)));
}
// TODO(https://crbug.com/935593): Use a centralized method when it's available.
gfx::Image GetDefaultFavicon() {
ui::NativeTheme* native_theme = ui::NativeTheme::GetInstanceForNativeUi();
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
native_theme->SystemDarkModeEnabled() ? IDR_DEFAULT_FAVICON_DARK
: IDR_DEFAULT_FAVICON);
}
} // namespace
enum RecentTabAction {
......@@ -590,7 +583,7 @@ void RecentTabsSubMenuModel::AddTabFavicon(int command_id, const GURL& url) {
// Otherwise, start to fetch the favicon from local history asynchronously.
// Set default icon first.
SetIcon(index_in_menu, GetDefaultFavicon());
SetIcon(index_in_menu, favicon::GetDefaultFavicon());
// Start request to fetch actual icon if possible.
favicon::FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(browser_->profile(),
......
......@@ -28,6 +28,7 @@
#include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/themes/theme_properties.h"
......@@ -1269,7 +1270,7 @@ void BookmarkBarView::WriteDragDataForView(View* sender,
views::Widget* widget = sender->GetWidget();
if (node->is_url()) {
const gfx::Image& image = model_->GetFavicon(node);
icon = image.IsEmpty() ? *GetImageSkiaNamed(IDR_DEFAULT_FAVICON)
icon = image.IsEmpty() ? favicon::GetDefaultFavicon().AsImageSkia()
: image.AsImageSkia();
} else {
icon = chrome::GetBookmarkFolderIcon(
......@@ -1615,7 +1616,7 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node,
gfx::CreateVectorIcon(kDefaultTouchFaviconMaskIcon, SK_ColorBLACK);
favicon = gfx::ImageSkiaOperations::CreateMaskedImage(icon, mask);
} else {
favicon = *GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
favicon = favicon::GetDefaultFavicon().AsImageSkia();
}
themify_icon = true;
}
......
......@@ -10,6 +10,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h"
......@@ -382,11 +383,9 @@ void BookmarkMenuDelegate::BookmarkNodeFaviconChanged(
return; // We're not showing a menu item for the node.
const gfx::Image& image = model->GetFavicon(node);
const gfx::ImageSkia* icon =
image.IsEmpty()
? ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_DEFAULT_FAVICON)
: image.ToImageSkia();
const gfx::ImageSkia* icon = image.IsEmpty()
? favicon::GetDefaultFavicon().ToImageSkia()
: image.ToImageSkia();
menu_pair->second->SetIcon(*icon);
}
......
......@@ -6,6 +6,7 @@
#include "base/time/default_tick_clock.h"
#include "cc/paint/paint_flags.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/views/tabs/tab_renderer_data.h"
......@@ -343,9 +344,8 @@ void TabIcon::MaybePaintFavicon(gfx::Canvas* canvas,
}
bool TabIcon::HasNonDefaultFavicon() const {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
return !favicon_.isNull() && !favicon_.BackedBySameObjectAs(
*rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON));
favicon::GetDefaultFavicon().AsImageSkia());
}
void TabIcon::SetIcon(const GURL& url, const gfx::ImageSkia& icon) {
......
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