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

Side by Side Diff: chrome/browser/extensions/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: 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
« no previous file with comments | « no previous file | chrome/browser/extensions/browser_event_router.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BROWSER_EVENT_ROUTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_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 namespace extensions { 23 namespace extensions {
29 24
30 // The BrowserEventRouter listens to Browser window & tab events 25 // The BrowserEventRouter listens to Browser window & tab events
31 // and routes them to listeners inside extension process renderers. 26 // and routes them to listeners inside extension process renderers.
32 // BrowserEventRouter listens to *all* events, but will only route 27 // BrowserEventRouter listens to *all* events, but will only route
33 // events from windows/tabs within a profile to extension processes in the same 28 // events from windows/tabs within a profile to extension processes in the same
34 // profile. 29 // profile.
35 class BrowserEventRouter : public TabStripModelObserver, 30 class BrowserEventRouter : public TabStripModelObserver,
36 #if defined(TOOLKIT_VIEWS) 31 public chrome::BrowserListObserver,
37 public views::WidgetFocusChangeListener, 32 public content::NotificationObserver {
38 #elif defined(TOOLKIT_GTK)
39 public ui::ActiveWindowWatcherXObserver,
40 #endif
41 public chrome::BrowserListObserver,
42 public content::NotificationObserver {
43 public: 33 public:
44 explicit BrowserEventRouter(Profile* profile); 34 explicit BrowserEventRouter(Profile* profile);
45 virtual ~BrowserEventRouter(); 35 virtual ~BrowserEventRouter();
46 36
47 // Must be called once. Subsequent calls have no effect. 37 // Must be called once. Subsequent calls have no effect.
48 void Init(); 38 void Init();
49 39
50 // chrome::BrowserListObserver 40 // chrome::BrowserListObserver
51 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; 41 virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
52 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; 42 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
53 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; 43 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE;
54 44
55 #if defined(TOOLKIT_VIEWS)
56 virtual void OnNativeFocusChange(gfx::NativeView focused_before,
57 gfx::NativeView focused_now) OVERRIDE;
58 #elif defined(TOOLKIT_GTK)
59 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE;
60 #endif
61
62 // Called from Observe() on BROWSER_WINDOW_READY (not a part of
63 // chrome::BrowserListObserver).
64 void OnBrowserWindowReady(Browser* browser);
65
66 // TabStripModelObserver 45 // TabStripModelObserver
67 virtual void TabInsertedAt(TabContents* contents, int index, 46 virtual void TabInsertedAt(TabContents* contents, int index,
68 bool active) OVERRIDE; 47 bool active) OVERRIDE;
69 virtual void TabClosingAt(TabStripModel* tab_strip_model, 48 virtual void TabClosingAt(TabStripModel* tab_strip_model,
70 TabContents* contents, 49 TabContents* contents,
71 int index) OVERRIDE; 50 int index) OVERRIDE;
72 virtual void TabDetachedAt(TabContents* contents, int index) OVERRIDE; 51 virtual void TabDetachedAt(TabContents* contents, int index) OVERRIDE;
73 virtual void ActiveTabChanged(TabContents* old_contents, 52 virtual void ActiveTabChanged(TabContents* old_contents,
74 TabContents* new_contents, 53 TabContents* new_contents,
75 int index, 54 int index,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // event to send based on what the extension wants. 201 // event to send based on what the extension wants.
223 void ExtensionActionExecuted(Profile* profile, 202 void ExtensionActionExecuted(Profile* profile,
224 const ExtensionAction& extension_action, 203 const ExtensionAction& extension_action,
225 TabContents* tab_contents); 204 TabContents* tab_contents);
226 205
227 std::map<int, TabEntry> tab_entries_; 206 std::map<int, TabEntry> tab_entries_;
228 207
229 // The main profile that owns this event router. 208 // The main profile that owns this event router.
230 Profile* profile_; 209 Profile* profile_;
231 210
232 // The profile the currently focused window belongs to; either the main or
233 // incognito profile or NULL (none of the above). We remember this in order
234 // to correctly handle focus changes between non-OTR and OTR windows.
235 Profile* focused_profile_;
236
237 // The currently focused window. We keep this so as to avoid sending multiple
238 // windows.onFocusChanged events with the same windowId.
239 int focused_window_id_;
240
241 DISALLOW_COPY_AND_ASSIGN(BrowserEventRouter); 211 DISALLOW_COPY_AND_ASSIGN(BrowserEventRouter);
242 }; 212 };
243 213
244 } // namespace extensions 214 } // namespace extensions
245 215
246 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 216 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/browser_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698