From 23fcbbd366e2070819c22178bd45292569156b10 Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Tue, 30 Aug 2016 11:19:20 +0800 Subject: [PATCH] 1. make naming consistent 2. move site hacks to load start --- app/sessionStore.js | 3 ++- docs/state.md | 4 ++-- docs/windowActions.md | 9 +++++---- js/actions/windowActions.js | 11 ++++++----- js/components/frame.js | 23 ++++++++++------------- js/components/siteInfo.js | 18 +++++++++--------- js/constants/windowConstants.js | 3 +-- js/state/contentSettings.js | 4 ++-- js/stores/windowStore.js | 14 +++++++------- 9 files changed, 44 insertions(+), 45 deletions(-) diff --git a/app/sessionStore.js b/app/sessionStore.js index 6de3af3f854..bffb4327cbf 100644 --- a/app/sessionStore.js +++ b/app/sessionStore.js @@ -248,7 +248,8 @@ module.exports.cleanAppData = (data, isShutdown) => { if (typeof expireTime === 'number' && expireTime < now) { delete data.siteSettings[host].flash } - delete data.siteSettings[host].allowActiveMixedContent + // Don't write runInsecureContent to session + delete data.siteSettings[host].runInsecureContent } if (data.sites) { const clearHistory = isShutdown && getSetting(settings.SHUTDOWN_CLEAR_HISTORY) === true diff --git a/docs/state.md b/docs/state.md index 45b6ba48885..0b9222bc6c7 100644 --- a/docs/state.md +++ b/docs/state.md @@ -267,8 +267,8 @@ WindowStore realm: string }, isExtendedValidation: boolean, // is using https ev - isMixedContent: boolean, // has active mixed content - blockedMixedContent: string, // source of blocked mixed content + isRunInsecureConent: boolean, // has active mixed content + blockedRunInsecureConent: string, // source of blocked active mixed content }, parentFrameKey: number, // the key of the frame this frame was opened from modalPromptDetail: {...}, diff --git a/docs/windowActions.md b/docs/windowActions.md index 2639d687625..cb921022b9e 100644 --- a/docs/windowActions.md +++ b/docs/windowActions.md @@ -753,15 +753,16 @@ Sets the manage autofill credit card popup detail -### setBlockedMixedContent(frameProps, source) +### setBlockedRunInsecureContent(frameProps, source) -Sets which mixed content were blocked on a page. +Sets page url with blocked active mixed content. **Parameters** -**frameProps**: `Object`, The frame to set blocked mixed content on +**frameProps**: `Object`, The frame to set source of +blocked active mixed content on -**source**: `string`, Source of blocked mixed content +**source**: `string`, Source of blocked active mixed content diff --git a/js/actions/windowActions.js b/js/actions/windowActions.js index b7008f69b5b..e0a21f7dbb0 100644 --- a/js/actions/windowActions.js +++ b/js/actions/windowActions.js @@ -974,13 +974,14 @@ const windowActions = { }, /** - * Sets which mixed content were blocked on a page. - * @param {Object} frameProps - The frame to set blocked mixed content on - * @param {string} source - Source of blocked mixed content + * Sets page url with blocked active mixed content. + * @param {Object} frameProps - The frame to set source of + * blocked active mixed content on + * @param {string} source - Source of blocked active mixed content */ - setBlockedMixedContent: function (frameProps, source) { + setBlockedRunInsecureContent: function (frameProps, source) { dispatch({ - actionType: WindowConstants.WINDOW_SET_BLOCKED_MIXED_CONTENT, + actionType: WindowConstants.WINDOW_SET_BLOCKED_RUN_INSECURE_CONTENT, frameProps, source }) diff --git a/js/components/frame.js b/js/components/frame.js index ab22f71bdaf..3644b0ff6d8 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -159,10 +159,10 @@ class Frame extends ImmutableComponent { return !this.webview || !!this.webview.allowRunningPlugins !== this.allowRunningPlugins() } - allowActiveMixedContent () { + runInsecureContent () { const activeSiteSettings = getSiteSettingsForHostPattern(this.props.allSiteSettings, this.origin) return activeSiteSettings === undefined - ? false : activeSiteSettings.get('allowActiveMixedContent') + ? false : activeSiteSettings.get('runInsecureContent') } allowRunningPlugins (url) { @@ -571,13 +571,7 @@ class Frame extends ImmutableComponent { } }) this.webview.addEventListener('did-block-run-insecure-content', (e) => { - const hack = siteHacks[urlParse(this.props.location).hostname] - if (hack && hack.allowRunningInsecureContent) { - appActions.changeSiteSetting(this.origin, 'allowActiveMixedContent', true) - this.webview.reload() - } else { - windowActions.setBlockedMixedContent(this.frame, this.props.location) - } + windowActions.setBlockedRunInsecureContent(this.frame, this.props.location) }) this.webview.addEventListener('context-menu', (e) => { contextMenus.onMainContextMenu(e.params, this.frame) @@ -753,12 +747,12 @@ class Frame extends ImmutableComponent { interceptFlash(true, e.url) } windowActions.onWebviewLoadStart(this.frame, e.url) - windowActions.setBlockedMixedContent(this.frame) - const isSecure = parsedUrl.protocol === 'https:' && !this.allowActiveMixedContent() - const isMixedContent = parsedUrl.protocol === 'https:' && this.allowActiveMixedContent() + windowActions.setBlockedRunInsecureContent(this.frame) + const isSecure = parsedUrl.protocol === 'https:' && !this.runInsecureContent() + const isRunInsecureContent = parsedUrl.protocol === 'https:' && this.runInsecureContent() windowActions.setSecurityState(this.frame, { secure: isSecure, - mixedContent: isMixedContent + runInsecureContent: isRunInsecureContent }) if (isSecure) { // Check that there isn't a cert error. @@ -776,6 +770,9 @@ class Frame extends ImmutableComponent { if (this.doNotTrack) { this.webview.executeJavaScript('Navigator.prototype.__defineGetter__("doNotTrack", () => {return 1});') } + if (hack && hack.allowRunningInsecureContent) { + appActions.changeSiteSetting(this.origin, 'runInsecureContent', true) + } } const loadEnd = (savePage) => { windowActions.onWebviewLoadEnd( diff --git a/js/components/siteInfo.js b/js/components/siteInfo.js index 0be16d9ea0a..61444bf3ed6 100644 --- a/js/components/siteInfo.js +++ b/js/components/siteInfo.js @@ -18,8 +18,8 @@ class SiteInfo extends ImmutableComponent { this.onAllowMixedContent = this.onAllowMixedContent.bind(this) } onAllowMixedContent () { - appActions.changeSiteSetting(siteUtil.getOrigin(this.isMixedContentBlocked), 'allowActiveMixedContent', true) - ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_LOAD_URL, {}, this.isMixedContentBlocked) + appActions.changeSiteSetting(siteUtil.getOrigin(this.isBlockedRunInsecureContent), 'runInsecureContent', true) + ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_LOAD_URL, {}, this.isBlockedRunInsecureContent) this.props.onHide() } get isExtendedValidation () { @@ -28,25 +28,25 @@ class SiteInfo extends ImmutableComponent { get isSecure () { return this.props.frameProps.getIn(['security', 'isSecure']) } - get isMixedContent () { - return this.props.frameProps.getIn(['security', 'isMixedContent']) + get isRunInsecureContent () { + return this.props.frameProps.getIn(['security', 'isRunInsecureContent']) } - get isMixedContentBlocked () { - return this.props.frameProps.getIn(['security', 'blockedMixedContent']) + get isBlockedRunInsecureContent () { + return this.props.frameProps.getIn(['security', 'blockedRunInsecureContent']) } get partitionNumber () { return this.props.frameProps.getIn(['partitionNumber']) } render () { let secureIcon - if (this.isSecure && !this.isMixedContent) { + if (this.isSecure && !this.isRunInsecureContent) { secureIcon =
  • - } else if (this.isMixedContent) { + } else if (this.isRunInsecureContent) { secureIcon =
  • } else { secureIcon =
  • @@ -64,7 +64,7 @@ class SiteInfo extends ImmutableComponent { } let allowMixedContentButton - if (this.isMixedContentBlocked) { + if (this.isBlockedRunInsecureContent) { allowMixedContentButton =