Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(914)

Side by Side Diff: chrome/browser/extensions/window_event_router.h

Issue 10777004: Support chrome.windows extension API events for browserless Panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_
7
8 #include "base/basictypes.h"
9 #include "chrome/browser/extensions/window_controller_list_observer.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
12 #if defined(TOOLKIT_VIEWS)
13 #include "ui/views/focus/widget_focus_manager.h"
14 #elif defined(TOOLKIT_GTK)
15 #include "ui/base/x/active_window_watcher_x_observer.h"
16 #endif
17
18 class Profile;
19
20 namespace base {
21 class ListValue;
22 }
23
24 namespace extensions {
25
26 // The WindowEventRouter sends chrome.windows.* events to listeners
27 // inside extension process renderers. The router listens to *all* events,
28 // but will only route eventes within a profile to extension processes in the
29 // same profile.
30 class WindowEventRouter : public WindowControllerListObserver,
31 #if defined(TOOLKIT_VIEWS)
32 public views::WidgetFocusChangeListener,
33 #elif defined(TOOLKIT_GTK)
34 public ui::ActiveWindowWatcherXObserver,
35 #endif
36 public content::NotificationObserver {
37 public:
38 explicit WindowEventRouter(Profile* profile);
39 virtual ~WindowEventRouter();
40
41 // Must be called once. Subsequent calls have no effect.
42 void Init();
43
44 // WindowControllerListObserver methods:
45 virtual void OnWindowControllerAdded(
46 WindowController* window_controller) OVERRIDE;
47 virtual void OnWindowControllerRemoved(
48 WindowController* window) OVERRIDE;
49
50 #if defined(TOOLKIT_VIEWS)
51 virtual void OnNativeFocusChange(gfx::NativeView focused_before,
52 gfx::NativeView focused_now) OVERRIDE;
53 #elif defined(TOOLKIT_GTK)
54 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE;
55 #endif
56
57 // content::NotificationObserver.
58 virtual void Observe(int type,
59 const content::NotificationSource& source,
60 const content::NotificationDetails& details) OVERRIDE;
61
62 // |window_controller| is NULL to indicate a focused window has lost focus.
63 void OnActiveWindowChanged(WindowController* window_controller);
64
65 private:
66 void DispatchEvent(const char* event_name,
67 Profile* profile,
68 base::ListValue* args);
69
70 content::NotificationRegistrar registrar_;
71 bool initialized_;
72
73 // The main profile that owns this event router.
74 Profile* profile_;
75
76 // The profile the currently focused window belongs to; either the main or
77 // incognito profile or NULL (none of the above). We remember this in order
78 // to correctly handle focus changes between non-OTR and OTR windows.
79 Profile* focused_profile_;
80
81 // The currently focused window. We keep this so as to avoid sending multiple
82 // windows.onFocusChanged events with the same windowId.
83 int focused_window_id_;
84
85 DISALLOW_COPY_AND_ASSIGN(WindowEventRouter);
86 };
87
88 } // namespace extensions
89
90 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/window_controller_list_observer.h ('k') | chrome/browser/extensions/window_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698