Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 ChromeVox panel and menus. | 6 * @fileoverview The ChromeVox panel and menus. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('Panel'); | 9 goog.provide('Panel'); |
| 10 | 10 |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 if (this.activeMenu_) | 610 if (this.activeMenu_) |
| 611 return this.activeMenu_.getCallbackForCurrentItem(); | 611 return this.activeMenu_.getCallbackForCurrentItem(); |
| 612 return null; | 612 return null; |
| 613 }; | 613 }; |
| 614 | 614 |
| 615 /** | 615 /** |
| 616 * Close the menus and restore focus to the page. If a menu item's callback | 616 * Close the menus and restore focus to the page. If a menu item's callback |
| 617 * was queued, execute it once focus is restored. | 617 * was queued, execute it once focus is restored. |
| 618 */ | 618 */ |
| 619 Panel.closeMenusAndRestoreFocus = function() { | 619 Panel.closeMenusAndRestoreFocus = function() { |
| 620 // Make sure we're not in full-screen mode. | 620 // Watch for the next focus event. |
| 621 window.location = '#'; | 621 var desktop = null; |
| 622 var onFocus = function(evt) { | |
|
dmazzoni
2016/10/11 17:41:18
Rather than add and remove a focus listener, what
David Tseng
2016/10/11 21:24:32
I'd like to limit the panel's global event listene
| |
| 623 desktop.removeEventListener(chrome.automation.EventType.focus, onFocus); | |
| 624 Panel.pendingCallback_ && Panel.pendingCallback_(); | |
| 625 }.bind(this); | |
| 622 | 626 |
| 623 this.activeMenu_ = null; | 627 chrome.automation.getDesktop(function(node) { |
|
dmazzoni
2016/10/11 17:41:18
How about: getDesktop(function(desktop) {
David Tseng
2016/10/11 21:24:32
desktop is used above. I guess I could bind it to
| |
| 628 desktop = node; | |
| 629 desktop.addEventListener(chrome.automation.EventType.focus, | |
| 630 onFocus, | |
| 631 true); | |
| 624 | 632 |
| 625 var bkgnd = | 633 // Make sure we're not in full-screen mode. |
| 626 chrome.extension.getBackgroundPage()['ChromeVoxState']['instance']; | 634 window.location = '#'; |
| 627 bkgnd['endExcursion'](Panel.pendingCallback_); | 635 |
| 636 this.activeMenu_ = null; | |
| 637 }); | |
| 628 }; | 638 }; |
| 629 | 639 |
| 630 /** | 640 /** |
| 631 * Open the tutorial. | 641 * Open the tutorial. |
| 632 */ | 642 */ |
| 633 Panel.onTutorial = function() { | 643 Panel.onTutorial = function() { |
| 634 var bkgnd = | |
| 635 chrome.extension.getBackgroundPage()['ChromeVoxState']['instance']; | |
| 636 bkgnd['startExcursion'](); | |
| 637 | |
| 638 // Change the url fragment to 'fullscreen', which signals the native | 644 // Change the url fragment to 'fullscreen', which signals the native |
| 639 // host code to make the window fullscreen, revealing the menus. | 645 // host code to make the window fullscreen, revealing the menus. |
| 640 window.location = '#fullscreen'; | 646 window.location = '#fullscreen'; |
| 641 | 647 |
| 642 $('main').style.display = 'none'; | 648 $('main').style.display = 'none'; |
| 643 $('menus_background').style.display = 'none'; | 649 $('menus_background').style.display = 'none'; |
| 644 $('tutorial').style.display = 'block'; | 650 $('tutorial').style.display = 'block'; |
| 645 | 651 |
| 646 Panel.tutorial_.firstPage(); | 652 Panel.tutorial_.firstPage(); |
| 647 }; | 653 }; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 674 }, false); | 680 }, false); |
| 675 | 681 |
| 676 window.addEventListener('hashchange', function() { | 682 window.addEventListener('hashchange', function() { |
| 677 if (location.hash == '#fullscreen' || location.hash == '#focus') { | 683 if (location.hash == '#fullscreen' || location.hash == '#focus') { |
| 678 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; | 684 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; |
| 679 cvox.ChromeVox.isStickyPrefOn = false; | 685 cvox.ChromeVox.isStickyPrefOn = false; |
| 680 } else { | 686 } else { |
| 681 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; | 687 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; |
| 682 } | 688 } |
| 683 }, false); | 689 }, false); |
| OLD | NEW |