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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview The entry point for all ChromeVox2 related code for the 6 * @fileoverview The entry point for all ChromeVox2 related code for the
7 * background page. 7 * background page.
8 */ 8 */
9 9
10 goog.provide('Background'); 10 goog.provide('Background');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 /** 45 /**
46 * A list of site substring patterns to use with ChromeVox next. Keep these 46 * A list of site substring patterns to use with ChromeVox next. Keep these
47 * strings relatively specific. 47 * strings relatively specific.
48 * @type {!Array<string>} 48 * @type {!Array<string>}
49 * @private 49 * @private
50 */ 50 */
51 this.whitelist_ = ['chromevox_next_test']; 51 this.whitelist_ = ['chromevox_next_test'];
52 52
53 /** 53 /**
54 * A list of site substring patterns to blacklist ChromeVox Classic,
55 * putting ChromeVox into Compat mode.
56 * @type {!Array<string>}
57 * @private
58 */
59 this.classicBlacklist_ = [];
60
61 /**
54 * Regular expression for blacklisting classic. 62 * Regular expression for blacklisting classic.
55 * @type {RegExp} 63 * @type {RegExp}
56 * @private 64 * @private
57 */ 65 */
58 this.classicBlacklistRegExp_ = Background.globsToRegExp_( 66 this.classicBlacklistRegExp_ = Background.globsToRegExp_(
59 chrome.runtime.getManifest()['content_scripts'][0]['exclude_globs']); 67 chrome.runtime.getManifest()['content_scripts'][0]['exclude_globs']);
60 68
61 /** 69 /**
62 * @type {cursors.Range} 70 * @type {cursors.Range}
63 * @private 71 * @private
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 !this.isBlacklistedForClassic_(url) && 1003 !this.isBlacklistedForClassic_(url) &&
996 !this.isWhitelistedForNext_(url); 1004 !this.isWhitelistedForNext_(url);
997 }, 1005 },
998 1006
999 /** 1007 /**
1000 * @param {string} url 1008 * @param {string} url
1001 * @return {boolean} 1009 * @return {boolean}
1002 * @private 1010 * @private
1003 */ 1011 */
1004 isBlacklistedForClassic_: function(url) { 1012 isBlacklistedForClassic_: function(url) {
1005 return this.classicBlacklistRegExp_.test(url); 1013 if (this.classicBlacklistRegExp_.test(url))
1014 return true;
1015 return this.classicBlacklist_.some(function(item) {
1016 return url.indexOf(item) != -1;
1017 });
1006 }, 1018 },
1007 1019
1008 /** 1020 /**
1009 * @param {string} url 1021 * @param {string} url
1010 * @return {boolean} Whether the given |url| is whitelisted. 1022 * @return {boolean} Whether the given |url| is whitelisted.
1011 * @private 1023 * @private
1012 */ 1024 */
1013 isWhitelistedForNext_: function(url) { 1025 isWhitelistedForNext_: function(url) {
1014 return this.whitelist_.some(function(item) { 1026 return this.whitelist_.some(function(item) {
1015 return url.indexOf(item) != -1; 1027 return url.indexOf(item) != -1;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 1080
1069 switch (target) { 1081 switch (target) {
1070 case 'next': 1082 case 'next':
1071 if (action == 'getIsClassicEnabled') { 1083 if (action == 'getIsClassicEnabled') {
1072 var url = msg['url']; 1084 var url = msg['url'];
1073 var isClassicEnabled = this.shouldEnableClassicForUrl_(url); 1085 var isClassicEnabled = this.shouldEnableClassicForUrl_(url);
1074 port.postMessage({ 1086 port.postMessage({
1075 target: 'next', 1087 target: 'next',
1076 isClassicEnabled: isClassicEnabled 1088 isClassicEnabled: isClassicEnabled
1077 }); 1089 });
1090 } else if (action == 'enableCompatForUrl') {
1091 var url = msg['url'];
1092 this.classicBlacklist_.push(url);
David Tseng 2016/06/15 22:50:17 Should be a dictionary/set since we don't want dup
dmazzoni 2016/06/16 20:00:06 Done.
1093 if (this.currentRange_ && this.currentRange_.start.node)
1094 this.refreshMode(this.currentRange_.start.node);
1078 } else if (action == 'onCommand') { 1095 } else if (action == 'onCommand') {
1079 this.onGotCommand(msg['command']); 1096 this.onGotCommand(msg['command']);
1080 } else if (action == 'flushNextUtterance') { 1097 } else if (action == 'flushNextUtterance') {
1081 Output.flushNextSpeechUtterance(); 1098 Output.flushNextSpeechUtterance();
1082 } 1099 }
1083 break; 1100 break;
1084 } 1101 }
1085 }, 1102 },
1086 1103
1087 /** 1104 /**
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') 1211 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&')
1195 .replace(/\*/g, '.*') 1212 .replace(/\*/g, '.*')
1196 .replace(/\?/g, '.'); 1213 .replace(/\?/g, '.');
1197 }).join('|') + ')$'); 1214 }).join('|') + ')$');
1198 }; 1215 };
1199 1216
1200 /** @type {Background} */ 1217 /** @type {Background} */
1201 global.backgroundObj = new Background(); 1218 global.backgroundObj = new Background();
1202 1219
1203 }); // goog.scope 1220 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698