Skip to content

Commit

Permalink
Fixes issue brave#791, frontend EV certificate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sashaperigo authored and darkdh committed Nov 29, 2017
1 parent 0147755 commit ad2af28
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
7 changes: 6 additions & 1 deletion app/renderer/components/frame/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,12 @@ class Frame extends React.Component {
}
let isSecure = null
let runInsecureContent = this.props.runInsecureContent
let evString
if (e.securityState === 'secure') {
isSecure = true
if (e.evString) {
evString = e.evString
}
} else if (e.securityState === 'insecure') {
isSecure = false
} else if (e.securityState === 'broken') {
Expand All @@ -690,7 +694,8 @@ class Frame extends React.Component {
}
windowActions.setSecurityState(this.props.tabId, {
secure: runInsecureContent ? false : isSecure,
runInsecureContent
runInsecureContent,
evString
})
}, { passive: true })
this.webview.addEventListener('load-start', (e) => {
Expand Down
24 changes: 17 additions & 7 deletions app/renderer/components/navigation/urlBarIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class UrlBarIcon extends React.Component {
} else if (this.props.isAboutPage && !this.props.titleMode) {
return ['fa-list']
} else if (this.props.isHTTPPage && !this.props.active) {
if (this.props.isSecure === true) {
if (this.props.isSecure && this.props.evString) {
return ['fa-lock', 'extendedValidation']
} else if (this.props.isSecure === true) {
return ['fa-lock']
} else if (this.props.isSecure === false || this.props.isSecure === 2) {
return ['fa-unlock', 'insecure-color']
Expand Down Expand Up @@ -149,6 +151,7 @@ class UrlBarIcon extends React.Component {
props.activateSearchEngine = urlBar.getIn(['searchDetail', 'activateSearchEngine'])
props.active = urlBar.get('active')
props.isSecure = activeFrame.getIn(['security', 'isSecure'])
props.evString = activeFrame.getIn(['security', 'evString'])
props.location = displayURL
props.isHTTPPage = UrlUtil.isHttpOrHttps(props.location)
props.searchSelectImage = urlBar.getIn(['searchDetail', 'image'], '')
Expand All @@ -174,12 +177,19 @@ class UrlBarIcon extends React.Component {
props.onDragStart = this.onDragStart
}

return <span
data-test-id='urlBarIcon'
data-test2-id={this.dataTestId}
{...props}
className={this.iconClasses}
style={this.iconStyles} />
return <span>
<span
data-test-id='urlBarIcon'
data-test2-id={this.dataTestId}
{...props}
className={this.iconClasses}
style={this.iconStyles} />
{
this.props.evString
? <span data-test-id='evString' className='evString'>{this.props.evString}</span>
: null
}
</span>
}
}

Expand Down
1 change: 1 addition & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ WindowStore
security: {
blockedRunInsecureContent: Array<string>, // sources of blocked active mixed content
isSecure: (boolean|number), // true = fully secure, false = fully insecure, 1 = partially secure, 2 = cert error
evString: string,
loginRequiredDetail: {
isProxy: boolean,
host: string,
Expand Down
5 changes: 5 additions & 0 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ const doAction = (action) => {
windowState.deleteIn(statePath('frames').concat(['security', 'blockedRunInsecureContent']))
windowState = windowState.mergeIn(statePath('frames').concat(['security']), {
isSecure: null,
evString: undefined,
runInsecureContent: false
})
// Update loading UI
Expand Down Expand Up @@ -620,6 +621,10 @@ const doAction = (action) => {
windowState = windowState.setIn(path.concat(['security', 'isSecure']),
action.securityState.secure)
}
if (action.securityState.evString !== undefined) {
windowState = windowState.setIn(path.concat(['security', 'evString']),
action.securityState.evString)
}
if (action.securityState.runInsecureContent !== undefined) {
windowState = windowState.setIn(path.concat(['security', 'runInsecureContent']),
action.securityState.runInsecureContent)
Expand Down
11 changes: 9 additions & 2 deletions less/navigationBar.less
Original file line number Diff line number Diff line change
Expand Up @@ -863,9 +863,7 @@
align-items: center;
justify-content: center;
height: @urlbarFormHeight;
width: @urlbarFormHeight;
min-height: @urlbarFormHeight;
min-width: @urlbarFormHeight;

.urlbarIcon {
color: @siteSecureColor;
Expand All @@ -874,6 +872,8 @@
background-position: center;
position: relative;
bottom: -1px;
width: @urlbarFormHeight;
min-width: @urlbarFormHeight;

// about:newtab
&.fa-search {
Expand All @@ -898,6 +898,13 @@
color: @siteEVColor;
}
}

.evString {
font-size: 16px;
color: green;
max-width: 150px;
padding-right: 0.5em;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/unit/js/stores/windowStoreTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ describe('Window store unit tests', function () {
windowState.getIn(['frames', 0, 'security']),
Immutable.fromJS({
isSecure: null,
runInsecureContent: false
runInsecureContent: false,
evString: undefined
}))
})
})
Expand Down

0 comments on commit ad2af28

Please sign in to comment.