From 6be1188dd75891d903f74b814a127878190cad59 Mon Sep 17 00:00:00 2001 From: Sudarshan Wadkar Date: Thu, 26 Feb 2015 22:53:32 -0500 Subject: Fix #1507 Open new tab in incognito mode - Change openUrlInNewTab to pass selected tab.windowId - Change createTab to use openUrlInNewTab --- background_scripts/main.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 647923c0..72b36b0b 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -165,7 +165,9 @@ openUrlInCurrentTab = (request) -> # openUrlInNewTab = (request) -> chrome.tabs.getSelected(null, (tab) -> - chrome.tabs.create({ url: Utils.convertToUrl(request.url), index: tab.index + 1, selected: true })) + # Pass selected tabs windowId to make sure we open in current window. + # Fixes issue #1507 Open new tab in incognito mode should open new tab in same window. + chrome.tabs.create({ url: Utils.convertToUrl(request.url), index: tab.index + 1, selected: true, windowId: tab.windowId })) openUrlInIncognito = (request) -> chrome.windows.create({ url: Utils.convertToUrl(request.url), incognito: true}) @@ -231,7 +233,10 @@ moveTab = (callback, direction) -> # These are commands which are bound to keystroke which must be handled by the background page. They are # mapped in commands.coffee. BackgroundCommands = - createTab: (callback) -> chrome.tabs.create({url: Settings.get("newTabUrl")}, (tab) -> callback()) + # Using openUrlInNewTab instead of chrome.tabs.create() because of upstread bug #308171. + # The function openUrlInNewTab now selects the current tab and uses its windowId while + # opening a new tab to force proper window selection. + createTab: (callback) -> openUrlInNewTab({ url: Settings.get("newTabUrl") }) duplicateTab: (callback) -> chrome.tabs.getSelected(null, (tab) -> chrome.tabs.duplicate(tab.id) -- cgit v1.2.3 From e2e311fd8e422ec9de50a92566ff14a2a76fe74f Mon Sep 17 00:00:00 2001 From: Sudarshan Wadkar Date: Thu, 26 Feb 2015 23:13:07 -0500 Subject: Remove noise, explain in commit - Change openUrlInNewTab to pass tab.windowId Why? Work around for upstream bug #308171 - Change createTab to use openUrlInNewTab Why? Fix issue #1507 to open new tab in current window (Note: This commit removes noise from the code and explains the changes) --- background_scripts/main.coffee | 5 ----- 1 file changed, 5 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 72b36b0b..a7dbeca8 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -165,8 +165,6 @@ openUrlInCurrentTab = (request) -> # openUrlInNewTab = (request) -> chrome.tabs.getSelected(null, (tab) -> - # Pass selected tabs windowId to make sure we open in current window. - # Fixes issue #1507 Open new tab in incognito mode should open new tab in same window. chrome.tabs.create({ url: Utils.convertToUrl(request.url), index: tab.index + 1, selected: true, windowId: tab.windowId })) openUrlInIncognito = (request) -> @@ -233,9 +231,6 @@ moveTab = (callback, direction) -> # These are commands which are bound to keystroke which must be handled by the background page. They are # mapped in commands.coffee. BackgroundCommands = - # Using openUrlInNewTab instead of chrome.tabs.create() because of upstread bug #308171. - # The function openUrlInNewTab now selects the current tab and uses its windowId while - # opening a new tab to force proper window selection. createTab: (callback) -> openUrlInNewTab({ url: Settings.get("newTabUrl") }) duplicateTab: (callback) -> chrome.tabs.getSelected(null, (tab) -> -- cgit v1.2.3 From 6901f4e584a41501ea865b87c481dc089a8f0d6f Mon Sep 17 00:00:00 2001 From: Sudarshan Wadkar Date: Sun, 1 Mar 2015 14:42:40 -0500 Subject: Stick in callback so `Nt` works - This fix enables `2t` to open two new tabs, even in incognito. Include callback in the call chain so that numbered commands can work. --- background_scripts/main.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index a7dbeca8..aa46dec0 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -163,9 +163,10 @@ openUrlInCurrentTab = (request) -> # # Opens request.url in new tab and switches to it if request.selected is true. # -openUrlInNewTab = (request) -> +openUrlInNewTab = (request, callback) -> chrome.tabs.getSelected(null, (tab) -> - chrome.tabs.create({ url: Utils.convertToUrl(request.url), index: tab.index + 1, selected: true, windowId: tab.windowId })) + chrome.tabs.create({ url: Utils.convertToUrl(request.url), index: tab.index + 1, selected: true, windowId: tab.windowId }, + (tab) -> callback())) openUrlInIncognito = (request) -> chrome.windows.create({ url: Utils.convertToUrl(request.url), incognito: true}) @@ -231,7 +232,7 @@ moveTab = (callback, direction) -> # These are commands which are bound to keystroke which must be handled by the background page. They are # mapped in commands.coffee. BackgroundCommands = - createTab: (callback) -> openUrlInNewTab({ url: Settings.get("newTabUrl") }) + createTab: (callback) -> openUrlInNewTab({ url: Settings.get("newTabUrl") }, (tab) -> callback()) duplicateTab: (callback) -> chrome.tabs.getSelected(null, (tab) -> chrome.tabs.duplicate(tab.id) -- cgit v1.2.3 From 67abd209027d7150e104cab8004a3b924f6053d8 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 5 Mar 2015 06:32:39 +0000 Subject: Tidy up #1507. --- background_scripts/main.coffee | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index aa46dec0..a217ad91 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -164,9 +164,13 @@ openUrlInCurrentTab = (request) -> # Opens request.url in new tab and switches to it if request.selected is true. # openUrlInNewTab = (request, callback) -> - chrome.tabs.getSelected(null, (tab) -> - chrome.tabs.create({ url: Utils.convertToUrl(request.url), index: tab.index + 1, selected: true, windowId: tab.windowId }, - (tab) -> callback())) + chrome.tabs.getSelected null, (tab) -> + tabConfig = + url: Utils.convertToUrl request.url + index: tab.index + 1 + selected: true + windowId: tab.windowId + chrome.tabs.create tabConfig, callback openUrlInIncognito = (request) -> chrome.windows.create({ url: Utils.convertToUrl(request.url), incognito: true}) @@ -232,7 +236,7 @@ moveTab = (callback, direction) -> # These are commands which are bound to keystroke which must be handled by the background page. They are # mapped in commands.coffee. BackgroundCommands = - createTab: (callback) -> openUrlInNewTab({ url: Settings.get("newTabUrl") }, (tab) -> callback()) + createTab: (callback) -> openUrlInNewTab { url: Settings.get("newTabUrl") }, callback duplicateTab: (callback) -> chrome.tabs.getSelected(null, (tab) -> chrome.tabs.duplicate(tab.id) -- cgit v1.2.3