diff --git a/app/vector_icons/BUILD.gn b/app/vector_icons/BUILD.gn index 8f8832b083a..384e65d3c3d 100644 --- a/app/vector_icons/BUILD.gn +++ b/app/vector_icons/BUILD.gn @@ -8,7 +8,6 @@ aggregate_vector_icons("brave_vector_icons") { icon_directory = "." icons = [ - "autoplay_status.icon", "download_unlock.icon", "sad_folder.icon", "speedreader.icon", diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index 63e3ab852a7..bcc9fe37e9e 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -192,10 +192,6 @@ source_set("ui") { "//brave/browser/profiles", "//brave/browser/resources/settings:resources", "//brave/browser/tor", - "//brave/components/brave_wayback_machine:buildflags", - "//brave/components/ntp_background_images/browser", - "//brave/components/ntp_background_images/common", - "//brave/components/webcompat_reporter/browser", "//brave/common", "//brave/common:pref_names", "//brave/common/tor", @@ -208,8 +204,13 @@ source_set("ui") { "//brave/components/brave_shields/browser", "//brave/components/brave_sync/buildflags:buildflags", "//brave/components/brave_wallet/browser/buildflags:buildflags", + "//brave/components/brave_wayback_machine:buildflags", "//brave/components/brave_welcome_ui:generated_resources", + "//brave/components/ntp_background_images/browser", + "//brave/components/ntp_background_images/common", "//brave/components/p3a:buildflags", + "//brave/components/vector_icons", + "//brave/components/webcompat_reporter/browser", "//brave/components/weekly_storage", "//chrome/app:command_ids", "//chrome/app/vector_icons:vector_icons", diff --git a/browser/ui/content_settings/brave_autoplay_blocked_image_model.cc b/browser/ui/content_settings/brave_autoplay_blocked_image_model.cc index 41d04cbc204..081c522a3d5 100644 --- a/browser/ui/content_settings/brave_autoplay_blocked_image_model.cc +++ b/browser/ui/content_settings/brave_autoplay_blocked_image_model.cc @@ -9,12 +9,13 @@ #include "brave/browser/ui/content_settings/brave_autoplay_content_setting_bubble_model.h" #include "brave/grit/brave_generated_resources.h" -#include "brave/app/vector_icons/vector_icons.h" -#include "chrome/app/vector_icons/vector_icons.h" +#include "brave/components/vector_icons/vector_icons.h" #include "components/content_settings/core/common/content_settings_types.h" +#include "components/vector_icons/vector_icons.h" #include "content/public/browser/web_contents.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" using content::WebContents; @@ -34,7 +35,7 @@ bool BraveAutoplayBlockedImageModel::UpdateAndGetVisibility( if (!content_settings->IsContentBlocked(content_type())) return false; - const gfx::VectorIcon* badge_id = &kBlockedBadgeIcon; + const gfx::VectorIcon* badge_id = &vector_icons::kBlockedBadgeIcon; const gfx::VectorIcon* icon = &kAutoplayStatusIcon; set_icon(*icon, *badge_id); set_explanatory_string_id(IDS_BLOCKED_AUTOPLAY_TITLE); diff --git a/browser/ui/views/profiles/brave_incognito_menu_view.cc b/browser/ui/views/profiles/brave_incognito_menu_view.cc index e8f1d95e8c8..2ad15a98c48 100644 --- a/browser/ui/views/profiles/brave_incognito_menu_view.cc +++ b/browser/ui/views/profiles/brave_incognito_menu_view.cc @@ -20,6 +20,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/grit/generated_resources.h" +#include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" #if BUILDFLAG(ENABLE_TOR) @@ -88,7 +89,7 @@ void BraveIncognitoMenuView::BuildMenu() { void BraveIncognitoMenuView::AddTorButton() { if (ShouldShowTorProfileButton(browser()->profile())) { AddFeatureButton( - ImageForMenu(kLaunchIcon), + ImageForMenu(vector_icons::kLaunchIcon), l10n_util::GetStringUTF16(IDS_PROFILES_OPEN_TOR_PROFILE_BUTTON), base::BindRepeating(&BraveIncognitoMenuView::OnTorProfileButtonClicked, base::Unretained(this))); diff --git a/browser/widevine/BUILD.gn b/browser/widevine/BUILD.gn index a002315b178..2529bac973d 100644 --- a/browser/widevine/BUILD.gn +++ b/browser/widevine/BUILD.gn @@ -7,12 +7,12 @@ source_set("widevine") { "//base", "//brave/app:brave_generated_resources_grit", "//brave/common:pref_names", - "//chrome/app/vector_icons", "//chrome/browser/ui", "//chrome/common", "//components/content_settings/core/common", "//components/permissions", "//components/subresource_filter/content/browser", + "//components/vector_icons", "//content/public/browser", "//content/public/common", "//third_party/widevine/cdm:buildflags", diff --git a/browser/widevine/widevine_permission_request.cc b/browser/widevine/widevine_permission_request.cc index b536247f290..f0bea1c5719 100644 --- a/browser/widevine/widevine_permission_request.cc +++ b/browser/widevine/widevine_permission_request.cc @@ -7,7 +7,7 @@ #include "brave/browser/widevine/widevine_utils.h" #include "brave/grit/brave_generated_resources.h" -#include "chrome/app/vector_icons/vector_icons.h" +#include "components/vector_icons/vector_icons.h" #include "content/public/browser/web_contents.h" #include "ui/base/l10n/l10n_util.h" #include "third_party/widevine/cdm/buildflags.h" @@ -27,7 +27,7 @@ WidevinePermissionRequest::~WidevinePermissionRequest() { permissions::PermissionRequest::IconId WidevinePermissionRequest::GetIconId() const { - return kExtensionIcon; + return vector_icons::kExtensionIcon; } base::string16 WidevinePermissionRequest::GetMessageTextFragment() const { diff --git a/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.cc b/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.cc new file mode 100644 index 00000000000..6e92080f189 --- /dev/null +++ b/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.cc @@ -0,0 +1,18 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/browser/profiles/profile_util.h" + +#include "../../../../../../chrome/browser/ui/page_info/chrome_page_info_delegate.cc" + +bool ChromePageInfoDelegate::BraveShouldShowPermission( + ContentSettingsType type) { + if ((type == ContentSettingsType::PLUGINS || + type == ContentSettingsType::GEOLOCATION) && + brave::IsTorProfile(GetProfile())) { + return false; + } + return true; +} diff --git a/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.h b/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.h new file mode 100644 index 00000000000..b3019c52c85 --- /dev/null +++ b/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.h @@ -0,0 +1,18 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_PAGE_INFO_CHROME_PAGE_INFO_DELEGATE_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_PAGE_INFO_CHROME_PAGE_INFO_DELEGATE_H_ + +#include "components/page_info/page_info_delegate.h" + +#define IsContentDisplayedInVrHeadset \ + BraveShouldShowPermission(ContentSettingsType type) override; \ + virtual bool IsContentDisplayedInVrHeadset + +#include "../../../../../../chrome/browser/ui/page_info/chrome_page_info_delegate.h" +#undef IsContentDisplayedInVrHeadset + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_PAGE_INFO_CHROME_PAGE_INFO_DELEGATE_H_ diff --git a/chromium_src/chrome/browser/ui/page_info/page_info.cc b/chromium_src/chrome/browser/ui/page_info/page_info.cc deleted file mode 100644 index 9e27249e394..00000000000 --- a/chromium_src/chrome/browser/ui/page_info/page_info.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2019 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "brave/browser/profiles/profile_util.h" -#include "content/public/browser/web_contents.h" -#include "chrome/browser/ui/page_info/page_info_ui.h" -#include "chrome/browser/profiles/profile.h" - -namespace { - -bool BraveShouldShowPermission( - const PageInfoUI::PermissionInfo& info, - content::WebContents* web_contents) { - if ((info.type == ContentSettingsType::PLUGINS || - info.type == ContentSettingsType::GEOLOCATION) && - brave::IsTorProfile( - Profile::FromBrowserContext(web_contents->GetBrowserContext()))) { - return false; - } - - return true; -} - -} // namespace - -#include "../../../../../../chrome/browser/ui/page_info/page_info.cc" diff --git a/chromium_src/components/page_info/page_info.cc b/chromium_src/components/page_info/page_info.cc new file mode 100644 index 00000000000..0dcf45b6b47 --- /dev/null +++ b/chromium_src/components/page_info/page_info.cc @@ -0,0 +1,14 @@ +/* Copyright (c) 2019 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#define BRAVE_PAGE_INFO_SHOULD_SHOW_PERMISSION \ + if (delegate_->BraveShouldShowPermission(permission_info.type)) { \ + permission_info_list.push_back(permission_info); \ + } else { \ + continue; \ + } + +#include "../../../../components/page_info/page_info.cc" +#undef BRAVE_PAGE_INFO_SHOULD_SHOW_PERMISSION diff --git a/chromium_src/components/page_info/page_info_delegate.h b/chromium_src/components/page_info/page_info_delegate.h new file mode 100644 index 00000000000..2e30b14339d --- /dev/null +++ b/chromium_src/components/page_info/page_info_delegate.h @@ -0,0 +1,16 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ +#define BRAVE_CHROMIUM_SRC_COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ + +#define IsContentDisplayedInVrHeadset \ + BraveShouldShowPermission(ContentSettingsType type) = 0; \ + virtual bool IsContentDisplayedInVrHeadset + +#include "../../../../components/page_info/page_info_delegate.h" +#undef IsContentDisplayedInVrHeadset + +#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ diff --git a/chromium_src/components/page_info/page_info_ui.cc b/chromium_src/components/page_info/page_info_ui.cc new file mode 100644 index 00000000000..c72805e81ed --- /dev/null +++ b/chromium_src/components/page_info/page_info_ui.cc @@ -0,0 +1,14 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/components/vector_icons/vector_icons.h" + +#define BRAVE_PAGE_INFO_UI_GET_PERMISSION_ICON \ + case ContentSettingsType::AUTOPLAY: \ + icon = &kAutoplayStatusIcon; \ + break; + +#include "../../../../components/page_info/page_info_ui.cc" +#undef BRAVE_PAGE_INFO_UI_GET_PERMISSION_ICON diff --git a/components/vector_icons/BUILD.gn b/components/vector_icons/BUILD.gn new file mode 100644 index 00000000000..5a54aaba340 --- /dev/null +++ b/components/vector_icons/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) 2020 The Brave Authors. All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +import("//components/vector_icons/vector_icons.gni") + +aggregate_vector_icons("brave_components_vector_icons") { + icon_directory = "." + + icons = [ "autoplay_status.icon" ] +} + +static_library("vector_icons") { + sources = get_target_outputs(":brave_components_vector_icons") + + defines = [ "BRAVE_COMPONENTS_VECTOR_ICONS_IMPL" ] + + deps = [ + ":brave_components_vector_icons", + "//base", + "//skia", + "//ui/gfx", + ] +} diff --git a/app/vector_icons/autoplay_status.icon b/components/vector_icons/autoplay_status.icon similarity index 100% rename from app/vector_icons/autoplay_status.icon rename to components/vector_icons/autoplay_status.icon diff --git a/components/vector_icons/vector_icons.cc.template b/components/vector_icons/vector_icons.cc.template new file mode 100644 index 00000000000..38a99c9d590 --- /dev/null +++ b/components/vector_icons/vector_icons.cc.template @@ -0,0 +1,17 @@ +// 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. + +// vector_icons.cc.template is used to generate vector_icons.cc. Edit the former +// rather than the latter. + +#include "brave/components/vector_icons/vector_icons.h" + +#include "base/logging.h" +#include "components/vector_icons/cc_macros.h" +#include "ui/gfx/vector_icon_types.h" + +#define DECLARE_VECTOR_COMMAND(x) using gfx::x; +DECLARE_VECTOR_COMMANDS + +TEMPLATE_PLACEHOLDER diff --git a/components/vector_icons/vector_icons.h.template b/components/vector_icons/vector_icons.h.template new file mode 100644 index 00000000000..df8afea7fb7 --- /dev/null +++ b/components/vector_icons/vector_icons.h.template @@ -0,0 +1,26 @@ +// 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. + +// vector_icons.h.template is used to generate vector_icons.h. Edit the former +// rather than the latter. + +#ifndef BRAVE_COMPONENTS_VECTOR_ICONS_VECTOR_ICONS_H_ +#define BRAVE_COMPONENTS_VECTOR_ICONS_VECTOR_ICONS_H_ + +namespace gfx { +struct VectorIcon; +} + +#define VECTOR_ICON_TEMPLATE_H(icon_name) \ +extern const gfx::VectorIcon icon_name; + +#if defined(FEATURE_MODULES) && defined(BRAVE_COMPONENTS_VECTOR_ICONS_IMPL) +#define VECTOR_ICON_EXPORT __attribute__((visibility("default"))) +#endif + +TEMPLATE_PLACEHOLDER + +#undef VECTOR_ICON_TEMPLATE_H + +#endif // BRAVE_COMPONENTS_VECTOR_ICONS_VECTOR_ICONS_H_ diff --git a/patches/chrome-browser-ui-page_info-page_info.cc.patch b/patches/chrome-browser-ui-page_info-page_info.cc.patch deleted file mode 100644 index 7099214491d..00000000000 --- a/patches/chrome-browser-ui-page_info-page_info.cc.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/chrome/browser/ui/page_info/page_info.cc b/chrome/browser/ui/page_info/page_info.cc -index 918adb7c9628e68ba367e5dff25910536976d03b..0f1f87c99100aea01c964d726c663be0cbac1a3c 100644 ---- a/chrome/browser/ui/page_info/page_info.cc -+++ b/chrome/browser/ui/page_info/page_info.cc -@@ -172,6 +172,7 @@ bool ShouldShowPermission(const PageInfoUI::PermissionInfo& info, - HostContentSettingsMap* content_settings, - content::WebContents* web_contents, - bool changed_since_last_page_load) { -+ if (!BraveShouldShowPermission(info, web_contents)) return false; - // Note |ContentSettingsType::ADS| will show up regardless of its default - // value when it has been activated on the current origin. - if (info.type == ContentSettingsType::ADS) { diff --git a/patches/chrome-browser-ui-page_info-page_info_ui.cc.patch b/patches/chrome-browser-ui-page_info-page_info_ui.cc.patch deleted file mode 100644 index 29bb4041857..00000000000 --- a/patches/chrome-browser-ui-page_info-page_info_ui.cc.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/chrome/browser/ui/page_info/page_info_ui.cc b/chrome/browser/ui/page_info/page_info_ui.cc -index 38f48905784266a85ccb0f2decfadbd9b6d089ea..73323f92e97b8fc39615b94938ad65dcab9fa01d 100644 ---- a/chrome/browser/ui/page_info/page_info_ui.cc -+++ b/chrome/browser/ui/page_info/page_info_ui.cc -@@ -30,6 +30,7 @@ - #if defined(OS_ANDROID) - #include "chrome/browser/android/android_theme_resources.h" - #else -+#include "brave/app/vector_icons/vector_icons.h" - #include "chrome/app/vector_icons/vector_icons.h" - #include "components/prefs/pref_service.h" - #include "media/base/media_switches.h" -@@ -616,6 +617,9 @@ const gfx::ImageSkia PageInfoUI::GetPermissionIcon(const PermissionInfo& info, - case ContentSettingsType::USB_GUARD: - icon = &vector_icons::kUsbIcon; - break; -+ case ContentSettingsType::AUTOPLAY: -+ icon = &kAutoplayStatusIcon; -+ break; - case ContentSettingsType::SERIAL_GUARD: - icon = &vector_icons::kSerialPortIcon; - break; diff --git a/patches/components-page_info-BUILD.gn.patch b/patches/components-page_info-BUILD.gn.patch new file mode 100644 index 00000000000..7478548ff57 --- /dev/null +++ b/patches/components-page_info-BUILD.gn.patch @@ -0,0 +1,12 @@ +diff --git a/components/page_info/BUILD.gn b/components/page_info/BUILD.gn +index 8fecfec436e938370d5a52baa54fe1b312bbf832..2ecc7b8e8356d76b1f08ee5e1d37ce9b929b5100 100644 +--- a/components/page_info/BUILD.gn ++++ b/components/page_info/BUILD.gn +@@ -37,6 +37,7 @@ static_library("page_info") { + "//services/device/public/cpp:device_features", + "//services/metrics/public/cpp:ukm_builders", + ] ++ deps += [ "//brave/components/vector_icons" ] + + if (is_android) { + deps += [ diff --git a/patches/components-page_info-page_info.cc.patch b/patches/components-page_info-page_info.cc.patch new file mode 100644 index 00000000000..8b7c18e2682 --- /dev/null +++ b/patches/components-page_info-page_info.cc.patch @@ -0,0 +1,12 @@ +diff --git a/components/page_info/page_info.cc b/components/page_info/page_info.cc +index 8c34cb80e20be2926d16dd1522c62ed48c3840ce..29637cef4a19b68a80a0548a7de0a0b813629404 100644 +--- a/components/page_info/page_info.cc ++++ b/components/page_info/page_info.cc +@@ -948,6 +948,7 @@ void PageInfo::PresentSitePermissions() { + + // TODO(crbug.com/1058597): Remove the call to |delegate_| once + // TabSpecificContentSettings has been componentized. ++ BRAVE_PAGE_INFO_SHOULD_SHOW_PERMISSION + if (ShouldShowPermission(permission_info, site_url_, content_settings, + web_contents(), + delegate_->HasContentSettingChangedViaPageInfo( diff --git a/patches/components-page_info-page_info_ui.cc.patch b/patches/components-page_info-page_info_ui.cc.patch new file mode 100644 index 00000000000..49338e0fd46 --- /dev/null +++ b/patches/components-page_info-page_info_ui.cc.patch @@ -0,0 +1,12 @@ +diff --git a/components/page_info/page_info_ui.cc b/components/page_info/page_info_ui.cc +index 7cf58fb855df796ad18f6496a953a3e788052259..7b58404aa81c67a5ec07c4d525100bd38cf29940 100644 +--- a/components/page_info/page_info_ui.cc ++++ b/components/page_info/page_info_ui.cc +@@ -547,6 +547,7 @@ const gfx::ImageSkia PageInfoUI::GetPermissionIcon(const PermissionInfo& info, + SkColor related_text_color) { + const gfx::VectorIcon* icon = &gfx::kNoneIcon; + switch (info.type) { ++ BRAVE_PAGE_INFO_UI_GET_PERMISSION_ICON + case ContentSettingsType::COOKIES: + icon = &vector_icons::kCookieIcon; + break;