aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/completion_engines.coffee4
-rw-r--r--background_scripts/main.coffee30
2 files changed, 22 insertions, 12 deletions
diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee
index db1ccc77..0a53ad14 100644
--- a/background_scripts/completion_engines.coffee
+++ b/background_scripts/completion_engines.coffee
@@ -48,7 +48,7 @@ class Google extends GoogleXMLBaseEngine
constructor: () ->
super
engineUrl: "https://suggestqueries.google.com/complete/search?ss_protocol=legace&client=toolbar&q=%s"
- regexps: "^https?://[a-z]+\\.google\\.(com|ie|co\\.uk|ca|com\\.au)/"
+ regexps: "^https?://[a-z]+\\.google\\.(com|ie|co\\.(uk|jp)|ca|com\\.au)/"
example:
searchUrl: "https://www.google.com/search?q=%s"
keyword: "g"
@@ -58,7 +58,7 @@ class GoogleMaps extends GoogleXMLBaseEngine
constructor: () ->
super
engineUrl: "https://suggestqueries.google.com/complete/search?ss_protocol=legace&client=toolbar&q=#{@prefix.split(' ').join '+'}%s"
- regexps: "^https?://[a-z]+\\.google\\.(com|ie|co\\.uk|ca|com\\.au)/maps"
+ regexps: "^https?://[a-z]+\\.google\\.(com|ie|co\\.(uk|jp)|ca|com\\.au)/maps"
example:
searchUrl: "https://www.google.com/maps?q=%s"
keyword: "m"
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 379239ae..97d8fa65 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -106,15 +106,25 @@ TabOperations =
index: request.tab.index + 1
active: true
windowId: request.tab.windowId
+ tabConfig.active = request.active if request.active?
# Firefox does not support "about:newtab" in chrome.tabs.create.
delete tabConfig["url"] if tabConfig["url"] == Settings.defaults.newTabUrl
- chrome.tabs.create tabConfig, (tab) ->
- # NOTE(mrmr1993, 2017-02-08): Firefox currently doesn't support openerTabId (issue 1238314) and throws
- # a type error if it is present. We work around this by attempting to set it separately from creating
- # the tab.
- try chrome.tabs.update tab.id, { openerTabId : request.tab.id }, callback
- catch
- callback.apply this, arguments
+
+ # Firefox <57 throws an error when openerTabId is used (issue 1238314).
+ canUseOpenerTabId = not (Utils.isFirefox() and Utils.compareVersions(Utils.firefoxVersion(), "57") < 0)
+ tabConfig.openerTabId = request.tab.id if canUseOpenerTabId
+
+ chrome.tabs.create tabConfig, callback
+
+ # Opens request.url in new window and switches to it.
+ openUrlInNewWindow: (request, callback = (->)) ->
+ winConfig =
+ url: Utils.convertToUrl request.url
+ active: true
+ winConfig.active = request.active if request.active?
+ # Firefox does not support "about:newtab" in chrome.tabs.create.
+ delete tabConfig["url"] if tabConfig["url"] == Settings.defaults.newTabUrl
+ chrome.windows.create winConfig, callback
toggleMuteTab = do ->
muteTab = (tab) -> chrome.tabs.update tab.id, {muted: !tab.mutedInfo.muted}
@@ -252,10 +262,9 @@ selectTab = (direction, {count, tab}) ->
Math.max 0, tabs.length - count
chrome.tabs.update tabs[toSelect].id, active: true
-chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) ->
- return unless changeInfo.status == "loading" # Only do this once per URL change.
+chrome.webNavigation.onCommitted.addListener ({tabId, frameId}) ->
cssConf =
- allFrames: true
+ frameId: frameId
code: Settings.get("userDefinedLinkHintCss")
runAt: "document_start"
chrome.tabs.insertCSS tabId, cssConf, -> chrome.runtime.lastError
@@ -415,6 +424,7 @@ sendRequestHandlers =
# with Chrome-specific URLs like "view-source:http:..".
getCurrentTabUrl: ({tab}) -> tab.url
openUrlInNewTab: (request) -> TabOperations.openUrlInNewTab request
+ openUrlInNewWindow: (request) -> TabOperations.openUrlInNewWindow request
openUrlInIncognito: (request) -> chrome.windows.create incognito: true, url: Utils.convertToUrl request.url
openUrlInCurrentTab: TabOperations.openUrlInCurrentTab
openOptionsPageInNewTab: (request) ->