Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

[WIP] Use Electron event to set urlbar security state #5501

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/renderer/components/urlBarIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ class UrlBarIcon extends ImmutableComponent {
*/
get isInsecure () {
return this.props.isHTTPPage &&
!this.props.isSecure &&
this.props.isSecure === false &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] if isSecure is null, we should show neither secure nor insecure

!this.props.active &&
this.props.loading === false &&
!this.props.titleMode
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was no longer needed because security state is set to null when the load starts

}
/**
Expand Down Expand Up @@ -63,7 +62,7 @@ class UrlBarIcon extends ImmutableComponent {
// NOTE: EV style not approved yet; see discussion at https://github.com/brave/browser-laptop/issues/791
'fa-lock': this.isSecure,
'fa-exclamation-triangle': this.isInsecure,
'fa fa-search': this.isSearch
'fa-search': this.isSearch
})
}
get iconStyles () {
Expand Down
33 changes: 22 additions & 11 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -916,17 +916,12 @@ class Frame extends ImmutableComponent {
interceptFlash(true, e.url)
}
windowActions.onWebviewLoadStart(this.frame, e.url)
// Clear security state
windowActions.setBlockedRunInsecureContent(this.frame)
const isSecure = parsedUrl.protocol === 'https:' && !this.runInsecureContent()
const runInsecureContent = parsedUrl.protocol === 'https:' && this.runInsecureContent()
windowActions.setSecurityState(this.frame, {
secure: isSecure,
runInsecureContent: runInsecureContent
secure: null,
runInsecureContent: false
})
if (isSecure) {
// Check that there isn't a cert error.
ipc.send(messages.CHECK_CERT_ERROR_ACCEPTED, parsedUrl.host, this.props.frameKey)
}
}
windowActions.updateBackForwardState(
this.frame,
Expand Down Expand Up @@ -1000,11 +995,27 @@ class Frame extends ImmutableComponent {
windowActions.setNavigated(this.webview.getURL(), this.props.frameKey, true, this.frame.get('tabId'))
}
}
this.webview.addEventListener('load-commit', (e) => {
loadStart(e)
this.webview.addEventListener('did-change-security', (e) => {
let isSecure = null
let runInsecureContent = false
if (e.securityState === 'secure') {
isSecure = true
runInsecureContent = this.runInsecureContent()
} else if (e.securityState === 'insecure') {
isSecure = false
}
// TODO: handle 'warning' security state
windowActions.setSecurityState(this.frame, {
secure: isSecure,
runInsecureContent
})
if (isSecure) {
// Check that there isn't a cert error.
const parsedUrl = urlParse(this.props.location)
ipc.send(messages.CHECK_CERT_ERROR_ACCEPTED, parsedUrl.host, this.props.frameKey)
}
})
this.webview.addEventListener('load-start', (e) => {
// XXX: loadstart probably does not need to be called twice anymore.
loadStart(e)
})

Expand Down
1 change: 0 additions & 1 deletion js/components/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ class UrlBar extends ImmutableComponent {
onContextMenu={this.onContextMenu}
data-l10n-id='urlbar'
className={cx({
insecure: !this.props.isSecure && this.props.loading === false && !this.isHTTPPage,
private: this.private,
testHookLoadDone: !this.props.loading
})}
Expand Down