Customized identificator for ipfs pages
This commit is contained in:
committed by
sergey
parent
e3766f5fbf
commit
f6b3e1f5f2
+5
-1
@@ -1,3 +1,4 @@
|
||||
import("//brave/components/ipfs/buildflags/buildflags.gni")
|
||||
import("//brave/components/sidebar/buildflags/buildflags.gni")
|
||||
import("//chrome/common/features.gni")
|
||||
import("//tools/grit/grit_rule.gni")
|
||||
@@ -5,7 +6,10 @@ import("//tools/grit/grit_rule.gni")
|
||||
grit("brave_theme_resources") {
|
||||
source = "brave_theme_resources.grd"
|
||||
defines = chrome_grit_defines
|
||||
defines += [ "enable_sidebar=$enable_sidebar" ]
|
||||
defines += [
|
||||
"enable_sidebar=$enable_sidebar",
|
||||
"ipfs_enabled=$ipfs_enabled",
|
||||
]
|
||||
outputs = [
|
||||
"grit/brave_theme_resources.h",
|
||||
"grit/brave_theme_resources_map.cc",
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
<structure type="chrome_scaled_image" name="IDR_SIDEBAR_ITEM_ADD_FOCUSED" file="brave/sidebar_item_add_focused.png" />
|
||||
<structure type="chrome_scaled_image" name="IDR_SIDEBAR_SETTINGS_FOCUSED" file="brave/sidebar_settings_focused.png" />
|
||||
</if>
|
||||
<if expr="ipfs_enabled">
|
||||
<structure type="chrome_scaled_image" name="IDR_BRAVE_IPFS_LOGO" file="brave/ipfs_logo.png" />
|
||||
</if>
|
||||
|
||||
<if expr="not is_android">
|
||||
<structure type="chrome_scaled_image" name="IDR_TOR_WINDOW_FRAME_GRAPHIC" file="brave/tor_window_frame_graphic.png" />
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 428 B |
Binary file not shown.
|
After Width: | Height: | Size: 610 B |
@@ -6,18 +6,31 @@
|
||||
#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "brave/app/vector_icons/vector_icons.h"
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/browser/themes/brave_theme_service.h"
|
||||
#include "brave/browser/ui/views/brave_actions/brave_actions_container.h"
|
||||
#include "brave/browser/ui/views/toolbar/brave_toolbar_view.h"
|
||||
#include "brave/components/ipfs/ipfs_constants.h"
|
||||
#include "brave/components/ipfs/ipfs_utils.h"
|
||||
#include "brave/grit/brave_theme_resources.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/themes/theme_service_factory.h"
|
||||
#include "chrome/browser/ui/layout_constants.h"
|
||||
#include "chrome/browser/ui/omnibox/omnibox_theme.h"
|
||||
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
||||
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
|
||||
#include "chrome/browser/ui/views/page_info/page_info_bubble_view.h"
|
||||
#include "chrome/grit/chromium_strings.h"
|
||||
#include "components/grit/brave_components_strings.h"
|
||||
#include "components/omnibox/browser/omnibox_edit_model.h"
|
||||
#include "components/version_info/channel.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
#include "ui/gfx/paint_vector_icon.h"
|
||||
#include "ui/views/controls/highlight_path_generator.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_TOR)
|
||||
@@ -92,6 +105,15 @@ void BraveLocationBarView::Init() {
|
||||
content_setting_view->disable_animation();
|
||||
}
|
||||
|
||||
bool BraveLocationBarView::ShouldShowIPFSLocationView() const {
|
||||
const GURL& url = GetLocationBarModel()->GetURL();
|
||||
if (!ipfs::IsIPFSScheme(url) || !ipfs::IsIpfsEnabled(profile_) ||
|
||||
!ipfs::IsLocalGatewayConfigured(profile_))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BraveLocationBarView::Update(content::WebContents* contents) {
|
||||
// base Init calls update before our Init is run, so our children
|
||||
// may not be initialized yet
|
||||
@@ -108,6 +130,26 @@ void BraveLocationBarView::Update(content::WebContents* contents) {
|
||||
#endif
|
||||
|
||||
LocationBarView::Update(contents);
|
||||
|
||||
if (!ShouldShowIPFSLocationView())
|
||||
return;
|
||||
// Secure display text for a page was set by chromium.
|
||||
// We do not want to override this.
|
||||
if (!GetLocationBarModel()->GetSecureDisplayText().empty())
|
||||
return;
|
||||
auto badge_text = l10n_util::GetStringUTF16(IDS_IPFS_BADGE_TITLE);
|
||||
location_icon_view()->SetLabel(badge_text);
|
||||
}
|
||||
|
||||
ui::ImageModel BraveLocationBarView::GetLocationIcon(
|
||||
LocationIconView::Delegate::IconFetchedCallback on_icon_fetched) const {
|
||||
if (!ShouldShowIPFSLocationView() ||
|
||||
!omnibox_view_->model()->ShouldShowCurrentPageIcon())
|
||||
return LocationBarView::GetLocationIcon(std::move(on_icon_fetched));
|
||||
|
||||
auto& bundle = ui::ResourceBundle::GetSharedInstance();
|
||||
const auto& ipfs_logo = *bundle.GetImageSkiaNamed(IDR_BRAVE_IPFS_LOGO);
|
||||
return ui::ImageModel::FromImageSkia(ipfs_logo);
|
||||
}
|
||||
|
||||
void BraveLocationBarView::OnChanged() {
|
||||
|
||||
@@ -44,6 +44,9 @@ class BraveLocationBarView : public LocationBarView {
|
||||
// LocationBarView:
|
||||
std::vector<views::View*> GetTrailingViews() override;
|
||||
|
||||
ui::ImageModel GetLocationIcon(LocationIconView::Delegate::IconFetchedCallback
|
||||
on_icon_fetched) const override;
|
||||
|
||||
// views::View:
|
||||
gfx::Size CalculatePreferredSize() const override;
|
||||
void OnThemeChanged() override;
|
||||
@@ -53,6 +56,7 @@ class BraveLocationBarView : public LocationBarView {
|
||||
|
||||
SkPath GetFocusRingHighlightPath() const;
|
||||
ContentSettingImageView* GetContentSettingsImageViewForTesting(size_t idx);
|
||||
bool ShouldShowIPFSLocationView() const;
|
||||
|
||||
private:
|
||||
friend class ::BraveActionsContainerTest;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/* Copyright (c) 2021 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/ipfs/ipfs_constants.h"
|
||||
|
||||
#define BRAVE_SHOULD_SHOW_URL_IPFS_CHECK \
|
||||
url.SchemeIs(ipfs::kIPFSScheme) || url.SchemeIs(ipfs::kIPNSScheme) ||
|
||||
|
||||
#include "../../../../../../../chrome/browser/ui/views/location_bar/location_icon_view.cc"
|
||||
#undef BRAVE_SHOULD_SHOW_URL_IPFS_CHECK
|
||||
@@ -29,6 +29,7 @@
|
||||
<message name="IDS_IPFS_GC_ERROR" desc="Text of garbage collection error">Garbage collection error</message>
|
||||
<message name="IDS_UTILITY_PROCESS_IPFS_NAME" desc="The utility process which manages IPFS daemon">IPFS Service</message>
|
||||
<message name="IDS_IPFS_OPEN_WEBUI" desc="Title of brave://ipfs webui button">My Node</message>
|
||||
<message name="IDS_IPFS_BADGE_TITLE" desc="Title of page info badge in location bar">IPFS</message>
|
||||
<message name="IDS_IPFS_PEERS_DETAILS_LINK" desc="Link to open details about peers on brave://ipfs.">
|
||||
(details)
|
||||
</message>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.cc b/chrome/browser/ui/views/location_bar/location_icon_view.cc
|
||||
index de836abcf94a550687d47894ecf19c6df1428b32..665df7d24b95bc7d9bfc19044c953c2bb954a745 100644
|
||||
--- a/chrome/browser/ui/views/location_bar/location_icon_view.cc
|
||||
+++ b/chrome/browser/ui/views/location_bar/location_icon_view.cc
|
||||
@@ -134,6 +134,7 @@ bool LocationIconView::ShouldShowText() const {
|
||||
const auto* location_bar_model = delegate_->GetLocationBarModel();
|
||||
const GURL& url = location_bar_model->GetURL();
|
||||
if (url.SchemeIs(content::kChromeUIScheme) ||
|
||||
+ BRAVE_SHOULD_SHOW_URL_IPFS_CHECK
|
||||
url.SchemeIs(extensions::kExtensionScheme) ||
|
||||
url.SchemeIs(url::kFileScheme) ||
|
||||
url.SchemeIs(dom_distiller::kDomDistillerScheme)) {
|
||||
Reference in New Issue
Block a user