|
|
|
/**
|
|
|
|
* A string representing the type of environment the application is currently running in
|
|
|
|
* popup - When the user click's the icon in their browser's extension bar; the default view
|
|
|
|
* notification - When the extension opens due to interaction with a Web3 enabled website
|
|
|
|
* fullscreen - When the user clicks 'expand view' to open the extension in a new tab
|
|
|
|
* background - The background process that powers the extension
|
|
|
|
* @typedef {'popup' | 'notification' | 'fullscreen' | 'background'} EnvironmentType
|
|
|
|
*/
|
|
|
|
|
|
|
|
const ENVIRONMENT_TYPE_POPUP = 'popup'
|
|
|
|
const ENVIRONMENT_TYPE_NOTIFICATION = 'notification'
|
|
|
|
const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen'
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
const ENVIRONMENT_TYPE_BACKGROUND = 'background'
|
|
|
|
|
|
|
|
const PLATFORM_BRAVE = 'Brave'
|
|
|
|
const PLATFORM_CHROME = 'Chrome'
|
|
|
|
const PLATFORM_EDGE = 'Edge'
|
|
|
|
const PLATFORM_FIREFOX = 'Firefox'
|
|
|
|
const PLATFORM_OPERA = 'Opera'
|
|
|
|
|
|
|
|
const MESSAGE_TYPE = {
|
|
|
|
ETH_DECRYPT: 'eth_decrypt',
|
|
|
|
ETH_GET_ENCRYPTION_PUBLIC_KEY: 'eth_getEncryptionPublicKey',
|
|
|
|
ETH_SIGN: 'eth_sign',
|
|
|
|
ETH_SIGN_TYPED_DATA: 'eth_signTypedData',
|
|
|
|
LOG_WEB3_USAGE: 'metamask_logInjectedWeb3Usage',
|
|
|
|
PERSONAL_SIGN: 'personal_sign',
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
ENVIRONMENT_TYPE_POPUP,
|
|
|
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
|
|
|
ENVIRONMENT_TYPE_FULLSCREEN,
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
ENVIRONMENT_TYPE_BACKGROUND,
|
|
|
|
MESSAGE_TYPE,
|
|
|
|
PLATFORM_BRAVE,
|
|
|
|
PLATFORM_CHROME,
|
|
|
|
PLATFORM_EDGE,
|
|
|
|
PLATFORM_FIREFOX,
|
|
|
|
PLATFORM_OPERA,
|
|
|
|
}
|