Commit 7f22a163 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Close Views menus when switching apps.

BUG=988979
TEST=as in bug

Change-Id: I40c09d3f3d630d2ef4762d7970d6a6ec52a875ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1727489Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682725}
parent cb554cda
......@@ -32,6 +32,7 @@ class VIEWS_EXPORT MenuCocoaWatcherMac {
// Tokens representing the notification observers.
id observer_token_other_menu_;
id observer_token_new_window_focus_;
id observer_token_app_change_;
DISALLOW_COPY_AND_ASSIGN(MenuCocoaWatcherMac);
};
......
......@@ -27,6 +27,14 @@ MenuCocoaWatcherMac::MenuCocoaWatcherMac(base::OnceClosure callback)
usingBlock:^(NSNotification* notification) {
ExecuteCallback();
}];
observer_token_app_change_ =
[[[NSWorkspace sharedWorkspace] notificationCenter]
addObserverForName:NSWorkspaceDidActivateApplicationNotification
object:nil
queue:nil
usingBlock:^(NSNotification* notification) {
ExecuteCallback();
}];
}
MenuCocoaWatcherMac::~MenuCocoaWatcherMac() {
......@@ -34,6 +42,8 @@ MenuCocoaWatcherMac::~MenuCocoaWatcherMac() {
removeObserver:observer_token_other_menu_];
[[NSNotificationCenter defaultCenter]
removeObserver:observer_token_new_window_focus_];
[[[NSWorkspace sharedWorkspace] notificationCenter]
removeObserver:observer_token_app_change_];
}
void MenuCocoaWatcherMac::ExecuteCallback() {
......
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