Skip to content

Commit

Permalink
Restrict unconnected notice to specific protocols (#6954)
Browse files Browse the repository at this point in the history
The notice asking whether you wanted to connect to a site was showing
up in places it shouldn't, like on the Firefox/Chrome settings pages
and on our fullscreen extension. It has now been restricted to only
be displayed for active tabs with specific protocols:

* http
* https
* dat
* dweb
* ipfs
* ipns
* ssb

This prevents the notice from being shown on settings pages, browser
extensions, and files such as PDFs.
  • Loading branch information
Gudahtt authored Aug 2, 2019
1 parent 2649b9b commit 75d5374
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ async function queryCurrentActiveTab (windowType) {
extension.tabs.query({active: true, currentWindow: true}, (tabs) => {
const [activeTab] = tabs
const {title, url} = activeTab
const origin = url ? urlUtil.parse(url).hostname : null
const { hostname: origin, protocol } = url ? urlUtil.parse(url) : {}
resolve({
title, origin, url,
title, origin, protocol, url,
})
})
})
Expand Down
9 changes: 8 additions & 1 deletion ui/app/pages/home/home.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums'

const activeTabDappProtocols = ['http:', 'https:', 'dweb:', 'ipfs:', 'ipns:', 'ssb:']

const mapStateToProps = state => {
const { activeTab, metamask, appState } = state
const {
Expand All @@ -28,7 +30,12 @@ const mapStateToProps = state => {
const accountBalance = getCurrentEthBalance(state)
const { forgottenPassword } = appState

const isUnconnected = Boolean(activeTab && privacyMode && !approvedOrigins[activeTab.origin])
const isUnconnected = Boolean(
activeTab &&
activeTabDappProtocols.includes(activeTab.protocol) &&
privacyMode &&
!approvedOrigins[activeTab.origin]
)
const isPopup = getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP

return {
Expand Down

0 comments on commit 75d5374

Please sign in to comment.