OLD | NEW |
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 case 'showContextMenu': | 346 case 'showContextMenu': |
347 if (this.currentRange_) { | 347 if (this.currentRange_) { |
348 var actionNode = this.currentRange_.start.node; | 348 var actionNode = this.currentRange_.start.node; |
349 if (actionNode.role == RoleType.inlineTextBox) | 349 if (actionNode.role == RoleType.inlineTextBox) |
350 actionNode = actionNode.parent; | 350 actionNode = actionNode.parent; |
351 actionNode.showContextMenu(); | 351 actionNode.showContextMenu(); |
352 return false; | 352 return false; |
353 } | 353 } |
354 break; | 354 break; |
355 case 'showOptionsPage': | 355 case 'showOptionsPage': |
356 var optionsPage = {url: 'chromevox/background/options.html'}; | 356 chrome.runtime.openOptionsPage(); |
357 chrome.tabs.create(optionsPage); | |
358 break; | 357 break; |
359 case 'toggleChromeVoxVersion': | 358 case 'toggleChromeVoxVersion': |
360 var newMode; | 359 var newMode; |
361 if (this.mode_ == ChromeVoxMode.FORCE_NEXT) { | 360 if (this.mode_ == ChromeVoxMode.FORCE_NEXT) { |
362 var inViews = | 361 var inViews = |
363 this.currentRange_.start.node.root.role == RoleType.desktop; | 362 this.currentRange_.start.node.root.role == RoleType.desktop; |
364 newMode = inViews ? ChromeVoxMode.COMPAT : ChromeVoxMode.CLASSIC; | 363 newMode = inViews ? ChromeVoxMode.COMPAT : ChromeVoxMode.CLASSIC; |
365 } else { | 364 } else { |
366 newMode = ChromeVoxMode.FORCE_NEXT; | 365 newMode = ChromeVoxMode.FORCE_NEXT; |
367 } | 366 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 404 |
406 new Output().withSpeechAndBraille( | 405 new Output().withSpeechAndBraille( |
407 this.currentRange_, prevRange, Output.EventType.NAVIGATE) | 406 this.currentRange_, prevRange, Output.EventType.NAVIGATE) |
408 .go(); | 407 .go(); |
409 } | 408 } |
410 | 409 |
411 return false; | 410 return false; |
412 }, | 411 }, |
413 | 412 |
414 /** | 413 /** |
| 414 * Open the options page in a new tab. |
| 415 */ |
| 416 showOptionsPage: function() { |
| 417 var optionsPage = {url: 'chromevox/background/options.html'}; |
| 418 chrome.tabs.create(optionsPage); |
| 419 }, |
| 420 |
| 421 /** |
415 * Handles a braille command. | 422 * Handles a braille command. |
416 * @param {!cvox.BrailleKeyEvent} evt | 423 * @param {!cvox.BrailleKeyEvent} evt |
417 * @param {!cvox.NavBraille} content | 424 * @param {!cvox.NavBraille} content |
418 * @return {boolean} True if evt was processed. | 425 * @return {boolean} True if evt was processed. |
419 */ | 426 */ |
420 onBrailleKeyEvent: function(evt, content) { | 427 onBrailleKeyEvent: function(evt, content) { |
421 if (this.mode_ === ChromeVoxMode.CLASSIC) | 428 if (this.mode_ === ChromeVoxMode.CLASSIC) |
422 return false; | 429 return false; |
423 | 430 |
424 switch (evt.command) { | 431 switch (evt.command) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 646 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
640 .replace(/\*/g, '.*') | 647 .replace(/\*/g, '.*') |
641 .replace(/\?/g, '.'); | 648 .replace(/\?/g, '.'); |
642 }).join('|') + ')$'); | 649 }).join('|') + ')$'); |
643 }; | 650 }; |
644 | 651 |
645 /** @type {Background} */ | 652 /** @type {Background} */ |
646 global.backgroundObj = new Background(); | 653 global.backgroundObj = new Background(); |
647 | 654 |
648 }); // goog.scope | 655 }); // goog.scope |
OLD | NEW |