From 3932e5db2fb6dd14be119eba1e465441b872255e Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Fri, 26 May 2017 14:27:49 -0700 Subject: [PATCH] Update passwords and blacklist when deleting 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 --- app/autofill.js | 13 +++++++++++++ app/browser/tabs.js | 18 +++++++++++------- js/about/passwords.js | 4 ++++ js/constants/messages.js | 2 ++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/autofill.js b/app/autofill.js index 0d54cbf967e..c1589363dc8 100644 --- a/app/autofill.js +++ b/app/autofill.js @@ -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) => { @@ -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) + }) +} diff --git a/app/browser/tabs.js b/app/browser/tabs.js index 6e7e77545bf..68a7c28a352 100644 --- a/app/browser/tabs.js +++ b/app/browser/tabs.js @@ -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 @@ -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() @@ -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') { diff --git a/js/about/passwords.js b/js/about/passwords.js index aa7048d5b7c..9d5c0f68586 100644 --- a/js/about/passwords.js +++ b/js/about/passwords.js @@ -64,6 +64,7 @@ class SiteItem extends React.Component { onDelete () { aboutActions.deletePassword(this.props.site.toJS()) + ipc.send(messages.UPDATE_PASSWORD_SITE_DETAILS) } render () { @@ -95,6 +96,7 @@ class PasswordItem extends React.Component { onDelete () { aboutActions.deletePassword(this.props.password.toJS()) + ipc.send(messages.UPDATE_PASSWORD_DETAILS) } onCopy () { @@ -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) } } diff --git a/js/constants/messages.js b/js/constants/messages.js index e8eb61d9984..e2e22d22377 100644 --- a/js/constants/messages.js +++ b/js/constants/messages.js @@ -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