2020-10-21 23:10:55 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2018-04-17 08:03:47 +02:00
|
|
|
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
2019-08-08 16:50:32 +02:00
|
|
|
const ENVIRONMENT_TYPE_BACKGROUND = 'background'
|
2018-04-17 08:03:47 +02:00
|
|
|
|
2018-08-08 09:00:39 +02:00
|
|
|
const PLATFORM_BRAVE = 'Brave'
|
|
|
|
const PLATFORM_CHROME = 'Chrome'
|
|
|
|
const PLATFORM_EDGE = 'Edge'
|
|
|
|
const PLATFORM_FIREFOX = 'Firefox'
|
|
|
|
const PLATFORM_OPERA = 'Opera'
|
|
|
|
|
2020-06-04 21:22:45 +02:00
|
|
|
const MESSAGE_TYPE = {
|
|
|
|
ETH_DECRYPT: 'eth_decrypt',
|
|
|
|
ETH_GET_ENCRYPTION_PUBLIC_KEY: 'eth_getEncryptionPublicKey',
|
|
|
|
ETH_SIGN: 'eth_sign',
|
|
|
|
ETH_SIGN_TYPED_DATA: 'eth_signTypedData',
|
2020-12-08 20:48:47 +01:00
|
|
|
GET_PROVIDER_STATE: 'metamask_getProviderState',
|
2020-12-07 21:09:02 +01:00
|
|
|
LOG_WEB3_SHIM_USAGE: 'metamask_logWeb3ShimUsage',
|
2020-06-04 21:22:45 +02:00
|
|
|
PERSONAL_SIGN: 'personal_sign',
|
2020-12-02 17:49:49 +01:00
|
|
|
WATCH_ASSET: 'wallet_watchAsset',
|
|
|
|
WATCH_ASSET_LEGACY: 'metamask_watchAsset',
|
2020-06-04 21:22:45 +02:00
|
|
|
}
|
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
export {
|
2018-04-17 08:03:47 +02:00
|
|
|
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
2019-08-08 16:50:32 +02:00
|
|
|
ENVIRONMENT_TYPE_BACKGROUND,
|
2020-06-04 21:22:45 +02:00
|
|
|
MESSAGE_TYPE,
|
2018-08-08 09:00:39 +02:00
|
|
|
PLATFORM_BRAVE,
|
|
|
|
PLATFORM_CHROME,
|
|
|
|
PLATFORM_EDGE,
|
|
|
|
PLATFORM_FIREFOX,
|
|
|
|
PLATFORM_OPERA,
|
2018-04-17 08:03:47 +02:00
|
|
|
}
|