[NTP] Use outlined tab icon for dark themes (#33573)
@@ -36,11 +36,13 @@ template("brave_repack_percent") {
|
||||
sources = [
|
||||
"$root_gen_dir/brave/brave_theme_resources_${percent}_percent.pak",
|
||||
"$root_gen_dir/brave/browser/resources/bookmark_icon/bookmark_icon_resources_${percent}_percent.pak",
|
||||
"$root_gen_dir/components/brave_components_resources_${percent}_percent.pak",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//brave/app/theme:brave_theme_resources",
|
||||
"//brave/browser/resources/bookmark_icon:bookmark_icon_resources",
|
||||
"//brave/components/resources:scaled_resources",
|
||||
]
|
||||
|
||||
if (defined(invoker.deps)) {
|
||||
|
||||
@@ -869,6 +869,7 @@ source_set("ui") {
|
||||
"//brave/components/p3a_utils",
|
||||
"//brave/components/playlist/core/common",
|
||||
"//brave/components/query_filter",
|
||||
"//brave/components/resources:scaled_resources",
|
||||
"//brave/components/resources:static_resources",
|
||||
"//brave/components/services/bat_ads/public/interfaces",
|
||||
"//brave/components/skus/browser",
|
||||
|
||||
|
Before Width: | Height: | Size: 963 B After Width: | Height: | Size: 641 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -16,9 +16,31 @@
|
||||
#include "brave/browser/ui/tabs/shared_pinned_tab_service_factory.h"
|
||||
#include "brave/components/constants/webui_url_constants.h"
|
||||
#include "chrome/browser/resource_coordinator/tab_load_tracker.h"
|
||||
#include "chrome/browser/ui/color/chrome_color_id.h"
|
||||
#include "chrome/browser/ui/tabs/features.h"
|
||||
#include "chrome/common/webui_url_constants.h"
|
||||
#include "components/grit/brave_components_scaled_resources.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "ui/color/color_provider.h"
|
||||
#include "ui/gfx/color_utils.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns the appropriate favicon for the NTP based on the current theme.
|
||||
ui::ImageModel GetThemedNTPFavicon(content::WebContents* contents) {
|
||||
const auto& color_provider = contents->GetColorProvider();
|
||||
const SkColor background_color =
|
||||
color_provider.GetColor(kColorTabBackgroundActiveFrameActive);
|
||||
const bool is_dark = color_utils::IsDark(background_color);
|
||||
const int resource_id =
|
||||
is_dark ? IDR_FAVICON_NTP_DARK : IDR_FAVICON_NTP_LIGHT;
|
||||
return ui::ImageModel::FromImage(
|
||||
ui::ResourceBundle::GetSharedInstance().GetImageNamed(resource_id));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TabRendererData TabRendererData::FromTabInModel(const TabStripModel* model,
|
||||
int index) {
|
||||
if (base::FeatureList::IsEnabled(tabs::kBraveSharedPinnedTabs)) {
|
||||
@@ -39,18 +61,22 @@ TabRendererData TabRendererData::FromTabInModel(const TabStripModel* model,
|
||||
}
|
||||
|
||||
auto data = FromTabInModel_ChromiumImpl(model, index);
|
||||
if (data.should_themify_favicon) {
|
||||
content::WebContents* const contents = model->GetWebContentsAt(index);
|
||||
const GURL& url = contents->GetVisibleURL();
|
||||
if (url.SchemeIs(content::kChromeUIScheme) &&
|
||||
(url.host() == kWelcomeHost || url.host() == kRewardsPageHost)) {
|
||||
|
||||
content::WebContents* const contents = model->GetWebContentsAt(index);
|
||||
const GURL& url = contents->GetVisibleURL();
|
||||
|
||||
// Override favicon theming for some WebUIs.
|
||||
if (url.SchemeIs(content::kChromeUIScheme)) {
|
||||
if (url.host() == chrome::kChromeUINewTabHost) {
|
||||
data.favicon = GetThemedNTPFavicon(contents);
|
||||
data.should_themify_favicon = false;
|
||||
} else if (url.host() == kWelcomeHost || url.host() == kRewardsPageHost) {
|
||||
data.should_themify_favicon = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Show which tabs are unloaded.
|
||||
if (!data.should_show_discard_status) {
|
||||
content::WebContents* const contents = model->GetWebContentsAt(index);
|
||||
using resource_coordinator::TabLoadTracker;
|
||||
const auto loading_state = TabLoadTracker::Get()->GetLoadingState(contents);
|
||||
if (loading_state == TabLoadTracker::LoadingState::UNLOADED) {
|
||||
|
||||
@@ -17,6 +17,20 @@ import("//build/config/locales.gni")
|
||||
import("//extensions/buildflags/buildflags.gni")
|
||||
import("//tools/grit/repack.gni")
|
||||
|
||||
brave_grit("scaled_resources") {
|
||||
source = "brave_components_scaled_resources.grd"
|
||||
|
||||
outputs = [
|
||||
"grit/brave_components_scaled_resources.h",
|
||||
"grit/brave_components_scaled_resources_map.cc",
|
||||
"grit/brave_components_scaled_resources_map.h",
|
||||
"brave_components_resources_100_percent.pak",
|
||||
"brave_components_resources_200_percent.pak",
|
||||
]
|
||||
|
||||
output_dir = "$root_gen_dir/components"
|
||||
}
|
||||
|
||||
brave_grit("static_resources") {
|
||||
source = "brave_components_resources.grd"
|
||||
|
||||
@@ -66,6 +80,7 @@ brave_grit("static_resources") {
|
||||
|
||||
repack("resources") {
|
||||
deps = [
|
||||
":scaled_resources",
|
||||
":static_resources",
|
||||
"//brave/components/ai_rewriter/common/buildflags",
|
||||
"//brave/components/brave_account/resources",
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<grit latest_public_release="0" current_release="1">
|
||||
<outputs>
|
||||
<output filename="grit/brave_components_scaled_resources.h" type="rc_header" context="default_100_percent">
|
||||
<emit emit_type='prepend'></emit>
|
||||
</output>
|
||||
<output filename="grit/brave_components_scaled_resources_map.cc" type="resource_map_source" context="default_100_percent" />
|
||||
<output filename="grit/brave_components_scaled_resources_map.h" type="resource_map_header" context="default_100_percent" />
|
||||
<output filename="brave_components_resources_100_percent.pak" type="data_package" context="default_100_percent" />
|
||||
<output filename="brave_components_resources_200_percent.pak" type="data_package" context="default_200_percent" />
|
||||
</outputs>
|
||||
<release seq="1">
|
||||
<structures fallback_to_low_resolution="true">
|
||||
<if expr="not is_android">
|
||||
<part file="brave_new_tab_page_scaled_resources.grdp" />
|
||||
</if>
|
||||
</structures>
|
||||
</release>
|
||||
</grit>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<grit-part>
|
||||
<structure type="chrome_scaled_image" name="IDR_FAVICON_NTP_DARK" file="favicon_ntp_dark.png" />
|
||||
<structure type="chrome_scaled_image" name="IDR_FAVICON_NTP_LIGHT" file="favicon_ntp_light.png" />
|
||||
</grit-part>
|
||||
|
After Width: | Height: | Size: 954 B |
|
After Width: | Height: | Size: 963 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
@@ -237,6 +237,9 @@
|
||||
"META": {"sizes": {"includes": [20]}},
|
||||
"includes": [54080],
|
||||
},
|
||||
"brave/components/resources/brave_components_scaled_resources.grd": {
|
||||
"structures": [54100],
|
||||
},
|
||||
# WARNING: The IDs range is 2^16-1. Check
|
||||
# out/<BUILD_TYPE>/gen/brave/resources/brave_resource_ids for how much the
|
||||
# ids got expanded for the build.
|
||||
|
||||