Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| index 5c5b4dfcd0a3c978021d6a122f9aa5eaa68e0f03..25d317029959eaa1d056771882ef3ec689c347e8 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| @@ -51,6 +51,14 @@ Background = function() { |
| this.whitelist_ = ['chromevox_next_test']; |
| /** |
| + * A list of site substring patterns to blacklist ChromeVox Classic, |
| + * putting ChromeVox into Compat mode. |
| + * @type {!Set<string>} |
| + * @private |
| + */ |
| + this.classicBlacklist_ = new Set(); |
| + |
| + /** |
| * Regular expression for blacklisting classic. |
| * @type {RegExp} |
| * @private |
| @@ -230,7 +238,8 @@ Background.prototype = { |
| // async. Save it to ensure we're looking at the currentRange at this moment |
| // in time. |
| var cur = this.currentRange_; |
| - chrome.tabs.query({active: true}, function(tabs) { |
| + chrome.tabs.query({active: true, |
| + lastFocusedWindow: true}, function(tabs) { |
| if (mode === ChromeVoxMode.CLASSIC) { |
| // Generally, we don't want to inject classic content scripts as it is |
| // done by the extension system at document load. The exception is when |
| @@ -243,7 +252,7 @@ Background.prototype = { |
| if (cur && !cur.isWebRange()) |
| return; |
| - this.disableClassicChromeVox_(); |
| + this.disableClassicChromeVox_(tabs); |
|
David Tseng
2016/06/16 21:36:33
If setting force next mode, we do want to disable
dmazzoni
2016/06/17 22:20:38
Good catch. Take a look.
|
| } |
| }.bind(this)); |
| @@ -1002,7 +1011,10 @@ Background.prototype = { |
| * @private |
| */ |
| isBlacklistedForClassic_: function(url) { |
| - return this.classicBlacklistRegExp_.test(url); |
| + if (this.classicBlacklistRegExp_.test(url)) |
| + return true; |
| + url = url.substring(0, url.indexOf('#')) || url; |
| + return this.classicBlacklist_.has(url); |
| }, |
| /** |
| @@ -1018,12 +1030,16 @@ Background.prototype = { |
| /** |
| * Disables classic ChromeVox in current web content. |
| + * @param {Array<Tab>} tabs The tabs where ChromeVox scripts should |
| + * be disabled. |
| */ |
| - disableClassicChromeVox_: function() { |
| - cvox.ExtensionBridge.send({ |
| + disableClassicChromeVox_: function(tabs) { |
| + for (var i = 0, tab; tab = tabs[i]; i++) { |
| + chrome.tabs.sendMessage(tab.id, { |
| message: 'SYSTEM_COMMAND', |
| command: 'killChromeVox' |
| - }); |
| + }); |
| + } |
| }, |
| /** |
| @@ -1075,6 +1091,11 @@ Background.prototype = { |
| target: 'next', |
| isClassicEnabled: isClassicEnabled |
| }); |
| + } else if (action == 'enableCompatForUrl') { |
| + var url = msg['url']; |
| + this.classicBlacklist_.add(url); |
| + if (this.currentRange_ && this.currentRange_.start.node) |
| + this.refreshMode(this.currentRange_.start.node); |
| } else if (action == 'onCommand') { |
| this.onGotCommand(msg['command']); |
| } else if (action == 'flushNextUtterance') { |