-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wrong location icon and page info bubble of brave page #1722
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* 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/ui/brave_browser_location_bar_model_delegate.h" | ||
|
||
#if !defined(OS_ANDROID) | ||
#include "components/omnibox/browser/vector_icons.h" // nogncheck | ||
#endif // !defined(OS_ANDROID) | ||
|
||
#include "content/public/common/url_constants.h" | ||
const gfx::VectorIcon* | ||
BraveBrowserLocationBarModelDelegate::GetVectorIconOverride() const { | ||
#if !defined(OS_ANDROID) | ||
GURL url; | ||
GetURL(&url); | ||
|
||
if (url.SchemeIs(content::kBraveUIScheme)) | ||
return &omnibox::kProductIcon; | ||
|
||
return BrowserLocationBarModelDelegate::GetVectorIconOverride(); | ||
#endif | ||
|
||
return nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* 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/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_BRAVE_BROWSER_LOCATION_BAR_MODEL_DELEGATE_H_ | ||
#define BRAVE_BROWSER_UI_BRAVE_BROWSER_LOCATION_BAR_MODEL_DELEGATE_H_ | ||
|
||
#include "chrome/browser/ui/browser_location_bar_model_delegate.h" | ||
|
||
class BraveBrowserLocationBarModelDelegate | ||
: public BrowserLocationBarModelDelegate { | ||
public: | ||
using BrowserLocationBarModelDelegate::BrowserLocationBarModelDelegate; | ||
~BraveBrowserLocationBarModelDelegate() override = default; | ||
|
||
private: | ||
const gfx::VectorIcon* GetVectorIconOverride() const override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveBrowserLocationBarModelDelegate); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_BRAVE_BROWSER_LOCATION_BAR_MODEL_DELEGATE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* 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/ui/views/location_bar/brave_location_icon_view.h" | ||
|
||
#include "chrome/grit/chromium_strings.h" | ||
#include "content/public/common/url_constants.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
|
||
bool BraveLocationIconView::ShouldShowText() const { | ||
const auto* location_bar_model = delegate_->GetLocationBarModel(); | ||
if (!location_bar_model->input_in_progress()) { | ||
const GURL& url = location_bar_model->GetURL(); | ||
if (url.SchemeIs(content::kBraveUIScheme)) | ||
return true; | ||
} | ||
|
||
return LocationIconView::ShouldShowText(); | ||
} | ||
|
||
base::string16 BraveLocationIconView::GetText() const { | ||
if (delegate_->GetLocationBarModel()->GetURL().SchemeIs( | ||
content::kBraveUIScheme)) { | ||
return l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | ||
} | ||
|
||
return LocationIconView::GetText(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* 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/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_VIEWS_LOCATION_BAR_BRAVE_LOCATION_ICON_VIEW_H_ | ||
#define BRAVE_BROWSER_UI_VIEWS_LOCATION_BAR_BRAVE_LOCATION_ICON_VIEW_H_ | ||
|
||
#include "chrome/browser/ui/views/location_bar/location_icon_view.h" | ||
|
||
class BraveLocationIconView : public LocationIconView { | ||
public: | ||
using LocationIconView::LocationIconView; | ||
~BraveLocationIconView() override = default; | ||
|
||
private: | ||
// LocationIconView overrides: | ||
base::string16 GetText() const override; | ||
bool ShouldShowText() const override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveLocationIconView); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_VIEWS_LOCATION_BAR_BRAVE_LOCATION_ICON_VIEW_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
patches/chrome-browser-ui-toolbar-chrome_location_bar_model_delegate.h.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/chrome/browser/ui/toolbar/chrome_location_bar_model_delegate.h b/chrome/browser/ui/toolbar/chrome_location_bar_model_delegate.h | ||
index 26d74e9c5d80d2c699df1a6ee16f4ed494d563dd..d3bc3bd42e610d4395746ce314a49d848f7d5975 100644 | ||
--- a/chrome/browser/ui/toolbar/chrome_location_bar_model_delegate.h | ||
+++ b/chrome/browser/ui/toolbar/chrome_location_bar_model_delegate.h | ||
@@ -37,6 +37,7 @@ class ChromeLocationBarModelDelegate : public LocationBarModelDelegate { | ||
content::NavigationEntry* GetNavigationEntry() const; | ||
|
||
private: | ||
+ friend class BraveBrowserLocationBarModelDelegate; | ||
base::string16 FormattedStringWithEquivalentMeaning( | ||
const GURL& url, | ||
const base::string16& formatted_url) const override; |
28 changes: 28 additions & 0 deletions
28
patches/chrome-browser-ui-views-location_bar-location_icon_view.h.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.h b/chrome/browser/ui/views/location_bar/location_icon_view.h | ||
index c5a8d05e0598f7e067f32d905f2bb060eca9e51f..af34e908d1c36e93e6b648ddfbee76811f872f92 100644 | ||
--- a/chrome/browser/ui/views/location_bar/location_icon_view.h | ||
+++ b/chrome/browser/ui/views/location_bar/location_icon_view.h | ||
@@ -92,13 +92,13 @@ class LocationIconView : public IconLabelBubbleView { | ||
// - For extension URLs, returns the extension name. | ||
// - For chrome:// URLs, returns the short product name (e.g. Chrome). | ||
// - For file:// URLs, returns the text "File". | ||
- base::string16 GetText() const; | ||
+ virtual base::string16 GetText() const; | ||
|
||
// Determines whether or not text should be shown (e.g Insecure/Secure). | ||
// Returns true if any of the following is true: | ||
// - the current page is explicitly secure or insecure. | ||
// - the current page URL is a chrome-extension:// URL. | ||
- bool ShouldShowText() const; | ||
+ virtual bool ShouldShowText() const; | ||
|
||
const views::InkDrop* get_ink_drop_for_testing(); | ||
|
||
@@ -108,6 +108,7 @@ class LocationIconView : public IconLabelBubbleView { | ||
double WidthMultiplier() const override; | ||
|
||
private: | ||
+ friend class BraveLocationIconView; | ||
// The security level when the location icon was last updated. Used to decide | ||
// whether to animate security level transitions. | ||
security_state::SecurityLevel last_update_security_level_ = |
24 changes: 24 additions & 0 deletions
24
patches/chrome-browser-ui-views-page_info-page_info_bubble_view.cc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view.cc | ||
index ebe5987d5b4239e09a9b255b0d73ec9f7ad74fe9..933b15b53b86376e63a425701ae8cb8571d8b692 100644 | ||
--- a/chrome/browser/ui/views/page_info/page_info_bubble_view.cc | ||
+++ b/chrome/browser/ui/views/page_info/page_info_bubble_view.cc | ||
@@ -386,6 +386,9 @@ InternalPageInfoBubbleView::InternalPageInfoBubbleView( | ||
} else if (url.SchemeIs(url::kFileScheme)) { | ||
text = IDS_PAGE_INFO_FILE_PAGE; | ||
} else if (!url.SchemeIs(content::kChromeUIScheme) && | ||
+#if defined(BRAVE_CHROMIUM_BUILD) | ||
+ !url.SchemeIs(content::kBraveUIScheme) && | ||
+#endif | ||
!url.SchemeIs(content::kChromeDevToolsScheme)) { | ||
NOTREACHED(); | ||
} | ||
@@ -430,6 +433,9 @@ views::BubbleDialogDelegateView* PageInfoBubbleView::CreatePageInfoBubble( | ||
gfx::NativeView parent_view = platform_util::GetViewForWindow(parent_window); | ||
|
||
if (url.SchemeIs(content::kChromeUIScheme) || | ||
+#if defined(BRAVE_CHROMIUM_BUILD) | ||
+ url.SchemeIs(content::kBraveUIScheme) || | ||
+#endif | ||
url.SchemeIs(content::kChromeDevToolsScheme) || | ||
url.SchemeIs(extensions::kExtensionScheme) || | ||
url.SchemeIs(content::kViewSourceScheme) || |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't avoid this patch file because multiple
PageInfoBubbleView::CreatePageInfoBubble()
is used in this file andInternalPageInfoBubbleView
class is in anonymous namespace.