From 5834c13769a4c84fc89f2c4bd2480f3fe58b5100 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 13:37:02 -0700 Subject: ui - change window title 'MetaMask Plugin' to 'MetaMask' --- app/home.html | 2 +- app/popup.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/home.html b/app/home.html index cfb4b00a0..730215d1a 100644 --- a/app/home.html +++ b/app/home.html @@ -3,7 +3,7 @@ - MetaMask Plugin + MetaMask
diff --git a/app/popup.html b/app/popup.html index bf09b97ca..148d266d3 100644 --- a/app/popup.html +++ b/app/popup.html @@ -3,7 +3,7 @@ - MetaMask Plugin + MetaMask
-- cgit v1.2.3 From 5815de33fbef617625d8350ec8e88aa4dbff6156 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 14:04:33 -0700 Subject: build - rename 'popup.js' to 'ui.js' --- app/home.html | 2 +- app/notification.html | 2 +- app/popup.html | 2 +- app/scripts/popup.js | 84 --------------------------------------------------- app/scripts/ui.js | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 87 deletions(-) delete mode 100644 app/scripts/popup.js create mode 100644 app/scripts/ui.js (limited to 'app') diff --git a/app/home.html b/app/home.html index 730215d1a..bb8e936a3 100644 --- a/app/home.html +++ b/app/home.html @@ -7,6 +7,6 @@
- + diff --git a/app/notification.html b/app/notification.html index f10cbbf41..2255ca2c1 100644 --- a/app/notification.html +++ b/app/notification.html @@ -11,6 +11,6 @@
- + diff --git a/app/popup.html b/app/popup.html index 148d266d3..109487d3e 100644 --- a/app/popup.html +++ b/app/popup.html @@ -7,6 +7,6 @@
- + diff --git a/app/scripts/popup.js b/app/scripts/popup.js deleted file mode 100644 index 13c7ac5ec..000000000 --- a/app/scripts/popup.js +++ /dev/null @@ -1,84 +0,0 @@ -const injectCss = require('inject-css') -const OldMetaMaskUiCss = require('../../old-ui/css') -const NewMetaMaskUiCss = require('../../ui/css') -const startPopup = require('./popup-core') -const PortStream = require('./lib/port-stream.js') -const isPopupOrNotification = require('./lib/is-popup-or-notification') -const extension = require('extensionizer') -const ExtensionPlatform = require('./platforms/extension') -const NotificationManager = require('./lib/notification-manager') -const notificationManager = new NotificationManager() -const setupRaven = require('./lib/setupRaven') - -start().catch(log.error) - -async function start() { - - // create platform global - global.platform = new ExtensionPlatform() - - // setup sentry error reporting - const release = global.platform.getVersion() - setupRaven({ release }) - - // inject css - // const css = MetaMaskUiCss() - // injectCss(css) - - // identify window type (popup, notification) - const windowType = isPopupOrNotification() - global.METAMASK_UI_TYPE = windowType - closePopupIfOpen(windowType) - - // setup stream to background - const extensionPort = extension.runtime.connect({ name: windowType }) - const connectionStream = new PortStream(extensionPort) - - // start ui - const container = document.getElementById('app-content') - startPopup({ container, connectionStream }, (err, store) => { - if (err) return displayCriticalError(err) - - // Code commented out until we begin auto adding users to NewUI - // const { isMascara, identities = {}, featureFlags = {} } = store.getState().metamask - // const firstTime = Object.keys(identities).length === 0 - const { isMascara, featureFlags = {} } = store.getState().metamask - let betaUIState = featureFlags.betaUI - - // Code commented out until we begin auto adding users to NewUI - // const useBetaCss = isMascara || firstTime || betaUIState - const useBetaCss = isMascara || betaUIState - - let css = useBetaCss ? NewMetaMaskUiCss() : OldMetaMaskUiCss() - let deleteInjectedCss = injectCss(css) - let newBetaUIState - - store.subscribe(() => { - const state = store.getState() - newBetaUIState = state.metamask.featureFlags.betaUI - if (newBetaUIState !== betaUIState) { - deleteInjectedCss() - betaUIState = newBetaUIState - css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss() - deleteInjectedCss = injectCss(css) - } - if (state.appState.shouldClose) notificationManager.closePopup() - }) - }) - - - function closePopupIfOpen (windowType) { - if (windowType !== 'notification') { - // should close only chrome popup - notificationManager.closePopup() - } - } - - function displayCriticalError (err) { - container.innerHTML = '
The MetaMask app failed to load: please open and close MetaMask again to restart.
' - container.style.height = '80px' - log.error(err.stack) - throw err - } - -} diff --git a/app/scripts/ui.js b/app/scripts/ui.js new file mode 100644 index 000000000..13c7ac5ec --- /dev/null +++ b/app/scripts/ui.js @@ -0,0 +1,84 @@ +const injectCss = require('inject-css') +const OldMetaMaskUiCss = require('../../old-ui/css') +const NewMetaMaskUiCss = require('../../ui/css') +const startPopup = require('./popup-core') +const PortStream = require('./lib/port-stream.js') +const isPopupOrNotification = require('./lib/is-popup-or-notification') +const extension = require('extensionizer') +const ExtensionPlatform = require('./platforms/extension') +const NotificationManager = require('./lib/notification-manager') +const notificationManager = new NotificationManager() +const setupRaven = require('./lib/setupRaven') + +start().catch(log.error) + +async function start() { + + // create platform global + global.platform = new ExtensionPlatform() + + // setup sentry error reporting + const release = global.platform.getVersion() + setupRaven({ release }) + + // inject css + // const css = MetaMaskUiCss() + // injectCss(css) + + // identify window type (popup, notification) + const windowType = isPopupOrNotification() + global.METAMASK_UI_TYPE = windowType + closePopupIfOpen(windowType) + + // setup stream to background + const extensionPort = extension.runtime.connect({ name: windowType }) + const connectionStream = new PortStream(extensionPort) + + // start ui + const container = document.getElementById('app-content') + startPopup({ container, connectionStream }, (err, store) => { + if (err) return displayCriticalError(err) + + // Code commented out until we begin auto adding users to NewUI + // const { isMascara, identities = {}, featureFlags = {} } = store.getState().metamask + // const firstTime = Object.keys(identities).length === 0 + const { isMascara, featureFlags = {} } = store.getState().metamask + let betaUIState = featureFlags.betaUI + + // Code commented out until we begin auto adding users to NewUI + // const useBetaCss = isMascara || firstTime || betaUIState + const useBetaCss = isMascara || betaUIState + + let css = useBetaCss ? NewMetaMaskUiCss() : OldMetaMaskUiCss() + let deleteInjectedCss = injectCss(css) + let newBetaUIState + + store.subscribe(() => { + const state = store.getState() + newBetaUIState = state.metamask.featureFlags.betaUI + if (newBetaUIState !== betaUIState) { + deleteInjectedCss() + betaUIState = newBetaUIState + css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss() + deleteInjectedCss = injectCss(css) + } + if (state.appState.shouldClose) notificationManager.closePopup() + }) + }) + + + function closePopupIfOpen (windowType) { + if (windowType !== 'notification') { + // should close only chrome popup + notificationManager.closePopup() + } + } + + function displayCriticalError (err) { + container.innerHTML = '
The MetaMask app failed to load: please open and close MetaMask again to restart.
' + container.style.height = '80px' + log.error(err.stack) + throw err + } + +} -- cgit v1.2.3 From 253abd60fca5a6efb1a2e0ecbe305989a852ec32 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 21:29:57 -0700 Subject: build - extension - move js files to toplevel --- app/home.html | 2 +- app/manifest.json | 10 +++++----- app/notification.html | 2 +- app/popup.html | 2 +- app/scripts/contentscript.js | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/home.html b/app/home.html index bb8e936a3..4fad0f993 100644 --- a/app/home.html +++ b/app/home.html @@ -7,6 +7,6 @@
- + diff --git a/app/manifest.json b/app/manifest.json index a20f9b976..1982b4820 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -27,8 +27,8 @@ "default_locale": "en", "background": { "scripts": [ - "scripts/chromereload.js", - "scripts/background.js" + "chromereload.js", + "background.js" ], "persistent": true }, @@ -48,7 +48,7 @@ "https://*/*" ], "js": [ - "scripts/contentscript.js" + "contentscript.js" ], "run_at": "document_start", "all_frames": true @@ -62,11 +62,11 @@ "https://*.infura.io/" ], "web_accessible_resources": [ - "scripts/inpage.js" + "inpage.js" ], "externally_connectable": { "matches": [ "https://metamask.io/*" ] } -} \ No newline at end of file +} diff --git a/app/notification.html b/app/notification.html index 2255ca2c1..457ba7137 100644 --- a/app/notification.html +++ b/app/notification.html @@ -11,6 +11,6 @@
- + diff --git a/app/popup.html b/app/popup.html index 109487d3e..3acfd8c55 100644 --- a/app/popup.html +++ b/app/popup.html @@ -7,6 +7,6 @@
- + diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 7abbc60e7..2098fae27 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -7,8 +7,8 @@ const ObjectMultiplex = require('obj-multiplex') const extension = require('extensionizer') const PortStream = require('./lib/port-stream.js') -const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'scripts', 'inpage.js')).toString() -const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('scripts/inpage.js') + '\n' +const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString() +const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n' const inpageBundle = inpageContent + inpageSuffix // Eventually this streaming injection could be replaced with: @@ -96,7 +96,7 @@ function logStreamDisconnectWarning (remoteLabel, err) { } function shouldInjectWeb3 () { - return doctypeCheck() && suffixCheck() + return doctypeCheck() && suffixCheck() && documentElementCheck() && !blacklistedDomainCheck() } -- cgit v1.2.3