Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1844)

Unified Diff: chrome/browser/extensions/api/tabs/windows_event_router.cc

Issue 773303005: MacViews: Change TOOLKIT_VIEWS to !OS_MACOSX in extensions::WindowsEventRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: event -> even Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/tabs/windows_event_router.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/tabs/windows_event_router.cc
diff --git a/chrome/browser/extensions/api/tabs/windows_event_router.cc b/chrome/browser/extensions/api/tabs/windows_event_router.cc
index b5b8aa3932ff86b7ca2bf6969001b037f5dd30e7..278a27106ac0632895e896b2959a12e921142176 100644
--- a/chrome/browser/extensions/api/tabs/windows_event_router.cc
+++ b/chrome/browser/extensions/api/tabs/windows_event_router.cc
@@ -30,19 +30,26 @@ WindowsEventRouter::WindowsEventRouter(Profile* profile)
DCHECK(!profile->IsOffTheRecord());
WindowControllerList::GetInstance()->AddObserver(this);
-#if defined(TOOLKIT_VIEWS)
- views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
-#elif defined(OS_MACOSX)
// Needed for when no suitable window can be passed to an extension as the
- // currently focused window.
+ // currently focused window. On Mac (even in a toolkit-views build) always
+ // rely on the notification sent by AppControllerMac after AppKit sends
+ // NSWindowDidBecomeKeyNotification and there is no [NSApp keyWindow]. This
+ // allows windows not created by toolkit-views to be tracked.
+ // TODO(tapted): Remove the ifdefs (and NOTIFICATION_NO_KEY_WINDOW) when
+ // Chrome on Mac only makes windows with toolkit-views.
+#if defined(OS_MACOSX)
registrar_.Add(this, chrome::NOTIFICATION_NO_KEY_WINDOW,
content::NotificationService::AllSources());
+#elif defined(TOOLKIT_VIEWS)
+ views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
+#else
+#error Unsupported
#endif
}
WindowsEventRouter::~WindowsEventRouter() {
WindowControllerList::GetInstance()->RemoveObserver(this);
-#if defined(TOOLKIT_VIEWS)
+#if !defined(OS_MACOSX)
views::WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(this);
#endif
}
@@ -73,7 +80,7 @@ void WindowsEventRouter::OnWindowControllerRemoved(
args.Pass());
}
-#if defined(TOOLKIT_VIEWS)
+#if !defined(OS_MACOSX)
void WindowsEventRouter::OnNativeFocusChange(
gfx::NativeView focused_before,
gfx::NativeView focused_now) {
« no previous file with comments | « chrome/browser/extensions/api/tabs/windows_event_router.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698