Skip to content

Commit

Permalink
Merge pull request #4828 from brave/fix-8524
Browse files Browse the repository at this point in the history
Shows brave://wallet alias under phishing detection and ENS redirect routes
  • Loading branch information
ryanml authored Mar 4, 2020
2 parents cec5d04 + 39218de commit 3867e4b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions browser/ui/toolbar/brave_location_bar_model_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 14 additions & 0 deletions browser/ui/toolbar/brave_location_bar_model_delegate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions common/extensions/extension_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 2 additions & 0 deletions common/extensions/extension_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand Down

0 comments on commit 3867e4b

Please sign in to comment.