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 34e73ebaae3e70127f591aa7cc7935010f9b6369..ad87568070dd62b244b03c97f317ae30acae5516 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
@@ -169,8 +169,7 @@ Background.prototype = { |
} else { |
// When in compat mode, if the focus is within the desktop tree proper, |
// then do not disable content scripts. |
- if (this.currentRange_ && |
- this.currentRange_.start.node.root.role == RoleType.desktop) |
+ if (this.currentRange_ && !this.currentRange_.isWebRange()) |
return; |
this.disableClassicChromeVox_(); |
@@ -189,17 +188,24 @@ Background.prototype = { |
}, |
/** |
+ * Mode refreshes takes into account both |url| and the current ChromeVox |
+ * range. The latter gets used to decide if the user is or isn't in web |
+ * content. The focused state also needs to be set for this info to be |
+ * reliable. |
* @override |
*/ |
refreshMode: function(url) { |
var mode = this.mode_; |
if (mode != ChromeVoxMode.FORCE_NEXT) { |
- if (this.isWhitelistedForNext_(url)) |
+ if (this.isWhitelistedForNext_(url)) { |
mode = ChromeVoxMode.NEXT; |
- else if (this.isBlacklistedForClassic_(url)) |
+ } else if (this.isBlacklistedForClassic_(url) || (this.currentRange_ && |
+ !this.currentRange_.isWebRange() && |
+ this.currentRange_.start.node.state.focused)) { |
mode = ChromeVoxMode.COMPAT; |
- else |
+ } else { |
mode = ChromeVoxMode.CLASSIC; |
+ } |
} |
this.setMode(mode); |
@@ -440,9 +446,8 @@ Background.prototype = { |
case 'toggleChromeVoxVersion': |
var newMode; |
if (this.mode_ == ChromeVoxMode.FORCE_NEXT) { |
- var inViews = |
- this.currentRange_.start.node.root.role == RoleType.desktop; |
- newMode = inViews ? ChromeVoxMode.COMPAT : ChromeVoxMode.CLASSIC; |
+ var inWeb = current.isWebRange(); |
+ newMode = inWeb ? ChromeVoxMode.CLASSIC : ChromeVoxMode.COMPAT; |
} else { |
newMode = ChromeVoxMode.FORCE_NEXT; |
} |
@@ -573,7 +578,7 @@ Background.prototype = { |
* @private |
*/ |
isBlacklistedForClassic_: function(url) { |
- return url === '' || this.classicBlacklistRegExp_.test(url); |
+ return this.classicBlacklistRegExp_.test(url); |
}, |
/** |