Commit 8db29c6c authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fix jump menu syncing

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I86ad1383c8531e7f1272aa22d4d1e7374ae18ab3
Reviewed-on: https://chromium-review.googlesource.com/1053186Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558045}
parent e839a7c5
......@@ -881,9 +881,12 @@ Panel.getCallbackForCurrentItem = function() {
* was queued, execute it once focus is restored.
*/
Panel.closeMenusAndRestoreFocus = function() {
// Watch for the next focus event.
var onFocus = function(desktop, evt) {
desktop.removeEventListener(chrome.automation.EventType.FOCUS, onFocus);
var bkgnd = chrome.extension.getBackgroundPage();
bkgnd.chrome.automation.getDesktop(function(desktop) {
// Watch for a blur on the panel, then a focus on the page.
var onFocus = function(evt) {
desktop.removeEventListener(
chrome.automation.EventType.FOCUS, onFocus, true);
if (Panel.pendingCallback_) {
// Clear it before calling it, in case the callback itself triggers
// another pending callback.
......@@ -891,13 +894,19 @@ Panel.closeMenusAndRestoreFocus = function() {
Panel.pendingCallback_ = null;
pendingCallback();
}
}.bind(this);
};
var bkgnd = chrome.extension.getBackgroundPage();
bkgnd.chrome.automation.getDesktop(function(desktop) {
onFocus = /** @type {function(chrome.automation.AutomationEvent)} */ (
onFocus.bind(this, desktop));
desktop.addEventListener(chrome.automation.EventType.FOCUS, onFocus, true);
var onBlur = function(evt) {
if (evt.docUrl != location.href)
return;
desktop.removeEventListener(
chrome.automation.EventType.BLUR, onBlur, true);
desktop.addEventListener(
chrome.automation.EventType.FOCUS, onFocus, true);
};
desktop.addEventListener(chrome.automation.EventType.BLUR, onBlur, true);
// Make sure all menus are cleared to avoid bogous output when we re-open.
Panel.clearMenus();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment