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

Side by Side Diff: chrome/renderer/extensions/extension_dispatcher.h

Issue 9460002: Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix koz bool thing Created 8 years, 9 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_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/common/extensions/feature.h"
18 #include "chrome/renderer/extensions/chrome_v8_context.h"
17 #include "chrome/renderer/extensions/chrome_v8_context_set.h" 19 #include "chrome/renderer/extensions/chrome_v8_context_set.h"
18 #include "chrome/renderer/resource_bundle_source_map.h" 20 #include "chrome/renderer/resource_bundle_source_map.h"
19 #include "v8/include/v8.h" 21 #include "v8/include/v8.h"
20 22
21 class ModuleSystem; 23 class ModuleSystem;
22 class GURL; 24 class GURL;
23 class URLPattern; 25 class URLPattern;
24 class UserScriptSlave; 26 class UserScriptSlave;
25 struct ExtensionMsg_Loaded_Params; 27 struct ExtensionMsg_Loaded_Params;
26 28
(...skipping 20 matching lines...) Expand all
47 return function_names_; 49 return function_names_;
48 } 50 }
49 51
50 bool is_extension_process() const { return is_extension_process_; } 52 bool is_extension_process() const { return is_extension_process_; }
51 const ExtensionSet* extensions() const { return &extensions_; } 53 const ExtensionSet* extensions() const { return &extensions_; }
52 const ChromeV8ContextSet& v8_context_set() const { 54 const ChromeV8ContextSet& v8_context_set() const {
53 return v8_context_set_; 55 return v8_context_set_;
54 } 56 }
55 UserScriptSlave* user_script_slave() { return user_script_slave_.get(); } 57 UserScriptSlave* user_script_slave() { return user_script_slave_.get(); }
56 58
57 bool IsApplicationActive(const std::string& extension_id) const;
58 bool IsExtensionActive(const std::string& extension_id) const; 59 bool IsExtensionActive(const std::string& extension_id) const;
59 60
60 // Whether or not we should set up custom bindings for this api. 61 // Finds the extension ID for the current context. This is determined from
Aaron Boodman 2012/03/06 01:17:21 s/current/specified/ Also, comment should say wha
not at google - send to devlin 2012/03/06 03:53:00 Done.
61 bool AllowCustomAPI(WebKit::WebFrame* frame, 62 // |world_id| if it's non-zero, or the URL in |frame| if it is.
62 const std::string& custom_binding_api_name, 63 std::string GetExtensionID(WebKit::WebFrame* frame, int world_id);
63 int world_id);
64 64
65 // See WebKit::WebPermissionClient::allowScriptExtension 65 // See WebKit::WebPermissionClient::allowScriptExtension
66 // TODO(koz): Remove once WebKit no longer calls this. 66 // TODO(koz): Remove once WebKit no longer calls this.
67 bool AllowScriptExtension(WebKit::WebFrame* frame, 67 bool AllowScriptExtension(WebKit::WebFrame* frame,
68 const std::string& v8_extension_name, 68 const std::string& v8_extension_name,
69 int extension_group); 69 int extension_group);
70 70
71 // TODO(koz): Remove once WebKit no longer calls this. 71 // TODO(koz): Remove once WebKit no longer calls this.
72 bool AllowScriptExtension(WebKit::WebFrame* frame, 72 bool AllowScriptExtension(WebKit::WebFrame* frame,
73 const std::string& v8_extension_name, 73 const std::string& v8_extension_name,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 const GURL& event_url); 110 const GURL& event_url);
111 void OnDeliverMessage(int target_port_id, const std::string& message); 111 void OnDeliverMessage(int target_port_id, const std::string& message);
112 void OnSetFunctionNames(const std::vector<std::string>& names); 112 void OnSetFunctionNames(const std::vector<std::string>& names);
113 void OnLoaded( 113 void OnLoaded(
114 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions); 114 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions);
115 void OnUnloaded(const std::string& id); 115 void OnUnloaded(const std::string& id);
116 void OnSetScriptingWhitelist( 116 void OnSetScriptingWhitelist(
117 const Extension::ScriptingWhitelist& extension_ids); 117 const Extension::ScriptingWhitelist& extension_ids);
118 void OnPageActionsUpdated(const std::string& extension_id, 118 void OnPageActionsUpdated(const std::string& extension_id,
119 const std::vector<std::string>& page_actions); 119 const std::vector<std::string>& page_actions);
120 void OnActivateApplication(const std::string& extension_id);
121 void OnActivateExtension(const std::string& extension_id); 120 void OnActivateExtension(const std::string& extension_id);
122 void OnUpdatePermissions(int reason_id, 121 void OnUpdatePermissions(int reason_id,
123 const std::string& extension_id, 122 const std::string& extension_id,
124 const ExtensionAPIPermissionSet& apis, 123 const ExtensionAPIPermissionSet& apis,
125 const URLPatternSet& explicit_hosts, 124 const URLPatternSet& explicit_hosts,
126 const URLPatternSet& scriptable_hosts); 125 const URLPatternSet& scriptable_hosts);
127 void OnUpdateUserScripts(base::SharedMemoryHandle table); 126 void OnUpdateUserScripts(base::SharedMemoryHandle table);
128 void OnUsingWebRequestAPI( 127 void OnUsingWebRequestAPI(
129 bool adblock, 128 bool adblock,
130 bool adblock_plus, 129 bool adblock_plus,
131 bool other_webrequest); 130 bool other_webrequest);
132 void OnShouldClose(const std::string& extension_id, int sequence_id); 131 void OnShouldClose(const std::string& extension_id, int sequence_id);
133 132
134 // Update the list of active extensions that will be reported when we crash. 133 // Update the list of active extensions that will be reported when we crash.
135 void UpdateActiveExtensions(); 134 void UpdateActiveExtensions();
136 135
137 // Calls RenderThread's RegisterExtension and keeps tracks of which v8 136 // Calls RenderThread's RegisterExtension and keeps tracks of which v8
138 // extension is for Chrome Extensions only. 137 // extension is for Chrome Extensions only.
139 void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions); 138 void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions);
140 139
141 // Sets up the host permissions for |extension|. 140 // Sets up the host permissions for |extension|.
142 void InitOriginPermissions(const Extension* extension); 141 void InitOriginPermissions(const Extension* extension);
143 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason, 142 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason,
144 const Extension* extension, 143 const Extension* extension,
145 const URLPatternSet& origins); 144 const URLPatternSet& origins);
146 145
147 void RegisterNativeHandlers(ModuleSystem* module_system, 146 void RegisterNativeHandlers(ModuleSystem* module_system,
148 ChromeV8Context* context, 147 ChromeV8Context* context);
149 bool is_bindings_allowed);
150 148
151 // Inserts static source code into |source_map_|. 149 // Inserts static source code into |source_map_|.
152 void PopulateSourceMap(); 150 void PopulateSourceMap();
153 151
154 // Finds the extension ID for the current context. This is determined from 152 // Returns the type of context that should be created, given an extension ID
Aaron Boodman 2012/03/06 01:17:21 Returns the Feature::Context type for a JavaScript
not at google - send to devlin 2012/03/06 03:53:00 Done.
155 // |world_id| if it's non-zero, or the URL in |frame| if it is. 153 // (if any), extension group (if any), and URL info (if any).
156 std::string GetExtensionID(WebKit::WebFrame* frame, int world_id); 154 extensions::Feature::Context ClassifyJavaScriptContext(
155 const std::string& extension_id,
156 int extension_group,
157 const ExtensionURLInfo& url_info);
157 158
158 // True if this renderer is running extensions. 159 // True if this renderer is running extensions.
159 bool is_extension_process_; 160 bool is_extension_process_;
160 161
161 // Contains all loaded extensions. This is essentially the renderer 162 // Contains all loaded extensions. This is essentially the renderer
162 // counterpart to ExtensionService in the browser. It contains information 163 // counterpart to ExtensionService in the browser. It contains information
163 // about all extensions currently loaded by the browser. 164 // about all extensions currently loaded by the browser.
164 ExtensionSet extensions_; 165 ExtensionSet extensions_;
165 166
166 // All the bindings contexts that are currently loaded for this renderer. 167 // All the bindings contexts that are currently loaded for this renderer.
167 // There is zero or one for each v8 context. 168 // There is zero or one for each v8 context.
168 ChromeV8ContextSet v8_context_set_; 169 ChromeV8ContextSet v8_context_set_;
169 170
170 scoped_ptr<UserScriptSlave> user_script_slave_; 171 scoped_ptr<UserScriptSlave> user_script_slave_;
171 172
172 // Same as above, but on a longer timer and will run even if the process is 173 // Same as above, but on a longer timer and will run even if the process is
173 // not idle, to ensure that IdleHandle gets called eventually. 174 // not idle, to ensure that IdleHandle gets called eventually.
174 base::RepeatingTimer<content::RenderThread> forced_idle_timer_; 175 base::RepeatingTimer<content::RenderThread> forced_idle_timer_;
175 176
176 // The v8 extensions which are restricted to extension-related contexts. 177 // The v8 extensions which are restricted to extension-related contexts.
177 std::set<std::string> restricted_v8_extensions_; 178 std::set<std::string> restricted_v8_extensions_;
178 179
179 // All declared function names. 180 // All declared function names.
180 std::set<std::string> function_names_; 181 std::set<std::string> function_names_;
181 182
182 // The extensions that are active in this process. 183 // The extensions and apps that are active in this process.
183 std::set<std::string> active_extension_ids_; 184 std::set<std::string> active_extension_ids_;
184 185
185 // The applications that are active in this process.
186 std::set<std::string> active_application_ids_;
187
188 // True once WebKit has been initialized (and it is therefore safe to poke). 186 // True once WebKit has been initialized (and it is therefore safe to poke).
189 bool is_webkit_initialized_; 187 bool is_webkit_initialized_;
190 188
191 std::string test_extension_id_; 189 std::string test_extension_id_;
192 190
193 // Status of webrequest usage for known extensions. 191 // Status of webrequest usage for known extensions.
194 // TODO(mpcomplete): remove. http://crbug.com/100411 192 // TODO(mpcomplete): remove. http://crbug.com/100411
195 bool webrequest_adblock_; 193 bool webrequest_adblock_;
196 bool webrequest_adblock_plus_; 194 bool webrequest_adblock_plus_;
197 bool webrequest_other_; 195 bool webrequest_other_;
198 196
199 ResourceBundleSourceMap source_map_; 197 ResourceBundleSourceMap source_map_;
200 198
201 DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher); 199 DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher);
202 }; 200 };
203 201
204 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ 202 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698