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

Side by Side Diff: extensions/renderer/dispatcher.h

Issue 344433003: Prepare declarativeContent API for new script injection feature. Added Javascript types and functio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add note about what it means to revert RequestContentScript Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_RENDERER_DISPATCHER_H_ 5 #ifndef EXTENSIONS_RENDERER_DISPATCHER_H_
6 #define EXTENSIONS_RENDERER_DISPATCHER_H_ 6 #define EXTENSIONS_RENDERER_DISPATCHER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/shared_memory.h" 13 #include "base/memory/shared_memory.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "content/public/renderer/render_process_observer.h" 15 #include "content/public/renderer/render_process_observer.h"
16 #include "extensions/common/event_filter.h" 16 #include "extensions/common/event_filter.h"
17 #include "extensions/common/extension_set.h" 17 #include "extensions/common/extension_set.h"
18 #include "extensions/common/extensions_client.h" 18 #include "extensions/common/extensions_client.h"
19 #include "extensions/common/features/feature.h" 19 #include "extensions/common/features/feature.h"
20 #include "extensions/renderer/content_watcher.h"
20 #include "extensions/renderer/resource_bundle_source_map.h" 21 #include "extensions/renderer/resource_bundle_source_map.h"
21 #include "extensions/renderer/script_context.h" 22 #include "extensions/renderer/script_context.h"
22 #include "extensions/renderer/script_context_set.h" 23 #include "extensions/renderer/script_context_set.h"
23 #include "extensions/renderer/v8_schema_registry.h" 24 #include "extensions/renderer/v8_schema_registry.h"
24 #include "third_party/WebKit/public/platform/WebString.h" 25 #include "third_party/WebKit/public/platform/WebString.h"
25 #include "third_party/WebKit/public/platform/WebVector.h" 26 #include "third_party/WebKit/public/platform/WebVector.h"
26 #include "v8/include/v8.h" 27 #include "v8/include/v8.h"
27 28
28 class ChromeRenderViewTest; 29 class ChromeRenderViewTest;
29 class GURL; 30 class GURL;
(...skipping 11 matching lines...) Expand all
41 namespace base { 42 namespace base {
42 class DictionaryValue; 43 class DictionaryValue;
43 class ListValue; 44 class ListValue;
44 } 45 }
45 46
46 namespace content { 47 namespace content {
47 class RenderThread; 48 class RenderThread;
48 } 49 }
49 50
50 namespace extensions { 51 namespace extensions {
51 class ContentWatcher;
52 class DispatcherDelegate; 52 class DispatcherDelegate;
53 class Extension; 53 class Extension;
54 class FilteredEventRouter; 54 class FilteredEventRouter;
55 class ManifestPermissionSet; 55 class ManifestPermissionSet;
56 class RequestSender; 56 class RequestSender;
57 class ScriptContext; 57 class ScriptContext;
58 class UserScriptSlave; 58 class UserScriptSlave;
59 struct Message; 59 struct Message;
60 60
61 // Map from RuleRegistry::event_name to associated ContentWatcher.
62 typedef std::map< std::string, linked_ptr<ContentWatcher> > ContentWatcherMap;
63
61 // Dispatches extension control messages sent to the renderer and stores 64 // Dispatches extension control messages sent to the renderer and stores
62 // renderer extension related state. 65 // renderer extension related state.
63 class Dispatcher : public content::RenderProcessObserver { 66 class Dispatcher : public content::RenderProcessObserver {
64 public: 67 public:
65 explicit Dispatcher(DispatcherDelegate* delegate); 68 explicit Dispatcher(DispatcherDelegate* delegate);
66 virtual ~Dispatcher(); 69 virtual ~Dispatcher();
67 70
68 const std::set<std::string>& function_names() const { 71 const std::set<std::string>& function_names() const {
69 return function_names_; 72 return function_names_;
70 } 73 }
71 74
72 bool is_extension_process() const { return is_extension_process_; } 75 bool is_extension_process() const { return is_extension_process_; }
73 76
74 const ExtensionSet* extensions() const { return &extensions_; } 77 const ExtensionSet* extensions() const { return &extensions_; }
75 78
76 const ScriptContextSet& script_context_set() const { 79 const ScriptContextSet& script_context_set() const {
77 return script_context_set_; 80 return script_context_set_;
78 } 81 }
79 82
80 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); } 83 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); }
81 84
82 ContentWatcher* content_watcher() { return content_watcher_.get(); }
83
84 UserScriptSlave* user_script_slave() { return user_script_slave_.get(); } 85 UserScriptSlave* user_script_slave() { return user_script_slave_.get(); }
85 86
86 RequestSender* request_sender() { return request_sender_.get(); } 87 RequestSender* request_sender() { return request_sender_.get(); }
87 88
88 bool IsExtensionActive(const std::string& extension_id) const; 89 bool IsExtensionActive(const std::string& extension_id) const;
89 90
90 // Finds the extension ID for the JavaScript context associated with the 91 // Finds the extension ID for the JavaScript context associated with the
91 // specified |frame| and isolated world. If |world_id| is zero, finds the 92 // specified |frame| and isolated world. If |world_id| is zero, finds the
92 // extension ID associated with the main world's JavaScript context. If the 93 // extension ID associated with the main world's JavaScript context. If the
93 // JavaScript context isn't from an extension, returns empty string. 94 // JavaScript context isn't from an extension, returns empty string.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void OnUnloaded(const std::string& id); 178 void OnUnloaded(const std::string& id);
178 void OnUpdatePermissions(const ExtensionMsg_UpdatePermissions_Params& params); 179 void OnUpdatePermissions(const ExtensionMsg_UpdatePermissions_Params& params);
179 void OnUpdateTabSpecificPermissions(int page_id, 180 void OnUpdateTabSpecificPermissions(int page_id,
180 int tab_id, 181 int tab_id,
181 const std::string& extension_id, 182 const std::string& extension_id,
182 const URLPatternSet& origin_set); 183 const URLPatternSet& origin_set);
183 void OnUpdateUserScripts(base::SharedMemoryHandle scripts, 184 void OnUpdateUserScripts(base::SharedMemoryHandle scripts,
184 const std::set<std::string>& extension_ids); 185 const std::set<std::string>& extension_ids);
185 void OnUsingWebRequestAPI(bool webrequest_used); 186 void OnUsingWebRequestAPI(bool webrequest_used);
186 187
188 // Handler for ExtensionMsg_WatchPages.
189 void OnWatchPages(const std::string& event_name,
190 const WatchedPagesRecipient& watched_pages_recipient,
191 const std::vector<std::string>& css_selectors);
192
187 void UpdateActiveExtensions(); 193 void UpdateActiveExtensions();
188 194
189 // Sets up the host permissions for |extension|. 195 // Sets up the host permissions for |extension|.
190 void InitOriginPermissions(const Extension* extension); 196 void InitOriginPermissions(const Extension* extension);
191 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason, 197 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason,
192 const Extension* extension, 198 const Extension* extension,
193 const URLPatternSet& origins); 199 const URLPatternSet& origins);
194 200
195 // Enable custom element whitelist in Apps. 201 // Enable custom element whitelist in Apps.
196 void EnableCustomElementWhiteList(); 202 void EnableCustomElementWhiteList();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 ExtensionSet extensions_; 251 ExtensionSet extensions_;
246 252
247 // The IDs of extensions that failed to load, mapped to the error message 253 // The IDs of extensions that failed to load, mapped to the error message
248 // generated on failure. 254 // generated on failure.
249 std::map<std::string, std::string> extension_load_errors_; 255 std::map<std::string, std::string> extension_load_errors_;
250 256
251 // All the bindings contexts that are currently loaded for this renderer. 257 // All the bindings contexts that are currently loaded for this renderer.
252 // There is zero or one for each v8 context. 258 // There is zero or one for each v8 context.
253 ScriptContextSet script_context_set_; 259 ScriptContextSet script_context_set_;
254 260
255 scoped_ptr<ContentWatcher> content_watcher_; 261 // Content watchers, keyed by event_name.
262 ContentWatcherMap content_watchers_;
256 263
257 scoped_ptr<UserScriptSlave> user_script_slave_; 264 scoped_ptr<UserScriptSlave> user_script_slave_;
258 265
259 // Same as above, but on a longer timer and will run even if the process is 266 // Same as above, but on a longer timer and will run even if the process is
260 // not idle, to ensure that IdleHandle gets called eventually. 267 // not idle, to ensure that IdleHandle gets called eventually.
261 scoped_ptr<base::RepeatingTimer<content::RenderThread> > forced_idle_timer_; 268 scoped_ptr<base::RepeatingTimer<content::RenderThread> > forced_idle_timer_;
262 269
263 // All declared function names. 270 // All declared function names.
264 std::set<std::string> function_names_; 271 std::set<std::string> function_names_;
265 272
(...skipping 17 matching lines...) Expand all
283 290
284 // True once WebKit has been initialized (and it is therefore safe to poke). 291 // True once WebKit has been initialized (and it is therefore safe to poke).
285 bool is_webkit_initialized_; 292 bool is_webkit_initialized_;
286 293
287 DISALLOW_COPY_AND_ASSIGN(Dispatcher); 294 DISALLOW_COPY_AND_ASSIGN(Dispatcher);
288 }; 295 };
289 296
290 } // namespace extensions 297 } // namespace extensions
291 298
292 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ 299 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698