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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 years, 7 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
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_EVENT_ROUTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #include "ipc/ipc_message.h" 18 #include "ipc/ipc_message.h"
19 19
20 class GURL; 20 class GURL;
21 class Extension;
22 class ExtensionHost; 21 class ExtensionHost;
23 class ExtensionDevToolsManager; 22 class ExtensionDevToolsManager;
24 class Profile; 23 class Profile;
25 24
26 namespace content { 25 namespace content {
27 class RenderProcessHost; 26 class RenderProcessHost;
28 } 27 }
29 28
29 namespace extensions {
30 class Extension;
31 }
32
30 class ExtensionEventRouter : public content::NotificationObserver { 33 class ExtensionEventRouter : public content::NotificationObserver {
31 public: 34 public:
32 // These constants convey the state of our knowledge of whether we're in 35 // These constants convey the state of our knowledge of whether we're in
33 // a user-caused gesture as part of DispatchEvent. 36 // a user-caused gesture as part of DispatchEvent.
34 enum UserGestureState { 37 enum UserGestureState {
35 USER_GESTURE_UNKNOWN = 0, 38 USER_GESTURE_UNKNOWN = 0,
36 USER_GESTURE_ENABLED = 1, 39 USER_GESTURE_ENABLED = 1,
37 USER_GESTURE_NOT_ENABLED = 2, 40 USER_GESTURE_NOT_ENABLED = 2,
38 }; 41 };
39 42
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // Dispatches the event to a single listener process. 159 // Dispatches the event to a single listener process.
157 void DispatchEventToListener(const ListenerProcess& listener, 160 void DispatchEventToListener(const ListenerProcess& listener,
158 const linked_ptr<ExtensionEvent>& event); 161 const linked_ptr<ExtensionEvent>& event);
159 162
160 // Returns false when the event is scoped to a profile and the listening 163 // Returns false when the event is scoped to a profile and the listening
161 // extension does not have access to events from that profile. Also fills 164 // extension does not have access to events from that profile. Also fills
162 // |event_args| with the proper arguments to send, which may differ if 165 // |event_args| with the proper arguments to send, which may differ if
163 // the event crosses the incognito boundary. 166 // the event crosses the incognito boundary.
164 bool CanDispatchEventToProfile( 167 bool CanDispatchEventToProfile(
165 Profile* profile, 168 Profile* profile,
166 const Extension* extension, 169 const extensions::Extension* extension,
167 const linked_ptr<ExtensionEvent>& event, 170 const linked_ptr<ExtensionEvent>& event,
168 const std::string** event_args); 171 const std::string** event_args);
169 172
170 // Ensures that all lazy background pages that are interested in the given 173 // Ensures that all lazy background pages that are interested in the given
171 // event are loaded, and queues the event if the page is not ready yet. 174 // event are loaded, and queues the event if the page is not ready yet.
172 // If |extension_id| is non-empty, we load only that extension's page 175 // If |extension_id| is non-empty, we load only that extension's page
173 // (assuming it is interested in the event). 176 // (assuming it is interested in the event).
174 void LoadLazyBackgroundPagesForEvent( 177 void LoadLazyBackgroundPagesForEvent(
175 const std::string& extension_id, 178 const std::string& extension_id,
176 const linked_ptr<ExtensionEvent>& event); 179 const linked_ptr<ExtensionEvent>& event);
177 180
178 // Possibly loads given extension's background page in preparation to 181 // Possibly loads given extension's background page in preparation to
179 // dispatch an event. 182 // dispatch an event.
180 void MaybeLoadLazyBackgroundPage( 183 void MaybeLoadLazyBackgroundPage(
181 Profile* profile, 184 Profile* profile,
182 const Extension* extension, 185 const extensions::Extension* extension,
183 const linked_ptr<ExtensionEvent>& event); 186 const linked_ptr<ExtensionEvent>& event);
184 187
185 // Track of the number of dispatched events that have not yet sent an 188 // Track of the number of dispatched events that have not yet sent an
186 // ACK from the renderer. 189 // ACK from the renderer.
187 void IncrementInFlightEvents(Profile* profile, const Extension* extension); 190 void IncrementInFlightEvents(Profile* profile,
191 const extensions::Extension* extension);
188 192
189 void DispatchPendingEvent(const linked_ptr<ExtensionEvent>& event, 193 void DispatchPendingEvent(const linked_ptr<ExtensionEvent>& event,
190 ExtensionHost* host); 194 ExtensionHost* host);
191 195
192 Profile* profile_; 196 Profile* profile_;
193 197
194 content::NotificationRegistrar registrar_; 198 content::NotificationRegistrar registrar_;
195 199
196 scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_; 200 scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_;
197 201
198 // The list of active extension processes that are listening to events. 202 // The list of active extension processes that are listening to events.
199 ListenerMap listeners_; 203 ListenerMap listeners_;
200 204
201 // The list of all the lazy (non-persistent) background pages that are 205 // The list of all the lazy (non-persistent) background pages that are
202 // listening to events. This is just a cache of the real list, which is 206 // listening to events. This is just a cache of the real list, which is
203 // stored on disk in the extension prefs. 207 // stored on disk in the extension prefs.
204 ListenerMap lazy_listeners_; 208 ListenerMap lazy_listeners_;
205 209
206 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); 210 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter);
207 }; 211 };
208 212
209 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ 213 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_disabled_ui_browsertest.cc ('k') | chrome/browser/extensions/extension_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698