From 39218de00b164d007cddf88b5dd9ece87952bdb0 Mon Sep 17 00:00:00 2001 From: ryanml Date: Tue, 3 Mar 2020 20:07:50 -0800 Subject: [PATCH] Fixes brave/brave-browser#8524 - Shows brave://wallet alias under loading/phishing routes --- .../toolbar/brave_location_bar_model_delegate.cc | 10 ++++++++++ .../brave_location_bar_model_delegate_unittest.cc | 14 ++++++++++++++ common/extensions/extension_constants.cc | 4 ++++ common/extensions/extension_constants.h | 2 ++ 4 files changed, 30 insertions(+) diff --git a/browser/ui/toolbar/brave_location_bar_model_delegate.cc b/browser/ui/toolbar/brave_location_bar_model_delegate.cc index c480b4b5aa09..706f46530e4d 100644 --- a/browser/ui/toolbar/brave_location_bar_model_delegate.cc +++ b/browser/ui/toolbar/brave_location_bar_model_delegate.cc @@ -38,6 +38,16 @@ void BraveLocationBarModelDelegate::FormattedStringFromURL(const GURL& url, 0, base::UTF8ToUTF16(ethereum_remote_client_base_url), base::UTF8ToUTF16("brave://wallet")); + base::ReplaceFirstSubstringAfterOffset( + new_formatted_url, + 0, + base::UTF8ToUTF16(ethereum_remote_client_phishing_url), + base::UTF8ToUTF16("brave://wallet")); + base::ReplaceFirstSubstringAfterOffset( + new_formatted_url, + 0, + base::UTF8ToUTF16(ethereum_remote_client_ens_redirect_url), + base::UTF8ToUTF16("brave://wallet")); } #endif } diff --git a/browser/ui/toolbar/brave_location_bar_model_delegate_unittest.cc b/browser/ui/toolbar/brave_location_bar_model_delegate_unittest.cc index e106967c227d..5952730838a5 100644 --- a/browser/ui/toolbar/brave_location_bar_model_delegate_unittest.cc +++ b/browser/ui/toolbar/brave_location_bar_model_delegate_unittest.cc @@ -23,6 +23,20 @@ TEST_F(BraveLocationBarModelDelegateTest, ResolvesEthereumRemoteClient) { BraveLocationBarModelDelegate::FormattedStringFromURL(url, &formatted_url); ASSERT_STREQ(base::UTF16ToASCII(formatted_url).c_str(), "brave://wallet"); } +TEST_F(BraveLocationBarModelDelegateTest, + ResolvesEthereumRemoteClientPhishingRoute) { + GURL url(ethereum_remote_client_phishing_url); + base::string16 formatted_url = base::UTF8ToUTF16(url.spec()); + BraveLocationBarModelDelegate::FormattedStringFromURL(url, &formatted_url); + ASSERT_STREQ(base::UTF16ToASCII(formatted_url).c_str(), "brave://wallet"); +} +TEST_F(BraveLocationBarModelDelegateTest, + ResolvesEthereumRemoteClientENSRoute) { + GURL url(ethereum_remote_client_ens_redirect_url); + base::string16 formatted_url = base::UTF8ToUTF16(url.spec()); + BraveLocationBarModelDelegate::FormattedStringFromURL(url, &formatted_url); + ASSERT_STREQ(base::UTF16ToASCII(formatted_url).c_str(), "brave://wallet"); +} #endif TEST_F(BraveLocationBarModelDelegateTest, ResolvesChromeSchemeToBrave) { diff --git a/common/extensions/extension_constants.cc b/common/extensions/extension_constants.cc index e236e087371f..d1a3fb1c9387 100644 --- a/common/extensions/extension_constants.cc +++ b/common/extensions/extension_constants.cc @@ -25,6 +25,10 @@ const char ethereum_remote_client_extension_public_key[] = "EGySVmv6czOI5eJYezWXwIDAQAB"; const char ethereum_remote_client_base_url[] = "chrome-extension://odbfpeeihdkbihmopkbjmoonfanlbfcl/home.html"; +const char ethereum_remote_client_phishing_url[] = + "chrome-extension://odbfpeeihdkbihmopkbjmoonfanlbfcl/phishing.html"; +const char ethereum_remote_client_ens_redirect_url[] = + "chrome-extension://odbfpeeihdkbihmopkbjmoonfanlbfcl/loading.html"; const char ethereum_remote_client_host[] = "wallet"; const char metamask_extension_id[] = "nkbihfbeogaeaoehlefnkodbefgpgknn"; diff --git a/common/extensions/extension_constants.h b/common/extensions/extension_constants.h index c27d2688bb54..2e1ab11f07db 100644 --- a/common/extensions/extension_constants.h +++ b/common/extensions/extension_constants.h @@ -18,6 +18,8 @@ extern const char ethereum_remote_client_extension_id[]; extern const char ethereum_remote_client_extension_name[]; extern const char ethereum_remote_client_extension_public_key[]; extern const char ethereum_remote_client_base_url[]; +extern const char ethereum_remote_client_phishing_url[]; +extern const char ethereum_remote_client_ens_redirect_url[]; extern const char ethereum_remote_client_host[]; extern const char metamask_extension_id[];