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

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

Issue 10566018: Initial work to remove the notion of all extension message payloads as strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing parts of a different change. Created 8 years, 6 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_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 "base/values.h"
16 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
18 #include "ipc/ipc_sender.h" 19 #include "ipc/ipc_sender.h"
19 20
20 class GURL; 21 class GURL;
21 class ExtensionHost; 22 class ExtensionHost;
22 class ExtensionDevToolsManager; 23 class ExtensionDevToolsManager;
23 class Profile; 24 class Profile;
24 25
25 namespace content { 26 namespace content {
(...skipping 12 matching lines...) Expand all
38 USER_GESTURE_UNKNOWN = 0, 39 USER_GESTURE_UNKNOWN = 0,
39 USER_GESTURE_ENABLED = 1, 40 USER_GESTURE_ENABLED = 1,
40 USER_GESTURE_NOT_ENABLED = 2, 41 USER_GESTURE_NOT_ENABLED = 2,
41 }; 42 };
42 43
43 // Sends an event via ipc_sender to the given extension. Can be called on 44 // Sends an event via ipc_sender to the given extension. Can be called on
44 // any thread. 45 // any thread.
45 static void DispatchEvent(IPC::Sender* ipc_sender, 46 static void DispatchEvent(IPC::Sender* ipc_sender,
46 const std::string& extension_id, 47 const std::string& extension_id,
47 const std::string& event_name, 48 const std::string& event_name,
49 const base::Value& event_args,
50 const GURL& event_url,
51 UserGestureState user_gesture);
52 static void DispatchEvent(IPC::Sender* ipc_sender,
asargent_no_longer_on_chrome 2012/06/18 16:25:30 Can you add a comment here saying that this is dep
Garret Kelly 2012/06/18 18:15:01 Done.
53 const std::string& extension_id,
54 const std::string& event_name,
48 const std::string& event_args, 55 const std::string& event_args,
49 const GURL& event_url, 56 const GURL& event_url,
50 UserGestureState user_gesture); 57 UserGestureState user_gesture);
51 58
52 explicit ExtensionEventRouter(Profile* profile); 59 explicit ExtensionEventRouter(Profile* profile);
53 virtual ~ExtensionEventRouter(); 60 virtual ~ExtensionEventRouter();
54 61
55 // Add or remove the process/extension pair as a listener for |event_name|. 62 // Add or remove the process/extension pair as a listener for |event_name|.
56 // Note that multiple extensions can share a process due to process 63 // Note that multiple extensions can share a process due to process
57 // collapsing. Also, a single extension can have 2 processes if it is a split 64 // collapsing. Also, a single extension can have 2 processes if it is a split
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 Profile* restrict_to_profile, 98 Profile* restrict_to_profile,
92 const GURL& event_url); 99 const GURL& event_url);
93 100
94 // Same as above, except only send the event to the given extension. 101 // Same as above, except only send the event to the given extension.
95 virtual void DispatchEventToExtension( 102 virtual void DispatchEventToExtension(
96 const std::string& extension_id, 103 const std::string& extension_id,
97 const std::string& event_name, 104 const std::string& event_name,
98 const std::string& event_args, 105 const std::string& event_args,
99 Profile* restrict_to_profile, 106 Profile* restrict_to_profile,
100 const GURL& event_url); 107 const GURL& event_url);
108 virtual void DispatchEventToExtension(
asargent_no_longer_on_chrome 2012/06/18 16:25:30 add same comment here
Garret Kelly 2012/06/18 18:15:01 Done.
109 const std::string& extension_id,
110 const std::string& event_name,
111 const base::Value& event_args,
112 Profile* restrict_to_profile,
113 const GURL& event_url);
101 114
102 // Dispatch an event to particular extension. Also include an 115 // Dispatch an event to particular extension. Also include an
103 // explicit user gesture indicator. 116 // explicit user gesture indicator.
104 virtual void DispatchEventToExtension( 117 virtual void DispatchEventToExtension(
105 const std::string& extension_id, 118 const std::string& extension_id,
106 const std::string& event_name, 119 const std::string& event_name,
107 const std::string& event_args, 120 const std::string& event_args,
108 Profile* restrict_to_profile, 121 Profile* restrict_to_profile,
109 const GURL& event_url, 122 const GURL& event_url,
110 UserGestureState user_gesture); 123 UserGestureState user_gesture);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 const linked_ptr<ExtensionEvent>& event); 174 const linked_ptr<ExtensionEvent>& event);
162 175
163 // Returns false when the event is scoped to a profile and the listening 176 // Returns false when the event is scoped to a profile and the listening
164 // extension does not have access to events from that profile. Also fills 177 // extension does not have access to events from that profile. Also fills
165 // |event_args| with the proper arguments to send, which may differ if 178 // |event_args| with the proper arguments to send, which may differ if
166 // the event crosses the incognito boundary. 179 // the event crosses the incognito boundary.
167 bool CanDispatchEventToProfile( 180 bool CanDispatchEventToProfile(
168 Profile* profile, 181 Profile* profile,
169 const extensions::Extension* extension, 182 const extensions::Extension* extension,
170 const linked_ptr<ExtensionEvent>& event, 183 const linked_ptr<ExtensionEvent>& event,
171 const std::string** event_args); 184 const base::Value** event_args);
172 185
173 // Ensures that all lazy background pages that are interested in the given 186 // Ensures that all lazy background pages that are interested in the given
174 // event are loaded, and queues the event if the page is not ready yet. 187 // event are loaded, and queues the event if the page is not ready yet.
175 // If |extension_id| is non-empty, we load only that extension's page 188 // If |extension_id| is non-empty, we load only that extension's page
176 // (assuming it is interested in the event). 189 // (assuming it is interested in the event).
177 void LoadLazyBackgroundPagesForEvent( 190 void LoadLazyBackgroundPagesForEvent(
178 const std::string& extension_id, 191 const std::string& extension_id,
179 const linked_ptr<ExtensionEvent>& event); 192 const linked_ptr<ExtensionEvent>& event);
180 193
181 // Possibly loads given extension's background page in preparation to 194 // Possibly loads given extension's background page in preparation to
(...skipping 22 matching lines...) Expand all
204 217
205 // The list of all the lazy (non-persistent) background pages that are 218 // The list of all the lazy (non-persistent) background pages that are
206 // listening to events. This is just a cache of the real list, which is 219 // listening to events. This is just a cache of the real list, which is
207 // stored on disk in the extension prefs. 220 // stored on disk in the extension prefs.
208 ListenerMap lazy_listeners_; 221 ListenerMap lazy_listeners_;
209 222
210 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); 223 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter);
211 }; 224 };
212 225
213 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ 226 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698