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

Side by Side Diff: chrome/browser/extensions/extension_browser_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: fix non-mac compiles Created 8 years, 4 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
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_EXTENSION_BROWSER_EVENT_ROUTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "chrome/browser/extensions/api/tabs/tabs.h" 13 #include "chrome/browser/extensions/api/tabs/tabs.h"
14 #include "chrome/browser/extensions/extension_toolbar_model.h" 14 #include "chrome/browser/extensions/extension_toolbar_model.h"
15 #include "chrome/browser/ui/browser_list_observer.h" 15 #include "chrome/browser/ui/browser_list_observer.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #if defined(TOOLKIT_VIEWS)
19 #include "ui/views/focus/widget_focus_manager.h"
20 #elif defined(TOOLKIT_GTK)
21 #include "ui/base/x/active_window_watcher_x_observer.h"
22 #endif
23 18
24 namespace content { 19 namespace content {
25 class WebContents; 20 class WebContents;
26 } 21 }
27 22
28 // The ExtensionBrowserEventRouter listens to Browser window & tab events 23 // The ExtensionBrowserEventRouter listens to Browser window & tab events
29 // and routes them to listeners inside extension process renderers. 24 // and routes them to listeners inside extension process renderers.
30 // ExtensionBrowserEventRouter listens to *all* events, but will only route 25 // ExtensionBrowserEventRouter listens to *all* events, but will only route
31 // events from windows/tabs within a profile to extension processes in the same 26 // events from windows/tabs within a profile to extension processes in the same
32 // profile. 27 // profile.
33 class ExtensionBrowserEventRouter : public TabStripModelObserver, 28 class ExtensionBrowserEventRouter : public TabStripModelObserver,
34 #if defined(TOOLKIT_VIEWS)
35 public views::WidgetFocusChangeListener,
36 #elif defined(TOOLKIT_GTK)
37 public ui::ActiveWindowWatcherXObserver,
38 #endif
39 public chrome::BrowserListObserver, 29 public chrome::BrowserListObserver,
40 public content::NotificationObserver { 30 public content::NotificationObserver {
41 public: 31 public:
42 explicit ExtensionBrowserEventRouter(Profile* profile); 32 explicit ExtensionBrowserEventRouter(Profile* profile);
43 virtual ~ExtensionBrowserEventRouter(); 33 virtual ~ExtensionBrowserEventRouter();
44 34
45 // Must be called once. Subsequent calls have no effect. 35 // Must be called once. Subsequent calls have no effect.
46 void Init(); 36 void Init();
47 37
48 // chrome::BrowserListObserver 38 // chrome::BrowserListObserver
49 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; 39 virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
50 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; 40 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
51 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; 41 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE;
52 42
53 #if defined(TOOLKIT_VIEWS)
54 virtual void OnNativeFocusChange(gfx::NativeView focused_before,
55 gfx::NativeView focused_now) OVERRIDE;
56 #elif defined(TOOLKIT_GTK)
57 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE;
58 #endif
59
60 // Called from Observe() on BROWSER_WINDOW_READY (not a part of
61 // chrome::BrowserListObserver).
62 void OnBrowserWindowReady(Browser* browser);
63
64 // TabStripModelObserver 43 // TabStripModelObserver
65 virtual void TabInsertedAt(TabContents* contents, int index, 44 virtual void TabInsertedAt(TabContents* contents, int index,
66 bool active) OVERRIDE; 45 bool active) OVERRIDE;
67 virtual void TabClosingAt(TabStripModel* tab_strip_model, 46 virtual void TabClosingAt(TabStripModel* tab_strip_model,
68 TabContents* contents, 47 TabContents* contents,
69 int index) OVERRIDE; 48 int index) OVERRIDE;
70 virtual void TabDetachedAt(TabContents* contents, int index) OVERRIDE; 49 virtual void TabDetachedAt(TabContents* contents, int index) OVERRIDE;
71 virtual void ActiveTabChanged(TabContents* old_contents, 50 virtual void ActiveTabChanged(TabContents* old_contents,
72 TabContents* new_contents, 51 TabContents* new_contents,
73 int index, 52 int index,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // event to send based on what the extension wants. 199 // event to send based on what the extension wants.
221 void ExtensionActionExecuted(Profile* profile, 200 void ExtensionActionExecuted(Profile* profile,
222 const ExtensionAction& extension_action, 201 const ExtensionAction& extension_action,
223 TabContents* tab_contents); 202 TabContents* tab_contents);
224 203
225 std::map<int, TabEntry> tab_entries_; 204 std::map<int, TabEntry> tab_entries_;
226 205
227 // The main profile that owns this event router. 206 // The main profile that owns this event router.
228 Profile* profile_; 207 Profile* profile_;
229 208
230 // The profile the currently focused window belongs to; either the main or
231 // incognito profile or NULL (none of the above). We remember this in order
232 // to correctly handle focus changes between non-OTR and OTR windows.
233 Profile* focused_profile_;
234
235 // The currently focused window. We keep this so as to avoid sending multiple
236 // windows.onFocusChanged events with the same windowId.
237 int focused_window_id_;
238
239 DISALLOW_COPY_AND_ASSIGN(ExtensionBrowserEventRouter); 209 DISALLOW_COPY_AND_ASSIGN(ExtensionBrowserEventRouter);
240 }; 210 };
241 211
242 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_ 212 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698