From 88f6eab0908ee05e67f4883ca3419681e7de39ef Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 9 Feb 2015 08:55:47 +0000 Subject: Propagate queries to incognito-mode tabs. --- content_scripts/vimium_frontend.coffee | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 9a50d373..06eaf334 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -551,16 +551,16 @@ FindModeHistory = @key = "findModeRawQueryListIncognito" if isIncognitoMode @storage.get @key, (items) => unless chrome.runtime.lastError - @rawQueryList = items[@key] - if isIncognitoMode and not @rawQueryList - # This is the first incognito tab, we need to initialize the incognito-mode query history. + @rawQueryList = items[@key] if items[@key] + if isIncognitoMode and not items[@key] + # This is the first incognito tab, so we need to initialize the incognito-mode query history. @storage.get "findModeRawQueryList", (items) => unless chrome.runtime.lastError @rawQueryList = items.findModeRawQueryList @storage.set findModeRawQueryListIncognito: @rawQueryList chrome.storage.onChanged.addListener (changes, area) => - @rawQueryList = changes[@key].newValue if changes[@key]?.newValue? + @rawQueryList = changes[@key].newValue if changes[@key]? getQuery: (index = 0) -> @rawQueryList?[index] or "" @@ -570,6 +570,12 @@ FindModeHistory = @rawQueryList = ([ query ].concat @rawQueryList.filter (q) => q != query)[0..@max] newSetting = {}; newSetting[@key] = @rawQueryList @storage.set newSetting + # Now, check whether we need to propagte this query to incognito mode too. + unless isIncognitoMode + @storage.get "findModeRawQueryListIncognito", (items) => + if not chrome.runtime.lastError and items.findModeRawQueryListIncognito + rawQueryList = ([ query ].concat items.findModeRawQueryListIncognito.filter (q) => q != query)[0..@max] + @storage.set findModeRawQueryListIncognito: rawQueryList # should be called whenever rawQuery is modified. updateFindModeQuery = -> -- cgit v1.2.3