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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // inside extension process renderers. The router listens to *all* events, | 28 // inside extension process renderers. The router listens to *all* events, |
29 // 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 |
30 // same profile. | 30 // same profile. |
31 class WindowsEventRouter : public WindowControllerListObserver, | 31 class WindowsEventRouter : public WindowControllerListObserver, |
32 #if defined(TOOLKIT_VIEWS) | 32 #if defined(TOOLKIT_VIEWS) |
33 public views::WidgetFocusChangeListener, | 33 public views::WidgetFocusChangeListener, |
34 #endif | 34 #endif |
35 public content::NotificationObserver { | 35 public content::NotificationObserver { |
36 public: | 36 public: |
37 explicit WindowsEventRouter(Profile* profile); | 37 explicit WindowsEventRouter(Profile* profile); |
38 virtual ~WindowsEventRouter(); | 38 ~WindowsEventRouter() override; |
39 | 39 |
40 // WindowControllerListObserver methods: | 40 // WindowControllerListObserver methods: |
41 virtual void OnWindowControllerAdded( | 41 void OnWindowControllerAdded(WindowController* window_controller) override; |
42 WindowController* window_controller) override; | 42 void OnWindowControllerRemoved(WindowController* window) override; |
43 virtual void OnWindowControllerRemoved( | |
44 WindowController* window) override; | |
45 | 43 |
46 #if defined(TOOLKIT_VIEWS) | 44 #if defined(TOOLKIT_VIEWS) |
47 virtual void OnNativeFocusChange(gfx::NativeView focused_before, | 45 virtual void OnNativeFocusChange(gfx::NativeView focused_before, |
48 gfx::NativeView focused_now) override; | 46 gfx::NativeView focused_now) override; |
49 #endif | 47 #endif |
50 | 48 |
51 // content::NotificationObserver. | 49 // content::NotificationObserver. |
52 virtual void Observe(int type, | 50 void Observe(int type, |
53 const content::NotificationSource& source, | 51 const content::NotificationSource& source, |
54 const content::NotificationDetails& details) override; | 52 const content::NotificationDetails& details) override; |
55 | 53 |
56 // |window_controller| is NULL to indicate a focused window has lost focus. | 54 // |window_controller| is NULL to indicate a focused window has lost focus. |
57 void OnActiveWindowChanged(WindowController* window_controller); | 55 void OnActiveWindowChanged(WindowController* window_controller); |
58 | 56 |
59 private: | 57 private: |
60 void DispatchEvent(const std::string& event_name, | 58 void DispatchEvent(const std::string& event_name, |
61 Profile* profile, | 59 Profile* profile, |
62 scoped_ptr<base::ListValue> args); | 60 scoped_ptr<base::ListValue> args); |
63 | 61 |
64 content::NotificationRegistrar registrar_; | 62 content::NotificationRegistrar registrar_; |
65 | 63 |
66 // The main profile that owns this event router. | 64 // The main profile that owns this event router. |
67 Profile* profile_; | 65 Profile* profile_; |
68 | 66 |
69 // The profile the currently focused window belongs to; either the main or | 67 // The profile the currently focused window belongs to; either the main or |
70 // incognito profile or NULL (none of the above). We remember this in order | 68 // incognito profile or NULL (none of the above). We remember this in order |
71 // to correctly handle focus changes between non-OTR and OTR windows. | 69 // to correctly handle focus changes between non-OTR and OTR windows. |
72 Profile* focused_profile_; | 70 Profile* focused_profile_; |
73 | 71 |
74 // The currently focused window. We keep this so as to avoid sending multiple | 72 // The currently focused window. We keep this so as to avoid sending multiple |
75 // windows.onFocusChanged events with the same windowId. | 73 // windows.onFocusChanged events with the same windowId. |
76 int focused_window_id_; | 74 int focused_window_id_; |
77 | 75 |
78 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); | 76 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); |
79 }; | 77 }; |
80 | 78 |
81 } // namespace extensions | 79 } // namespace extensions |
82 | 80 |
83 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 81 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
OLD | NEW |