Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1866)

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js

Issue 2074513002: Parse meta tag that disables ChromeVox content script and forces compat mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only kill Classic in current tab Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/chromevox/injected/init_document.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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') {
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/chromevox/injected/init_document.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698