| 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 |
| 16 #if !defined(OS_MACOSX) |
| 16 #include "ui/views/focus/widget_focus_manager.h" | 17 #include "ui/views/focus/widget_focus_manager.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 class Profile; | 20 class Profile; |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class ListValue; | 23 class ListValue; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace extensions { | 26 namespace extensions { |
| 26 | 27 |
| 27 // The WindowsEventRouter sends chrome.windows.* events to listeners | 28 // The WindowsEventRouter sends chrome.windows.* events to listeners |
| 28 // inside extension process renderers. The router listens to *all* events, | 29 // inside extension process renderers. The router listens to *all* events, |
| 29 // but will only route eventes within a profile to extension processes in the | 30 // but will only route events within a profile to extension processes in the |
| 30 // same profile. | 31 // same profile. |
| 31 class WindowsEventRouter : public WindowControllerListObserver, | 32 class WindowsEventRouter : public WindowControllerListObserver, |
| 32 #if defined(TOOLKIT_VIEWS) | 33 #if !defined(OS_MACOSX) |
| 33 public views::WidgetFocusChangeListener, | 34 public views::WidgetFocusChangeListener, |
| 34 #endif | 35 #endif |
| 35 public content::NotificationObserver { | 36 public content::NotificationObserver { |
| 36 public: | 37 public: |
| 37 explicit WindowsEventRouter(Profile* profile); | 38 explicit WindowsEventRouter(Profile* profile); |
| 38 ~WindowsEventRouter() override; | 39 ~WindowsEventRouter() override; |
| 39 | 40 |
| 40 // WindowControllerListObserver methods: | 41 // WindowControllerListObserver methods: |
| 41 void OnWindowControllerAdded(WindowController* window_controller) override; | 42 void OnWindowControllerAdded(WindowController* window_controller) override; |
| 42 void OnWindowControllerRemoved(WindowController* window) override; | 43 void OnWindowControllerRemoved(WindowController* window) override; |
| 43 | 44 |
| 44 #if defined(TOOLKIT_VIEWS) | 45 #if !defined(OS_MACOSX) |
| 45 void OnNativeFocusChange(gfx::NativeView focused_before, | 46 void OnNativeFocusChange(gfx::NativeView focused_before, |
| 46 gfx::NativeView focused_now) override; | 47 gfx::NativeView focused_now) override; |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 // content::NotificationObserver. | 50 // content::NotificationObserver. |
| 50 void Observe(int type, | 51 void Observe(int type, |
| 51 const content::NotificationSource& source, | 52 const content::NotificationSource& source, |
| 52 const content::NotificationDetails& details) override; | 53 const content::NotificationDetails& details) override; |
| 53 | 54 |
| 54 // |window_controller| is NULL to indicate a focused window has lost focus. | 55 // |window_controller| is NULL to indicate a focused window has lost focus. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 72 // The currently focused window. We keep this so as to avoid sending multiple | 73 // The currently focused window. We keep this so as to avoid sending multiple |
| 73 // windows.onFocusChanged events with the same windowId. | 74 // windows.onFocusChanged events with the same windowId. |
| 74 int focused_window_id_; | 75 int focused_window_id_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); | 77 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 } // namespace extensions | 80 } // namespace extensions |
| 80 | 81 |
| 81 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 82 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
| OLD | NEW |