aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJez Ng2013-03-06 04:25:23 -0500
committerJez Ng2013-03-06 04:25:23 -0500
commit25c871c9bfc15278d72b9d0b2821b92627a605c6 (patch)
tree7936f3212a76b6ef72f5feada6144f2e19b01465
parent4c5fcc544f016c0f06dfa548bd46bd4f6e46eeda (diff)
parent22093e34ab94bbdab4059f197a67f8b57dd0b99e (diff)
downloadvimium-25c871c9bfc15278d72b9d0b2821b92627a605c6.tar.bz2
Merge remote-tracking branch 'deiga/patch-4'
Conflicts: background_scripts/commands.coffee
-rw-r--r--background_scripts/commands.coffee4
-rw-r--r--background_scripts/main.coffee10
-rw-r--r--content_scripts/link_hints.coffee9
3 files changed, 22 insertions, 1 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index 05af51c2..5614e576 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -110,7 +110,7 @@ Commands =
advancedCommands: [
"scrollToLeft", "scrollToRight", "moveTabToNewWindow",
"goUp", "goToRoot", "focusInput", "LinkHints.activateModeWithQueue",
- "goPrevious", "goNext", "Marks.activateCreateMode", "Marks.activateGotoMode"]
+ "LinkHints.activateModeToOpenIncognitoWindow", "goNext", "Marks.activateCreateMode", "Marks.activateGotoMode"]
defaultKeyMappings =
"?": "showHelp"
@@ -217,6 +217,8 @@ commandDescriptions =
'LinkHints.activateModeToOpenInNewTab': ["Open a link in a new tab"]
'LinkHints.activateModeWithQueue': ["Open multiple links in a new tab"]
+ "LinkHints.activateModeToOpenIncognitoWindow": ["Open a link in incognito window"]
+
enterFindMode: ["Enter find mode"]
performFind: ["Cycle forward to the next find match"]
performBackwardsFind: ["Cycle backward to the previous find match"]
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 431d84be..3e6f2dad 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -60,6 +60,12 @@ chrome.extension.onRequest.addListener((request, sender, sendResponse) ->
# Ensure the sendResponse callback is freed.
return false)
+chrome.extension.onMessage.addListener((request, sender, sendResponse) ->
+ if (sendRequestHandlers[request.handler])
+ sendResponse(sendRequestHandlers[request.handler](request, sender))
+ # Ensure the sendResponse callback is freed.
+ return false)
+
#
# Used by the content scripts to get their full URL. This is needed for URLs like "view-source:http:# .."
# because window.location doesn't know anything about the Chrome-specific "view-source:".
@@ -162,6 +168,9 @@ openUrlInNewTab = (request) ->
chrome.tabs.getSelected(null, (tab) ->
chrome.tabs.create({ url: Utils.convertToUrl(request.url), index: tab.index + 1, selected: true }))
+openUrlInIncognitoWindow = (request) ->
+ chrome.windows.create({ url: Utils.convertToUrl(request.url), incognito: true})
+
#
# Called when the user has clicked the close icon on the "Vimium has been updated" message.
# We should now dismiss that message in all tabs.
@@ -555,6 +564,7 @@ sendRequestHandlers =
getCompletionKeys: getCompletionKeysRequest,
getCurrentTabUrl: getCurrentTabUrl,
openUrlInNewTab: openUrlInNewTab,
+ openUrlInIncognitoWindow: openUrlInIncognitoWindow,
openUrlInCurrentTab: openUrlInCurrentTab,
openOptionsPageInNewTab: openOptionsPageInNewTab,
registerFrame: registerFrame,
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 1f5e5d05..ad4a2686 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -12,6 +12,7 @@ OPEN_IN_CURRENT_TAB = {}
OPEN_IN_NEW_TAB = {}
OPEN_WITH_QUEUE = {}
COPY_LINK_URL = {}
+OPEN_INCOGNITO_WINDOW = {}
LinkHints =
hintMarkerContainingDiv: null
@@ -48,6 +49,7 @@ LinkHints =
activateModeToOpenInNewTab: -> @activateMode(OPEN_IN_NEW_TAB)
activateModeToCopyLinkUrl: -> @activateMode(COPY_LINK_URL)
activateModeWithQueue: -> @activateMode(OPEN_WITH_QUEUE)
+ activateModeToOpenIncognitoWindow: -> @activateMode(OPEN_INCOGNITO_WINDOW)
activateMode: (mode = OPEN_IN_CURRENT_TAB) ->
# we need documentElement to be ready in order to append links
@@ -90,6 +92,13 @@ LinkHints =
HUD.show("Copy link URL to Clipboard")
@linkActivator = (link) ->
chrome.extension.sendRequest({handler: "copyToClipboard", data: link.href})
+ else if @mode is OPEN_INCOGNITO_WINDOW
+ HUD.show("Open link in incognito window")
+
+ @linkActivator = (link) ->
+ chrome.extension.sendMessage(
+ handler: 'openUrlInIncognitoWindow'
+ url: link.href)
else # OPEN_IN_CURRENT_TAB
HUD.show("Open link in current tab")
# When we're opening the link in the current tab, don't navigate to the selected link immediately