PageInfo and PageInfoUI moved to //components.
Chromium change: https://chromium.googlesource.com/chromium/src/+/b6762167670454d9b44a0ad80c3a55ac4f227180 commit b6762167670454d9b44a0ad80c3a55ac4f227180 Author: Mugdha Lakhani <nator@chromium.org> Date: Mon Mar 30 10:23:25 2020 +0000 [WebLayer] Move PageInfo and PageInfoUI to components. PageInfo and PageInfoUI have already been refactored into parts that can be shared among embedders, and chrome-specific parts. This CL simply moves the former to components. In addition, this moves some vector icons to components,and creates a a new build target in components/resources to house all resources for components resources that are mapped to an Android resource. Permissions code is updated to depend on this new target. Bug: 1052375
This commit is contained in:
@@ -8,7 +8,6 @@ aggregate_vector_icons("brave_vector_icons") {
|
||||
icon_directory = "."
|
||||
|
||||
icons = [
|
||||
"autoplay_status.icon",
|
||||
"download_unlock.icon",
|
||||
"sad_folder.icon",
|
||||
"speedreader.icon",
|
||||
|
||||
+5
-4
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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_
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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_
|
||||
@@ -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
|
||||
@@ -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",
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -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_
|
||||
@@ -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) {
|
||||
@@ -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;
|
||||
@@ -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 += [
|
||||
@@ -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(
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user