Skip to content
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

Use Infobars for Dapp detection and MetaMask detection #3791

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@
<message name="IDS_WIDEVINE_PERMISSION_REQUEST_TEXT_FRAGMENT" desc="Text fragment for Widevine permission request. 'Widevine' is the name of a plugin and should not be translated.">
Install and run Widevine
</message>
<message name="IDS_WALLET_PERMISSION_REQUEST_TEXT_FRAGMENT" desc="Text fragment for wallet installation permission request.">
Install Crypto Wallets
</message>
<message name="IDS_WIDEVINE_DONT_ASK_AGAIN_CHECKBOX" desc="Checkbox for prevent showing widevine install prompt">
Don't ask again
</message>
Expand Down Expand Up @@ -627,6 +624,22 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
<message name="IDS_BRAVE_P3A_ENABLE_SETTING_SUBITEM" desc="Description that shows under main toggle setting for P3A">
This anonymous info only lets Brave estimate the overall usage of certain features.
</message>
<!-- Web3 detection -->
<message name="IDS_BRAVE_CRYPTO_WALLETS_METAMASK_INFOBAR_TEXT" desc="Text that shows on the info bar when a Dapp is detected">
Crypto Wallets is now available in Brave. You can't use MetaMask and Crypto Wallets at the same time.
</message>
<message name="IDS_BRAVE_CRYPTO_WALLETS_INFOBAR_TEXT" desc="Text that shows on the info bar when a Dapp is detected">
Set up Crypto Wallets to interact with this app and others like it.
</message>
<message name="IDS_BRAVE_CRYPTO_WALLETS_USE_CRYPTO_WALLETS" desc="Use Crypto Wallets">
Use Crypto Wallets
</message>
<message name="IDS_BRAVE_CRYPTO_WALLETS_USE_METAMASK" desc="Use MetaMask and don't use Crypto Wallets">
Use MetaMask
</message>
<message name="IDS_BRAVE_CRYPTO_WALLETS_SETUP" desc="Use Crypto Wallets">
SETUP
</message>
</messages>
<includes>
<include name="IDR_BRAVE_GOOGLE_ANALYTICS_POLYFILL" file="resources/js/google_analytics_polyfill.js" type="BINDATA" />
Expand Down
9 changes: 0 additions & 9 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,6 @@ source_set("browser_process") {
]
}

if (brave_wallet_enabled) {
sources += [
"brave_wallet/brave_wallet_utils.cc",
"brave_wallet/brave_wallet_utils.h",
"brave_wallet/wallet_installation_permission_request.cc",
"brave_wallet/wallet_installation_permission_request.h",
]
}

if (enable_tor) {
deps += [
"//brave/components/services/tor/public/cpp:manifest",
Expand Down
1 change: 1 addition & 0 deletions browser/brave_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#if !defined(OS_ANDROID)
#include "brave/browser/infobars/brave_confirm_p3a_infobar_delegate.h"
#include "brave/browser/infobars/crypto_wallets_infobar_delegate.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "content/public/browser/web_contents.h"
Expand Down
31 changes: 0 additions & 31 deletions browser/brave_wallet/brave_wallet_utils.cc

This file was deleted.

20 changes: 0 additions & 20 deletions browser/brave_wallet/brave_wallet_utils.h

This file was deleted.

59 changes: 0 additions & 59 deletions browser/brave_wallet/wallet_installation_permission_request.cc

This file was deleted.

41 changes: 0 additions & 41 deletions browser/brave_wallet/wallet_installation_permission_request.h

This file was deleted.

13 changes: 11 additions & 2 deletions browser/extensions/api/brave_wallet_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

#include "base/base64.h"
#include "base/environment.h"
#include "brave/browser/brave_wallet/brave_wallet_utils.h"
#include "brave/browser/infobars/crypto_wallets_infobar_delegate.h"
#include "brave/browser/profiles/profile_util.h"
#include "brave/common/extensions/api/brave_wallet.h"
#include "brave/common/extensions/extension_constants.h"
#include "brave/common/pref_names.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_contents.h"
Expand Down Expand Up @@ -58,7 +59,15 @@ BraveWalletPromptToEnableWalletFunction::Run() {
base::NumberToString(params->tab_id)));
}

RequestWalletInstallationPermission(contents);
InfoBarService* infobar_service =
InfoBarService::FromWebContents(contents);
if (infobar_service) {
auto* registry = extensions::ExtensionRegistry::Get(profile);
bool metamask_enabled = !brave::IsTorProfile(profile) &&
registry->ready_extensions().GetByID(metamask_extension_id);
CryptoWalletsInfoBarDelegate::Create(infobar_service, metamask_enabled);
}

return RespondNow(NoArguments());
}

Expand Down
Loading