| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/extensions/window_controller_list_observer.h" | 12 #include "chrome/browser/extensions/window_controller_list_observer.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #if defined(TOOLKIT_VIEWS) | 15 #if defined(TOOLKIT_VIEWS) |
| 16 #include "ui/views/focus/widget_focus_manager.h" | 16 #include "ui/views/focus/widget_focus_manager.h" |
| 17 #elif defined(TOOLKIT_GTK) | |
| 18 #include "ui/base/x/active_window_watcher_x_observer.h" | |
| 19 #endif | 17 #endif |
| 20 | 18 |
| 21 class Profile; | 19 class Profile; |
| 22 | 20 |
| 23 namespace base { | 21 namespace base { |
| 24 class ListValue; | 22 class ListValue; |
| 25 } | 23 } |
| 26 | 24 |
| 27 namespace extensions { | 25 namespace extensions { |
| 28 | 26 |
| 29 // The WindowsEventRouter sends chrome.windows.* events to listeners | 27 // The WindowsEventRouter sends chrome.windows.* events to listeners |
| 30 // inside extension process renderers. The router listens to *all* events, | 28 // inside extension process renderers. The router listens to *all* events, |
| 31 // but will only route eventes within a profile to extension processes in the | 29 // but will only route eventes within a profile to extension processes in the |
| 32 // same profile. | 30 // same profile. |
| 33 class WindowsEventRouter : public WindowControllerListObserver, | 31 class WindowsEventRouter : public WindowControllerListObserver, |
| 34 #if defined(TOOLKIT_VIEWS) | 32 #if defined(TOOLKIT_VIEWS) |
| 35 public views::WidgetFocusChangeListener, | 33 public views::WidgetFocusChangeListener, |
| 36 #elif defined(TOOLKIT_GTK) | |
| 37 public ui::ActiveWindowWatcherXObserver, | |
| 38 #endif | 34 #endif |
| 39 public content::NotificationObserver { | 35 public content::NotificationObserver { |
| 40 public: | 36 public: |
| 41 explicit WindowsEventRouter(Profile* profile); | 37 explicit WindowsEventRouter(Profile* profile); |
| 42 virtual ~WindowsEventRouter(); | 38 virtual ~WindowsEventRouter(); |
| 43 | 39 |
| 44 // WindowControllerListObserver methods: | 40 // WindowControllerListObserver methods: |
| 45 virtual void OnWindowControllerAdded( | 41 virtual void OnWindowControllerAdded( |
| 46 WindowController* window_controller) OVERRIDE; | 42 WindowController* window_controller) OVERRIDE; |
| 47 virtual void OnWindowControllerRemoved( | 43 virtual void OnWindowControllerRemoved( |
| 48 WindowController* window) OVERRIDE; | 44 WindowController* window) OVERRIDE; |
| 49 | 45 |
| 50 #if defined(TOOLKIT_VIEWS) | 46 #if defined(TOOLKIT_VIEWS) |
| 51 virtual void OnNativeFocusChange(gfx::NativeView focused_before, | 47 virtual void OnNativeFocusChange(gfx::NativeView focused_before, |
| 52 gfx::NativeView focused_now) OVERRIDE; | 48 gfx::NativeView focused_now) OVERRIDE; |
| 53 #elif defined(TOOLKIT_GTK) | |
| 54 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE; | |
| 55 #endif | 49 #endif |
| 56 | 50 |
| 57 // content::NotificationObserver. | 51 // content::NotificationObserver. |
| 58 virtual void Observe(int type, | 52 virtual void Observe(int type, |
| 59 const content::NotificationSource& source, | 53 const content::NotificationSource& source, |
| 60 const content::NotificationDetails& details) OVERRIDE; | 54 const content::NotificationDetails& details) OVERRIDE; |
| 61 | 55 |
| 62 // |window_controller| is NULL to indicate a focused window has lost focus. | 56 // |window_controller| is NULL to indicate a focused window has lost focus. |
| 63 void OnActiveWindowChanged(WindowController* window_controller); | 57 void OnActiveWindowChanged(WindowController* window_controller); |
| 64 | 58 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 80 // The currently focused window. We keep this so as to avoid sending multiple | 74 // The currently focused window. We keep this so as to avoid sending multiple |
| 81 // windows.onFocusChanged events with the same windowId. | 75 // windows.onFocusChanged events with the same windowId. |
| 82 int focused_window_id_; | 76 int focused_window_id_; |
| 83 | 77 |
| 84 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); | 78 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); |
| 85 }; | 79 }; |
| 86 | 80 |
| 87 } // namespace extensions | 81 } // namespace extensions |
| 88 | 82 |
| 89 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 83 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
| OLD | NEW |