From a04e0379efab5984c4e15d1a27109e2384b0bd8f Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Sun, 4 Sep 2016 18:39:13 +0800 Subject: [PATCH] Add clearAutocompleteData & clearAutofillData to clearBrowsingDataPanel and clear on shutdown fix #3458 required https://github.com/brave/electron/pull/53 Auditors: @bridiver, @bbondy Test Plan: For autocomplete data in clearBrowsingDataPanel: 1. Go to site contains form and submit form after input some value 2. Double click the input field to make sure it popup the value you previous input 3. Go to "about:preferences#security" and click "Clear Browsing Data Now..." 4. Toggle on "Autocomplete data" and click "Clear" 5. Go previous site you submitted form 6. Double click the input field should popup nothing For autocomplete data clear on shutdown: 1. Go to site contains form and submit form after input some value 2. Double click the input field to make sure it popup the value you previous input 3. Go to "about:preferences#security" and toggle on "Autocomplete data" 4. Quit brave and relaunch it 5. Go previous site you submitted form 6. Double click the input field should popup nothing For autofill data in clearBrowsingDataPanel: 1. Add address and credit card in "about:autofill" 2. Go to the site you usually verify autofill and verify it 3. Go to "about:preferences#security" and click "Clear Browsing Data Now..." 4. Toggle on "Autofill data" and click "Clear" 5. Go previous site you verify autofill 6. Double click the input field should popup nothing For autofill data clear on shutdown: 1. Add address and credit card in "about:autofill" 2. Go to the site you usually verify autofill and verify it 3. Go to "about:preferences#security" and toggle on "Autofill data" 4. Quit brave and relaunch it 5. Go previous site you verify autofill 6. Double click the input field should popup nothing --- .../brave/locales/en-US/app.properties | 2 + .../locales/en-US/preferences.properties | 2 + app/filtering.js | 14 ++ app/sessionStore.js | 8 + js/about/preferences.js | 2 + js/components/clearBrowsingDataPanel.js | 4 + js/constants/appConfig.js | 4 +- js/constants/settings.js | 2 + js/stores/appStore.js | 8 + test/components/autofillTest.js | 199 +++++++++++++++++- 10 files changed, 243 insertions(+), 2 deletions(-) diff --git a/app/extensions/brave/locales/en-US/app.properties b/app/extensions/brave/locales/en-US/app.properties index 2c9ebd61d77..4d9fbe29f93 100644 --- a/app/extensions/brave/locales/en-US/app.properties +++ b/app/extensions/brave/locales/en-US/app.properties @@ -174,6 +174,8 @@ downloadHistory=Download history cachedImagesAndFiles=Cached images and files savedPasswords=Saved passwords allSiteCookies=All site cookies +autofillData=Autofill data +autocompleteData=Autocomplete data clear=Clear clearDataWarning=Warning: Selected data, back to the day you installed Brave will be cleared and cannot be undone. clearBrowsingData=Clear browsing data diff --git a/app/extensions/brave/locales/en-US/preferences.properties b/app/extensions/brave/locales/en-US/preferences.properties index d75120870c4..d0af5433950 100644 --- a/app/extensions/brave/locales/en-US/preferences.properties +++ b/app/extensions/brave/locales/en-US/preferences.properties @@ -184,6 +184,8 @@ browsingHistory=Browsing history downloadHistory=Download history cachedImagesAndFiles=Cached images and files allSiteCookies=All site cookies +autofillData=Autofill data +autocompleteData=Autocomplete data passwordsAndForms=Passwords and Forms tabSettings=Tab Settings clearBrowsingDataNow=Clear Browsing Data Now... diff --git a/app/filtering.js b/app/filtering.js index 21ffaccc25f..4454d238892 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -646,3 +646,17 @@ module.exports.removeAutofillCreditCard = (guid) => { } } } + +module.exports.clearAutocompleteData = () => { + for (let partition in registeredSessions) { + let ses = registeredSessions[partition] + ses.autofill.clearAutocompleteData() + } +} + +module.exports.clearAutofillData = () => { + for (let partition in registeredSessions) { + let ses = registeredSessions[partition] + ses.autofill.clearAutofillData() + } +} diff --git a/app/sessionStore.js b/app/sessionStore.js index d6c587af51e..0be12cea485 100644 --- a/app/sessionStore.js +++ b/app/sessionStore.js @@ -198,6 +198,14 @@ module.exports.cleanPerWindowData = (perWindowData, isShutdown) => { if (clearHistory) { perWindowData.closedFrames = [] } + const clearAutocompleteData = isShutdown && getSetting(settings.SHUTDOWN_CLEAR_AUTOCOMPLETE_DATA) === true + if (clearAutocompleteData) { + filtering.clearAutocompleteData() + } + const clearAutofillData = isShutdown && getSetting(settings.SHUTDOWN_CLEAR_AUTOFILL_DATA) === true + if (clearAutofillData) { + filtering.clearAutofillData() + } // Clean closed frame data before frames because the keys are re-ordered // and the new next key is calculated in windowStore.js based on diff --git a/js/about/preferences.js b/js/about/preferences.js index e834b9faa35..89e66e8199d 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -958,6 +958,8 @@ class SecurityTab extends ImmutableComponent { + +