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

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

Issue 11366074: Coalesce event router Init calls into their constructors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: aa Created 8 years, 1 month 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_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
(...skipping 17 matching lines...) Expand all
28 // BrowserEventRouter listens to *all* events, but will only route 28 // BrowserEventRouter listens to *all* events, but will only route
29 // events from windows/tabs within a profile to extension processes in the same 29 // events from windows/tabs within a profile to extension processes in the same
30 // profile. 30 // profile.
31 class BrowserEventRouter : public TabStripModelObserver, 31 class BrowserEventRouter : public TabStripModelObserver,
32 public chrome::BrowserListObserver, 32 public chrome::BrowserListObserver,
33 public content::NotificationObserver { 33 public content::NotificationObserver {
34 public: 34 public:
35 explicit BrowserEventRouter(Profile* profile); 35 explicit BrowserEventRouter(Profile* profile);
36 virtual ~BrowserEventRouter(); 36 virtual ~BrowserEventRouter();
37 37
38 // Must be called once. Subsequent calls have no effect.
39 void Init();
40
41 // chrome::BrowserListObserver 38 // chrome::BrowserListObserver
42 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; 39 virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
43 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; 40 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
44 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; 41 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE;
45 42
46 // TabStripModelObserver 43 // TabStripModelObserver
47 virtual void TabInsertedAt(TabContents* contents, int index, 44 virtual void TabInsertedAt(TabContents* contents, int index,
48 bool active) OVERRIDE; 45 bool active) OVERRIDE;
49 virtual void TabClosingAt(TabStripModel* tab_strip_model, 46 virtual void TabClosingAt(TabStripModel* tab_strip_model,
50 TabContents* contents, 47 TabContents* contents,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 144
148 // Register ourselves to receive the various notifications we are interested 145 // Register ourselves to receive the various notifications we are interested
149 // in for a tab. 146 // in for a tab.
150 void RegisterForTabNotifications(content::WebContents* contents); 147 void RegisterForTabNotifications(content::WebContents* contents);
151 148
152 // Removes notifications added in RegisterForTabNotifications. 149 // Removes notifications added in RegisterForTabNotifications.
153 void UnregisterForTabNotifications(content::WebContents* contents); 150 void UnregisterForTabNotifications(content::WebContents* contents);
154 151
155 content::NotificationRegistrar registrar_; 152 content::NotificationRegistrar registrar_;
156 153
157 bool initialized_;
158
159 // Maintain some information about known tabs, so we can: 154 // Maintain some information about known tabs, so we can:
160 // 155 //
161 // - distinguish between tab creation and tab insertion 156 // - distinguish between tab creation and tab insertion
162 // - not send tab-detached after tab-removed 157 // - not send tab-detached after tab-removed
163 // - reduce the "noise" of TabChangedAt() when sending events to extensions 158 // - reduce the "noise" of TabChangedAt() when sending events to extensions
164 class TabEntry { 159 class TabEntry {
165 public: 160 public:
166 // Create a new tab entry whose initial state is TAB_COMPLETE. This 161 // Create a new tab entry whose initial state is TAB_COMPLETE. This
167 // constructor is required because TabEntry objects placed inside an 162 // constructor is required because TabEntry objects placed inside an
168 // std::map<> by value. 163 // std::map<> by value.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 200
206 // The main profile that owns this event router. 201 // The main profile that owns this event router.
207 Profile* profile_; 202 Profile* profile_;
208 203
209 DISALLOW_COPY_AND_ASSIGN(BrowserEventRouter); 204 DISALLOW_COPY_AND_ASSIGN(BrowserEventRouter);
210 }; 205 };
211 206
212 } // namespace extensions 207 } // namespace extensions
213 208
214 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 209 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_navigation/web_navigation_api.cc ('k') | chrome/browser/extensions/browser_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698