aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/provider-approval.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/controllers/provider-approval.js')
-rw-r--r--app/scripts/controllers/provider-approval.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/app/scripts/controllers/provider-approval.js b/app/scripts/controllers/provider-approval.js
index 8c7520d59..918fc8ad0 100644
--- a/app/scripts/controllers/provider-approval.js
+++ b/app/scripts/controllers/provider-approval.js
@@ -18,7 +18,15 @@ class ProviderApprovalController {
this.publicConfigStore = publicConfigStore
this.approvedOrigins = {}
platform && platform.addMessageListener && platform.addMessageListener(({ action, origin }) => {
- action && action === 'init-provider-request' && this.handleProviderRequest(origin)
+ if (!action) { return }
+ switch (action) {
+ case 'init-provider-request':
+ this.handleProviderRequest(origin)
+ break
+ case 'provider-status-request':
+ this.handleProviderStatusRequest(origin)
+ break
+ }
})
}
@@ -37,6 +45,16 @@ class ProviderApprovalController {
}
/**
+ * Called by a tab to detemrine if a full Ethereum provider API is exposed
+ *
+ * @param {string} origin - Origin of the window requesting provider status
+ */
+ async handleProviderStatusRequest (origin) {
+ const isEnabled = await this.isApproved(origin)
+ this.platform && this.platform.sendMessage({ action: 'provider-status', isEnabled }, { active: true })
+ }
+
+ /**
* Called when a user approves access to a full Ethereum provider API
*
* @param {string} origin - Origin of the target window to approve provider access