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() { ...@@ -881,9 +881,12 @@ Panel.getCallbackForCurrentItem = function() {
* was queued, execute it once focus is restored. * was queued, execute it once focus is restored.
*/ */
Panel.closeMenusAndRestoreFocus = function() { Panel.closeMenusAndRestoreFocus = function() {
// Watch for the next focus event. var bkgnd = chrome.extension.getBackgroundPage();
var onFocus = function(desktop, evt) { bkgnd.chrome.automation.getDesktop(function(desktop) {
desktop.removeEventListener(chrome.automation.EventType.FOCUS, onFocus); // 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_) { if (Panel.pendingCallback_) {
// Clear it before calling it, in case the callback itself triggers // Clear it before calling it, in case the callback itself triggers
// another pending callback. // another pending callback.
...@@ -891,13 +894,19 @@ Panel.closeMenusAndRestoreFocus = function() { ...@@ -891,13 +894,19 @@ Panel.closeMenusAndRestoreFocus = function() {
Panel.pendingCallback_ = null; Panel.pendingCallback_ = null;
pendingCallback(); pendingCallback();
} }
}.bind(this); };
var bkgnd = chrome.extension.getBackgroundPage(); var onBlur = function(evt) {
bkgnd.chrome.automation.getDesktop(function(desktop) { if (evt.docUrl != location.href)
onFocus = /** @type {function(chrome.automation.AutomationEvent)} */ ( return;
onFocus.bind(this, desktop));
desktop.addEventListener(chrome.automation.EventType.FOCUS, onFocus, true); 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. // Make sure all menus are cleared to avoid bogous output when we re-open.
Panel.clearMenus(); 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