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

Commit

Permalink
Update passwords and blacklist when deleting
Browse files Browse the repository at this point in the history
fix #8906
resolve item 1 of #8874

Auditors: @diracdeltas, @bridiver

Test Plan:
1. Makue sure you have passwords and never saved sites in
about:passwords
2. delete any of them or clear all passwords should relfect changes
instantly
  • Loading branch information
darkdh committed May 26, 2017
1 parent de97b76 commit 3932e5d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
13 changes: 13 additions & 0 deletions app/autofill.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const electron = require('electron')
const session = electron.session
const appActions = require('../js/actions/appActions')
const messages = require('../js/constants/messages')

module.exports.init = () => {
process.on('personal-data-changed', (profileGuids, creditCardGuids) => {
Expand Down Expand Up @@ -68,3 +69,15 @@ module.exports.removeLogin = (form) => {
module.exports.clearLogins = (form) => {
session.defaultSession.autofill.clearLogins(form)
}

module.exports.getAutofillableLogins = (tab) => {
session.defaultSession.autofill.getAutofillableLogins((result) => {
tab.send(messages.PASSWORD_DETAILS_UPDATED, result)
})
}

module.exports.getBlackedlistLogins = (tab) => {
session.defaultSession.autofill.getBlackedlistLogins((result) => {
tab.send(messages.PASSWORD_SITE_DETAILS_UPDATED, result)
})
}
18 changes: 11 additions & 7 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const appConfig = require('../../js/constants/appConfig')
const siteTags = require('../../js/constants/siteTags')
const {newTabMode} = require('../common/constants/settingsEnums')
const {cleanupWebContents, currentWebContents, getWebContents, updateWebContents} = require('./webContentsCache')
const autofill = require('../autofill')

let currentPartitionNumber = 0
const incrementPartitionNumber = () => ++currentPartitionNumber
Expand Down Expand Up @@ -131,6 +132,14 @@ ipcMain.on(messages.ABOUT_COMPONENT_INITIALIZED, (e) => {
})
})

ipcMain.on(messages.UPDATE_PASSWORD_DETAILS, (e) => {
autofill.getAutofillableLogins(e.sender)
})

ipcMain.on(messages.UPDATE_PASSWORD_SITE_DETAILS, (e) => {
autofill.getBlackedlistLogins(e.sender)
})

const getBookmarksData = function (state) {
let bookmarkSites = new Immutable.Map()
let bookmarkFolderSites = new Immutable.Map()
Expand Down Expand Up @@ -209,13 +218,8 @@ const updateAboutDetails = (tab, tabValue) => {
downloads: downloads.toJS()
})
} else if (location === 'about:passwords' && passwords) {
const defaultSession = session.defaultSession
defaultSession.autofill.getAutofillableLogins((result) => {
tab.send(messages.PASSWORD_DETAILS_UPDATED, result)
})
defaultSession.autofill.getBlackedlistLogins((result) => {
tab.send(messages.PASSWORD_SITE_DETAILS_UPDATED, result)
})
autofill.getAutofillableLogins(tab)
autofill.getBlackedlistLogins(tab)
} else if (location === 'about:flash') {
tab.send(messages.BRAVERY_DEFAULTS_UPDATED, braveryDefaults.toJS())
} else if (location === 'about:newtab') {
Expand Down
4 changes: 4 additions & 0 deletions js/about/passwords.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SiteItem extends React.Component {

onDelete () {
aboutActions.deletePassword(this.props.site.toJS())
ipc.send(messages.UPDATE_PASSWORD_SITE_DETAILS)
}

render () {
Expand Down Expand Up @@ -95,6 +96,7 @@ class PasswordItem extends React.Component {

onDelete () {
aboutActions.deletePassword(this.props.password.toJS())
ipc.send(messages.UPDATE_PASSWORD_DETAILS)
}

onCopy () {
Expand Down Expand Up @@ -165,6 +167,8 @@ class AboutPasswords extends React.Component {
'This cannot be undone.'
if (window.confirm(msg)) {
aboutActions.clearPasswords()
ipc.send(messages.UPDATE_PASSWORD_DETAILS)
ipc.send(messages.UPDATE_PASSWORD_SITE_DETAILS)
}
}

Expand Down
2 changes: 2 additions & 0 deletions js/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const messages = {
GET_MISSPELLING_INFO: _, /** @arg {string} word, the word to lookup */
PASSWORD_DETAILS_UPDATED: _, /** @arg {Object} passwords app state */
PASSWORD_SITE_DETAILS_UPDATED: _, /** @arg {Object} passwords app state */
UPDATE_PASSWORD_DETAILS: _,
UPDATE_PASSWORD_SITE_DETAILS: _,
// Init
INITIALIZE_WINDOW: _,
// Session restore
Expand Down

0 comments on commit 3932e5d

Please sign in to comment.