From d4171ccea51db04aa40320de8770e22203d4d6c2 Mon Sep 17 00:00:00 2001 From: bitpshr Date: Mon, 29 Oct 2018 23:44:04 +0100 Subject: Disable approval caching --- app/scripts/controllers/provider-approval.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'app/scripts/controllers') diff --git a/app/scripts/controllers/provider-approval.js b/app/scripts/controllers/provider-approval.js index 66017c58e..cbdebc3e3 100644 --- a/app/scripts/controllers/provider-approval.js +++ b/app/scripts/controllers/provider-approval.js @@ -4,6 +4,11 @@ const ObservableStore = require('obs-store') * A controller that services user-approved requests for a full Ethereum provider API */ class ProviderApprovalController { + /** + * Determines if caching is enabled + */ + caching = false + /** * Creates a ProviderApprovalController * @@ -44,7 +49,7 @@ class ProviderApprovalController { */ _handleProviderRequest (origin) { this.store.updateState({ providerRequests: [{ origin }] }) - if (this.isApproved(origin)) { + if (this.isApproved(origin) && this.caching) { this.approveProviderRequest(origin) return } @@ -57,8 +62,9 @@ class ProviderApprovalController { * @param {string} origin - Origin of the window */ _handleIsApproved (origin) { - const isApproved = this.isApproved(origin) - this.platform && this.platform.sendMessage({ action: 'answer-is-approved', isApproved }, { active: true }) + const isApproved = this.isApproved(origin) && this.caching + const caching = this.caching + this.platform && this.platform.sendMessage({ action: 'answer-is-approved', isApproved, caching }, { active: true }) } /** @@ -125,6 +131,14 @@ class ProviderApprovalController { const privacyMode = this.preferencesController.getFeatureFlags().privacyMode return !privacyMode || this.approvedOrigins[origin] } + + /** + * Tells all tabs that MetaMask is now locked. This is primarily used to set + * internal flags in the contentscript and inpage script. + */ + setLocked () { + this.platform.sendMessage({ action: 'metamask-set-locked' }) + } } module.exports = ProviderApprovalController -- cgit v1.2.3