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 <string> | 9 #include <string> |
9 | 10 |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/containers/scoped_ptr_hash_map.h" | |
11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/extensions/window_controller_list_observer.h" | 14 #include "chrome/browser/extensions/window_controller_list_observer.h" |
13 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
17 #include "extensions/browser/app_window/app_window_registry.h" | |
15 | 18 |
16 #if !defined(OS_MACOSX) | 19 #if !defined(OS_MACOSX) |
17 #include "ui/views/focus/widget_focus_manager.h" | 20 #include "ui/views/focus/widget_focus_manager.h" |
18 #endif | 21 #endif |
19 | 22 |
20 class Profile; | 23 class Profile; |
21 | 24 |
22 namespace base { | 25 namespace base { |
23 class ListValue; | 26 class ListValue; |
24 } | 27 } |
25 | 28 |
26 namespace extensions { | 29 namespace extensions { |
27 | 30 |
31 class AppWindow; | |
32 class AppWindowController; | |
33 | |
28 // The WindowsEventRouter sends chrome.windows.* events to listeners | 34 // The WindowsEventRouter sends chrome.windows.* events to listeners |
29 // inside extension process renderers. The router listens to *all* events, | 35 // inside extension process renderers. The router listens to *all* events, |
30 // but will only route events within a profile to extension processes in the | 36 // but will only route events within a profile to extension processes in the |
31 // same profile. | 37 // same profile. |
32 class WindowsEventRouter : public WindowControllerListObserver, | 38 class WindowsEventRouter : public AppWindowRegistry::Observer, |
39 public WindowControllerListObserver, | |
33 #if !defined(OS_MACOSX) | 40 #if !defined(OS_MACOSX) |
34 public views::WidgetFocusChangeListener, | 41 public views::WidgetFocusChangeListener, |
35 #endif | 42 #endif |
36 public content::NotificationObserver { | 43 public content::NotificationObserver { |
37 public: | 44 public: |
38 explicit WindowsEventRouter(Profile* profile); | 45 explicit WindowsEventRouter(Profile* profile); |
39 ~WindowsEventRouter() override; | 46 ~WindowsEventRouter() override; |
40 | 47 |
48 void DispatchEvents(); | |
dcheng
2015/06/29 18:15:49
The name of this member makes it sound like this a
llandwerlin-old
2015/06/30 10:20:47
Done.
| |
49 | |
50 // extensions::AppWindowRegistry::Observer: | |
51 void OnAppWindowAdded(extensions::AppWindow* app_window) override; | |
52 void OnAppWindowRemoved(extensions::AppWindow* app_window) override; | |
53 | |
41 // WindowControllerListObserver methods: | 54 // WindowControllerListObserver methods: |
42 void OnWindowControllerAdded(WindowController* window_controller) override; | 55 void OnWindowControllerAdded(WindowController* window_controller) override; |
43 void OnWindowControllerRemoved(WindowController* window) override; | 56 void OnWindowControllerRemoved(WindowController* window) override; |
44 | 57 |
45 #if !defined(OS_MACOSX) | 58 #if !defined(OS_MACOSX) |
46 void OnNativeFocusChanged(gfx::NativeView focused_now) override; | 59 void OnNativeFocusChanged(gfx::NativeView focused_now) override; |
47 #endif | 60 #endif |
48 | 61 |
49 // content::NotificationObserver. | 62 // content::NotificationObserver. |
50 void Observe(int type, | 63 void Observe(int type, |
(...skipping 15 matching lines...) Expand all Loading... | |
66 | 79 |
67 // The profile the currently focused window belongs to; either the main or | 80 // The profile the currently focused window belongs to; either the main or |
68 // incognito profile or NULL (none of the above). We remember this in order | 81 // incognito profile or NULL (none of the above). We remember this in order |
69 // to correctly handle focus changes between non-OTR and OTR windows. | 82 // to correctly handle focus changes between non-OTR and OTR windows. |
70 Profile* focused_profile_; | 83 Profile* focused_profile_; |
71 | 84 |
72 // The currently focused window. We keep this so as to avoid sending multiple | 85 // The currently focused window. We keep this so as to avoid sending multiple |
73 // windows.onFocusChanged events with the same windowId. | 86 // windows.onFocusChanged events with the same windowId. |
74 int focused_window_id_; | 87 int focused_window_id_; |
75 | 88 |
89 // Whether to dispatch events. | |
90 bool dispatch_events_; | |
91 | |
92 // Map of application windows. | |
93 base::ScopedPtrHashMap<int, scoped_ptr<AppWindowController>> app_windows_; | |
94 | |
76 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); | 95 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); |
77 }; | 96 }; |
78 | 97 |
79 } // namespace extensions | 98 } // namespace extensions |
80 | 99 |
81 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 100 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
OLD | NEW |