| 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_EXTENSION_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ |
| 6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
| 14 #include "base/timer.h" | 14 #include "base/timer.h" |
| 15 #include "content/public/renderer/render_process_observer.h" | 15 #include "content/public/renderer/render_process_observer.h" |
| 16 #include "chrome/common/extensions/extension_set.h" | 16 #include "chrome/common/extensions/extension_set.h" |
| 17 #include "chrome/renderer/extensions/chrome_v8_context_set.h" | 17 #include "chrome/renderer/extensions/chrome_v8_context_set.h" |
| 18 #include "chrome/renderer/resource_bundle_source_map.h" | |
| 19 #include "v8/include/v8.h" | 18 #include "v8/include/v8.h" |
| 20 | 19 |
| 21 class ModuleSystem; | |
| 22 class GURL; | 20 class GURL; |
| 23 class URLPattern; | 21 class URLPattern; |
| 24 class UserScriptSlave; | 22 class UserScriptSlave; |
| 25 struct ExtensionMsg_Loaded_Params; | 23 struct ExtensionMsg_Loaded_Params; |
| 26 | 24 |
| 27 namespace WebKit { | 25 namespace WebKit { |
| 28 class WebFrame; | 26 class WebFrame; |
| 29 } | 27 } |
| 30 | 28 |
| 31 namespace base { | 29 namespace base { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 50 bool is_extension_process() const { return is_extension_process_; } | 48 bool is_extension_process() const { return is_extension_process_; } |
| 51 const ExtensionSet* extensions() const { return &extensions_; } | 49 const ExtensionSet* extensions() const { return &extensions_; } |
| 52 const ChromeV8ContextSet& v8_context_set() const { | 50 const ChromeV8ContextSet& v8_context_set() const { |
| 53 return v8_context_set_; | 51 return v8_context_set_; |
| 54 } | 52 } |
| 55 UserScriptSlave* user_script_slave() { return user_script_slave_.get(); } | 53 UserScriptSlave* user_script_slave() { return user_script_slave_.get(); } |
| 56 | 54 |
| 57 bool IsApplicationActive(const std::string& extension_id) const; | 55 bool IsApplicationActive(const std::string& extension_id) const; |
| 58 bool IsExtensionActive(const std::string& extension_id) const; | 56 bool IsExtensionActive(const std::string& extension_id) const; |
| 59 | 57 |
| 60 // Whether or not we should set up custom bindings for this api. | |
| 61 bool AllowCustomAPI(WebKit::WebFrame* frame, | |
| 62 const std::string& custom_binding_api_name, | |
| 63 int world_id); | |
| 64 | |
| 65 // See WebKit::WebPermissionClient::allowScriptExtension | 58 // See WebKit::WebPermissionClient::allowScriptExtension |
| 66 // TODO(koz): Remove once WebKit no longer calls this. | 59 // TODO(koz): Remove once WebKit no longer calls this. |
| 67 bool AllowScriptExtension(WebKit::WebFrame* frame, | 60 bool AllowScriptExtension(WebKit::WebFrame* frame, |
| 68 const std::string& v8_extension_name, | 61 const std::string& v8_extension_name, |
| 69 int extension_group); | 62 int extension_group); |
| 70 | 63 |
| 71 // TODO(koz): Remove once WebKit no longer calls this. | |
| 72 bool AllowScriptExtension(WebKit::WebFrame* frame, | 64 bool AllowScriptExtension(WebKit::WebFrame* frame, |
| 73 const std::string& v8_extension_name, | 65 const std::string& v8_extension_name, |
| 74 int extension_group, | 66 int extension_group, |
| 75 int world_id); | 67 int world_id); |
| 76 | 68 |
| 77 void DidCreateScriptContext(WebKit::WebFrame* frame, | 69 void DidCreateScriptContext(WebKit::WebFrame* frame, |
| 78 v8::Handle<v8::Context> context, | 70 v8::Handle<v8::Context> context, |
| 79 int extension_group, | 71 int extension_group, |
| 80 int world_id); | 72 int world_id); |
| 81 void WillReleaseScriptContext(WebKit::WebFrame* frame, | 73 void WillReleaseScriptContext(WebKit::WebFrame* frame, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // Calls RenderThread's RegisterExtension and keeps tracks of which v8 | 130 // Calls RenderThread's RegisterExtension and keeps tracks of which v8 |
| 139 // extension is for Chrome Extensions only. | 131 // extension is for Chrome Extensions only. |
| 140 void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions); | 132 void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions); |
| 141 | 133 |
| 142 // Sets up the host permissions for |extension|. | 134 // Sets up the host permissions for |extension|. |
| 143 void InitOriginPermissions(const Extension* extension); | 135 void InitOriginPermissions(const Extension* extension); |
| 144 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason, | 136 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason, |
| 145 const Extension* extension, | 137 const Extension* extension, |
| 146 const URLPatternSet& origins); | 138 const URLPatternSet& origins); |
| 147 | 139 |
| 148 void RegisterNativeHandlers(ModuleSystem* module_system, | |
| 149 ChromeV8Context* context); | |
| 150 | |
| 151 // Inserts static source code into |source_map_|. | |
| 152 void PopulateSourceMap(); | |
| 153 | |
| 154 // Finds the extension ID for the current context. This is determined from | 140 // Finds the extension ID for the current context. This is determined from |
| 155 // |world_id| if it's non-zero, or the URL in |frame| if it is. | 141 // |world_id| if it's non-zero, or the URL in |frame| if it is. |
| 156 std::string GetExtensionID(WebKit::WebFrame* frame, int world_id); | 142 std::string GetExtensionID(WebKit::WebFrame* frame, int world_id); |
| 157 | 143 |
| 158 // True if this renderer is running extensions. | 144 // True if this renderer is running extensions. |
| 159 bool is_extension_process_; | 145 bool is_extension_process_; |
| 160 | 146 |
| 161 // Contains all loaded extensions. This is essentially the renderer | 147 // Contains all loaded extensions. This is essentially the renderer |
| 162 // counterpart to ExtensionService in the browser. It contains information | 148 // counterpart to ExtensionService in the browser. It contains information |
| 163 // about all extensions currently loaded by the browser. | 149 // about all extensions currently loaded by the browser. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 189 bool is_webkit_initialized_; | 175 bool is_webkit_initialized_; |
| 190 | 176 |
| 191 std::string test_extension_id_; | 177 std::string test_extension_id_; |
| 192 | 178 |
| 193 // Status of webrequest usage for known extensions. | 179 // Status of webrequest usage for known extensions. |
| 194 // TODO(mpcomplete): remove. http://crbug.com/100411 | 180 // TODO(mpcomplete): remove. http://crbug.com/100411 |
| 195 bool webrequest_adblock_; | 181 bool webrequest_adblock_; |
| 196 bool webrequest_adblock_plus_; | 182 bool webrequest_adblock_plus_; |
| 197 bool webrequest_other_; | 183 bool webrequest_other_; |
| 198 | 184 |
| 199 ResourceBundleSourceMap source_map_; | |
| 200 | |
| 201 DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher); | 185 DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher); |
| 202 }; | 186 }; |
| 203 | 187 |
| 204 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ | 188 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ |
| OLD | NEW |