Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_RENDERER_EXTENSIONS_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ |
| 6 #define CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_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 "chrome/renderer/extensions/chrome_v8_context.h" | |
| 16 #include "chrome/renderer/extensions/chrome_v8_context_set.h" | |
| 17 #include "chrome/renderer/extensions/v8_schema_registry.h" | |
| 18 #include "chrome/renderer/resource_bundle_source_map.h" | 15 #include "chrome/renderer/resource_bundle_source_map.h" |
| 19 #include "content/public/renderer/render_process_observer.h" | 16 #include "content/public/renderer/render_process_observer.h" |
| 20 #include "extensions/common/event_filter.h" | 17 #include "extensions/common/event_filter.h" |
| 21 #include "extensions/common/extension_set.h" | 18 #include "extensions/common/extension_set.h" |
| 22 #include "extensions/common/extensions_client.h" | 19 #include "extensions/common/extensions_client.h" |
| 23 #include "extensions/common/features/feature.h" | 20 #include "extensions/common/features/feature.h" |
| 21 #include "extensions/renderer/script_context.h" | |
| 22 #include "extensions/renderer/script_context_set.h" | |
| 23 #include "extensions/renderer/v8_schema_registry.h" | |
| 24 #include "third_party/WebKit/public/platform/WebString.h" | 24 #include "third_party/WebKit/public/platform/WebString.h" |
| 25 #include "third_party/WebKit/public/platform/WebVector.h" | 25 #include "third_party/WebKit/public/platform/WebVector.h" |
| 26 #include "v8/include/v8.h" | 26 #include "v8/include/v8.h" |
| 27 | 27 |
| 28 class ChromeRenderViewTest; | 28 class ChromeRenderViewTest; |
| 29 class GURL; | 29 class GURL; |
| 30 class ModuleSystem; | 30 class ModuleSystem; |
| 31 class URLPattern; | 31 class URLPattern; |
| 32 struct ExtensionMsg_ExternalConnectionInfo; | 32 struct ExtensionMsg_ExternalConnectionInfo; |
| 33 struct ExtensionMsg_Loaded_Params; | 33 struct ExtensionMsg_Loaded_Params; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 63 public: | 63 public: |
| 64 Dispatcher(); | 64 Dispatcher(); |
| 65 virtual ~Dispatcher(); | 65 virtual ~Dispatcher(); |
| 66 | 66 |
| 67 const std::set<std::string>& function_names() const { | 67 const std::set<std::string>& function_names() const { |
| 68 return function_names_; | 68 return function_names_; |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool is_extension_process() const { return is_extension_process_; } | 71 bool is_extension_process() const { return is_extension_process_; } |
| 72 const ExtensionSet* extensions() const { return &extensions_; } | 72 const ExtensionSet* extensions() const { return &extensions_; } |
| 73 const ChromeV8ContextSet& v8_context_set() const { | 73 const ScriptContextSet& script_context_set() const { |
|
not at google - send to devlin
2014/04/17 15:11:10
looks like there are a number of places that only
| |
| 74 return v8_context_set_; | 74 return script_context_set_; |
| 75 } | 75 } |
| 76 UserScriptSlave* user_script_slave() { | 76 UserScriptSlave* user_script_slave() { |
| 77 return user_script_slave_.get(); | 77 return user_script_slave_.get(); |
| 78 } | 78 } |
| 79 V8SchemaRegistry* v8_schema_registry() { | 79 V8SchemaRegistry* v8_schema_registry() { |
| 80 return v8_schema_registry_.get(); | 80 return v8_schema_registry_.get(); |
| 81 } | 81 } |
| 82 ContentWatcher* content_watcher() { | 82 ContentWatcher* content_watcher() { |
| 83 return content_watcher_.get(); | 83 return content_watcher_.get(); |
| 84 } | 84 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 const URLPatternSet& origins); | 213 const URLPatternSet& origins); |
| 214 | 214 |
| 215 // Enable custom element whitelist in Apps. | 215 // Enable custom element whitelist in Apps. |
| 216 void EnableCustomElementWhiteList(); | 216 void EnableCustomElementWhiteList(); |
| 217 | 217 |
| 218 // Adds or removes bindings for every context belonging to |extension_id|, or | 218 // Adds or removes bindings for every context belonging to |extension_id|, or |
| 219 // or all contexts if |extension_id| is empty. | 219 // or all contexts if |extension_id| is empty. |
| 220 void AddOrRemoveBindings(const std::string& extension_id); | 220 void AddOrRemoveBindings(const std::string& extension_id); |
| 221 | 221 |
| 222 void RegisterNativeHandlers(ModuleSystem* module_system, | 222 void RegisterNativeHandlers(ModuleSystem* module_system, |
| 223 ChromeV8Context* context); | 223 ScriptContext* context); |
| 224 void AddOrRemoveBindingsForContext(ChromeV8Context* context); | 224 void AddOrRemoveBindingsForContext(ScriptContext* context); |
| 225 void RegisterBinding(const std::string& api_name, | 225 void RegisterBinding(const std::string& api_name, ScriptContext* context); |
| 226 ChromeV8Context* context); | |
| 227 v8::Handle<v8::Object> GetOrCreateBindObjectIfAvailable( | 226 v8::Handle<v8::Object> GetOrCreateBindObjectIfAvailable( |
| 228 const std::string& api_name, | 227 const std::string& api_name, |
| 229 std::string* bind_name, | 228 std::string* bind_name, |
| 230 ChromeV8Context* context); | 229 ScriptContext* context); |
| 231 | 230 |
| 232 // Inserts static source code into |source_map_|. | 231 // Inserts static source code into |source_map_|. |
| 233 void PopulateSourceMap(); | 232 void PopulateSourceMap(); |
| 234 | 233 |
| 235 // Inserts BindingInstallers into |lazy_bindings_map_|. | 234 // Inserts BindingInstallers into |lazy_bindings_map_|. |
| 236 void PopulateLazyBindingsMap(); | 235 void PopulateLazyBindingsMap(); |
| 237 | 236 |
| 238 // Sets up the bindings for the given api. | 237 // Sets up the bindings for the given api. |
| 239 void InstallBindings(ModuleSystem* module_system, | 238 void InstallBindings(ModuleSystem* module_system, |
| 240 v8::Handle<v8::Context> v8_context, | 239 v8::Handle<v8::Context> v8_context, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 265 // counterpart to ExtensionService in the browser. It contains information | 264 // counterpart to ExtensionService in the browser. It contains information |
| 266 // about all extensions currently loaded by the browser. | 265 // about all extensions currently loaded by the browser. |
| 267 ExtensionSet extensions_; | 266 ExtensionSet extensions_; |
| 268 | 267 |
| 269 // The IDs of extensions that failed to load, mapped to the error message | 268 // The IDs of extensions that failed to load, mapped to the error message |
| 270 // generated on failure. | 269 // generated on failure. |
| 271 std::map<std::string, std::string> extension_load_errors_; | 270 std::map<std::string, std::string> extension_load_errors_; |
| 272 | 271 |
| 273 // All the bindings contexts that are currently loaded for this renderer. | 272 // All the bindings contexts that are currently loaded for this renderer. |
| 274 // There is zero or one for each v8 context. | 273 // There is zero or one for each v8 context. |
| 275 ChromeV8ContextSet v8_context_set_; | 274 ScriptContextSet script_context_set_; |
| 276 | 275 |
| 277 scoped_ptr<UserScriptSlave> user_script_slave_; | 276 scoped_ptr<UserScriptSlave> user_script_slave_; |
| 278 | 277 |
| 279 scoped_ptr<ContentWatcher> content_watcher_; | 278 scoped_ptr<ContentWatcher> content_watcher_; |
| 280 | 279 |
| 281 // Same as above, but on a longer timer and will run even if the process is | 280 // Same as above, but on a longer timer and will run even if the process is |
| 282 // not idle, to ensure that IdleHandle gets called eventually. | 281 // not idle, to ensure that IdleHandle gets called eventually. |
| 283 scoped_ptr<base::RepeatingTimer<content::RenderThread> > forced_idle_timer_; | 282 scoped_ptr<base::RepeatingTimer<content::RenderThread> > forced_idle_timer_; |
| 284 | 283 |
| 285 // All declared function names. | 284 // All declared function names. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 315 | 314 |
| 316 // Mapping of port IDs to tabs. If there is no tab, the value would be -1. | 315 // Mapping of port IDs to tabs. If there is no tab, the value would be -1. |
| 317 std::map<int, int> port_to_tab_id_map_; | 316 std::map<int, int> port_to_tab_id_map_; |
| 318 | 317 |
| 319 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 318 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
| 320 }; | 319 }; |
| 321 | 320 |
| 322 } // namespace extensions | 321 } // namespace extensions |
| 323 | 322 |
| 324 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ | 323 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ |
| OLD | NEW |