diff options
| author | Stephen Blott | 2015-02-08 15:30:04 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-02-08 15:30:04 +0000 | 
| commit | 11609b918485ee4c3a659bee9dc0c420fb04ddcc (patch) | |
| tree | 00c646a5b60908c2cc44010c455b15e9eda3ecb1 | |
| parent | 7b451aaca8d8c84aab77ac262753c6239b466791 (diff) | |
| download | vimium-11609b918485ee4c3a659bee9dc0c420fb04ddcc.tar.bz2 | |
Proper find-mode history for incognito mode.
Approach:
   - We never save the find mode history from an incognito tab in the
     settings, instead they are saved in the tabMapInfo for each
     currently-active incognito tab.
   - When a new incognito tab (or page, after navigation) starts, we
     scan the tabMapInfo looking for the find-mode history of any active
     tab.
In this way, the history is shared between incognito tabs, but discarded
once the last incognito tab closes.
| -rw-r--r-- | background_scripts/main.coffee | 12 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 14 | 
2 files changed, 25 insertions, 1 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 54e0491b..b4eac4f1 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -193,6 +193,15 @@ handleSettings = (args, port) ->      # In the case of findModeRawQueryList, this allows each tab to accurately track the find-mode history.      if args.key in [ "findModeRawQueryList" ]        sendRequestToAllTabs extend args, name: "updateSettings" +    # We also track the incognito find-mode history setting in the tabInfoMap for all incognito tabs. +    if args.incognito and args.key == "findModeRawQueryList" +      for own _, map of tabInfoMap +        map.findModeRawQueryList = args.value if map.incognito + +# Search through the active tab map for an up-to-date find-mode history for an incognito-mode tab. +getIncognitoRawQueryList = -> +  for own id, map of tabInfoMap +    return map.findModeRawQueryList if map.findModeRawQueryList  refreshCompleter = (request) -> completers[request.name].refresh() @@ -337,6 +346,8 @@ updateOpenTabs = (tab) ->      scrollX: null      scrollY: null      deletor: null +    incognito: tab.incognito +    findModeRawQueryList: null    # Frames are recreated on refresh    delete frameIdsForTab[tab.id] @@ -661,6 +672,7 @@ sendRequestHandlers =    createMark: Marks.create.bind(Marks)    gotoMark: Marks.goto.bind(Marks)    setBadge: setBadge +  getIncognitoRawQueryList: getIncognitoRawQueryList  # Convenience function for development use.  window.runTests = -> open(chrome.runtime.getURL('tests/dom_tests/dom_tests.html')) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index b9737ffd..3d40e307 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -123,6 +123,12 @@ window.initializeModes = ->    new InsertMode permanent: true  # +# Called if we learn that this frame is in incognito mode. +# +goIncognito = -> +  FindModeHistory.goIncognito() + +#  # Complete initialization work that sould be done prior to DOMReady.  #  initializePreDomReady = -> @@ -197,6 +203,7 @@ window.initializeWhenEnabled = ->  setState = (request) ->    isEnabledForUrl = request.enabled    passKeys = request.passKeys +  goIncognito() if request.incognito and not isIncognitoMode    isIncognitoMode = request.incognito    initializeWhenEnabled() if isEnabledForUrl    handlerStack.bubbleEvent "registerStateChange", @@ -556,7 +563,7 @@ FindModeHistory =      # This update path is only used to initialize @rawQueryList.  Thereafter, we use updateFindModeHistory to      # track the history.      settings.postUpdateHooks.findModeRawQueryList = (args...) -> FindModeHistory.postUpdateHook args... -    (rawQueryList) -> @rawQueryList ||= rawQueryList +    (rawQueryList) -> @rawQueryList = rawQueryList unless @rawQueryList?    # This is called when we receive an updateSettings message from the background page.  It is called    # synchronously with the update from another tab.  Therefore, we know that only the most-recent query can @@ -577,6 +584,11 @@ FindModeHistory =        @updateRawQueryList query        settings.set "findModeRawQueryList", @rawQueryList +  goIncognito: -> +    # In incognito mode, we try to fetch the query history from another incognito tab.  See #1465. +    chrome.runtime.sendMessage { handler: "getIncognitoRawQueryList" }, (response) => +      @rawQueryList = response if response +  # should be called whenever rawQuery is modified.  updateFindModeQuery = ->    # the query can be treated differently (e.g. as a plain string versus regex depending on the presence of | 
