| 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 <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/extensions/window_controller_list_observer.h" | 15 #include "chrome/browser/extensions/window_controller_list_observer.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "extensions/browser/app_window/app_window_registry.h" | 18 #include "extensions/browser/app_window/app_window_registry.h" |
| 19 #include "extensions/browser/extension_event_histogram_value.h" | 19 #include "extensions/browser/extension_event_histogram_value.h" |
| 20 | 20 |
| 21 #if !defined(OS_MACOSX) | 21 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
| 22 #include "ui/views/focus/widget_focus_manager.h" | 22 #include "ui/views/focus/widget_focus_manager.h" // nogncheck |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 class Profile; | 25 class Profile; |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class ListValue; | 28 class ListValue; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace extensions { | 31 namespace extensions { |
| 32 | 32 |
| 33 class AppWindow; | 33 class AppWindow; |
| 34 class AppWindowController; | 34 class AppWindowController; |
| 35 class WindowControllerList; | 35 class WindowControllerList; |
| 36 | 36 |
| 37 // The WindowsEventRouter sends chrome.windows.* events to listeners | 37 // The WindowsEventRouter sends chrome.windows.* events to listeners |
| 38 // inside extension process renderers. The router listens to *all* events, | 38 // inside extension process renderers. The router listens to *all* events, |
| 39 // but will only route events within a profile to extension processes in the | 39 // but will only route events within a profile to extension processes in the |
| 40 // same profile. | 40 // same profile. |
| 41 class WindowsEventRouter : public AppWindowRegistry::Observer, | 41 class WindowsEventRouter : public AppWindowRegistry::Observer, |
| 42 public WindowControllerListObserver, | 42 public WindowControllerListObserver, |
| 43 #if !defined(OS_MACOSX) | 43 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
| 44 public views::WidgetFocusChangeListener, | 44 public views::WidgetFocusChangeListener, |
| 45 #endif | 45 #endif |
| 46 public content::NotificationObserver { | 46 public content::NotificationObserver { |
| 47 public: | 47 public: |
| 48 explicit WindowsEventRouter(Profile* profile); | 48 explicit WindowsEventRouter(Profile* profile); |
| 49 ~WindowsEventRouter() override; | 49 ~WindowsEventRouter() override; |
| 50 | 50 |
| 51 // |window_controller| is NULL to indicate a focused window has lost focus. | 51 // |window_controller| is NULL to indicate a focused window has lost focus. |
| 52 void OnActiveWindowChanged(WindowController* window_controller); | 52 void OnActiveWindowChanged(WindowController* window_controller); |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // extensions::AppWindowRegistry::Observer: | 55 // extensions::AppWindowRegistry::Observer: |
| 56 void OnAppWindowAdded(extensions::AppWindow* app_window) override; | 56 void OnAppWindowAdded(extensions::AppWindow* app_window) override; |
| 57 void OnAppWindowRemoved(extensions::AppWindow* app_window) override; | 57 void OnAppWindowRemoved(extensions::AppWindow* app_window) override; |
| 58 void OnAppWindowActivated(extensions::AppWindow* app_window) override; | 58 void OnAppWindowActivated(extensions::AppWindow* app_window) override; |
| 59 | 59 |
| 60 // WindowControllerListObserver methods: | 60 // WindowControllerListObserver methods: |
| 61 void OnWindowControllerAdded(WindowController* window_controller) override; | 61 void OnWindowControllerAdded(WindowController* window_controller) override; |
| 62 void OnWindowControllerRemoved(WindowController* window) override; | 62 void OnWindowControllerRemoved(WindowController* window) override; |
| 63 | 63 |
| 64 #if !defined(OS_MACOSX) | 64 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
| 65 void OnNativeFocusChanged(gfx::NativeView focused_now) override; | 65 void OnNativeFocusChanged(gfx::NativeView focused_now) override; |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 // content::NotificationObserver. | 68 // content::NotificationObserver. |
| 69 void Observe(int type, | 69 void Observe(int type, |
| 70 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) override; | 71 const content::NotificationDetails& details) override; |
| 72 | 72 |
| 73 void DispatchEvent(events::HistogramValue histogram_value, | 73 void DispatchEvent(events::HistogramValue histogram_value, |
| 74 const std::string& event_name, | 74 const std::string& event_name, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 102 // Observed WindowControllerList. | 102 // Observed WindowControllerList. |
| 103 ScopedObserver<WindowControllerList, WindowControllerListObserver> | 103 ScopedObserver<WindowControllerList, WindowControllerListObserver> |
| 104 observed_controller_list_; | 104 observed_controller_list_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); | 106 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace extensions | 109 } // namespace extensions |
| 110 | 110 |
| 111 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 111 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
| OLD | NEW |