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

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: aa comments 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/renderer/extensions/chrome_v8_context.h"
17 #include "chrome/renderer/extensions/chrome_v8_context_set.h" 18 #include "chrome/renderer/extensions/chrome_v8_context_set.h"
18 #include "v8/include/v8.h" 19 #include "v8/include/v8.h"
19 20
20 class GURL; 21 class GURL;
21 class URLPattern; 22 class URLPattern;
22 class UserScriptSlave; 23 class UserScriptSlave;
23 struct ExtensionMsg_Loaded_Params; 24 struct ExtensionMsg_Loaded_Params;
24 25
25 namespace WebKit { 26 namespace WebKit {
26 class WebFrame; 27 class WebFrame;
(...skipping 18 matching lines...) Expand all
45 return function_names_; 46 return function_names_;
46 } 47 }
47 48
48 bool is_extension_process() const { return is_extension_process_; } 49 bool is_extension_process() const { return is_extension_process_; }
49 const ExtensionSet* extensions() const { return &extensions_; } 50 const ExtensionSet* extensions() const { return &extensions_; }
50 const ChromeV8ContextSet& v8_context_set() const { 51 const ChromeV8ContextSet& v8_context_set() const {
51 return v8_context_set_; 52 return v8_context_set_;
52 } 53 }
53 UserScriptSlave* user_script_slave() { return user_script_slave_.get(); } 54 UserScriptSlave* user_script_slave() { return user_script_slave_.get(); }
54 55
55 bool IsApplicationActive(const std::string& extension_id) const;
56 bool IsExtensionActive(const std::string& extension_id) const; 56 bool IsExtensionActive(const std::string& extension_id) const;
57 57
58 // See WebKit::WebPermissionClient::allowScriptExtension 58 // See WebKit::WebPermissionClient::allowScriptExtension
59 // TODO(koz): Remove once WebKit no longer calls this. 59 // TODO(koz): Remove once WebKit no longer calls this.
60 bool AllowScriptExtension(WebKit::WebFrame* frame, 60 bool AllowScriptExtension(WebKit::WebFrame* frame,
61 const std::string& v8_extension_name, 61 const std::string& v8_extension_name,
62 int extension_group); 62 int extension_group);
63 63
64 bool AllowScriptExtension(WebKit::WebFrame* frame, 64 bool AllowScriptExtension(WebKit::WebFrame* frame,
65 const std::string& v8_extension_name, 65 const std::string& v8_extension_name,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 const GURL& event_url); 105 const GURL& event_url);
106 void OnDeliverMessage(int target_port_id, const std::string& message); 106 void OnDeliverMessage(int target_port_id, const std::string& message);
107 void OnSetFunctionNames(const std::vector<std::string>& names); 107 void OnSetFunctionNames(const std::vector<std::string>& names);
108 void OnLoaded( 108 void OnLoaded(
109 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions); 109 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions);
110 void OnUnloaded(const std::string& id); 110 void OnUnloaded(const std::string& id);
111 void OnSetScriptingWhitelist( 111 void OnSetScriptingWhitelist(
112 const Extension::ScriptingWhitelist& extension_ids); 112 const Extension::ScriptingWhitelist& extension_ids);
113 void OnPageActionsUpdated(const std::string& extension_id, 113 void OnPageActionsUpdated(const std::string& extension_id,
114 const std::vector<std::string>& page_actions); 114 const std::vector<std::string>& page_actions);
115 void OnActivateApplication(const std::string& extension_id);
116 void OnActivateExtension(const std::string& extension_id); 115 void OnActivateExtension(const std::string& extension_id);
117 void OnUpdatePermissions(int reason_id, 116 void OnUpdatePermissions(int reason_id,
118 const std::string& extension_id, 117 const std::string& extension_id,
119 const ExtensionAPIPermissionSet& apis, 118 const ExtensionAPIPermissionSet& apis,
120 const URLPatternSet& explicit_hosts, 119 const URLPatternSet& explicit_hosts,
121 const URLPatternSet& scriptable_hosts); 120 const URLPatternSet& scriptable_hosts);
122 void OnUpdateUserScripts(base::SharedMemoryHandle table); 121 void OnUpdateUserScripts(base::SharedMemoryHandle table);
123 void OnUsingWebRequestAPI( 122 void OnUsingWebRequestAPI(
124 bool adblock, 123 bool adblock,
125 bool adblock_plus, 124 bool adblock_plus,
126 bool other_webrequest); 125 bool other_webrequest);
127 126
128 // Update the list of active extensions that will be reported when we crash. 127 // Update the list of active extensions that will be reported when we crash.
129 void UpdateActiveExtensions(); 128 void UpdateActiveExtensions();
130 129
131 // Calls RenderThread's RegisterExtension and keeps tracks of which v8 130 // Calls RenderThread's RegisterExtension and keeps tracks of which v8
132 // extension is for Chrome Extensions only. 131 // extension is for Chrome Extensions only.
133 void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions); 132 void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions);
134 133
135 // Sets up the host permissions for |extension|. 134 // Sets up the host permissions for |extension|.
136 void InitOriginPermissions(const Extension* extension); 135 void InitOriginPermissions(const Extension* extension);
137 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason, 136 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason,
138 const Extension* extension, 137 const Extension* extension,
139 const URLPatternSet& origins); 138 const URLPatternSet& origins);
140 139
141 // 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
142 // |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.
143 std::string GetExtensionID(WebKit::WebFrame* frame, int world_id); 142 std::string GetExtensionID(WebKit::WebFrame* frame, int world_id);
144 143
144 // Gets the type of context that would be created for a v8 extension group
145 // on a frame.
146 ChromeV8Context::ContextType GetContextType(int extension_group,
147 WebKit::WebFrame* frame);
148
145 // True if this renderer is running extensions. 149 // True if this renderer is running extensions.
146 bool is_extension_process_; 150 bool is_extension_process_;
147 151
148 // Contains all loaded extensions. This is essentially the renderer 152 // Contains all loaded extensions. This is essentially the renderer
149 // counterpart to ExtensionService in the browser. It contains information 153 // counterpart to ExtensionService in the browser. It contains information
150 // about all extensions currently loaded by the browser. 154 // about all extensions currently loaded by the browser.
151 ExtensionSet extensions_; 155 ExtensionSet extensions_;
152 156
153 // All the bindings contexts that are currently loaded for this renderer. 157 // All the bindings contexts that are currently loaded for this renderer.
154 // There is zero or one for each v8 context. 158 // There is zero or one for each v8 context.
155 ChromeV8ContextSet v8_context_set_; 159 ChromeV8ContextSet v8_context_set_;
156 160
157 scoped_ptr<UserScriptSlave> user_script_slave_; 161 scoped_ptr<UserScriptSlave> user_script_slave_;
158 162
159 // Same as above, but on a longer timer and will run even if the process is 163 // Same as above, but on a longer timer and will run even if the process is
160 // not idle, to ensure that IdleHandle gets called eventually. 164 // not idle, to ensure that IdleHandle gets called eventually.
161 base::RepeatingTimer<content::RenderThread> forced_idle_timer_; 165 base::RepeatingTimer<content::RenderThread> forced_idle_timer_;
162 166
163 // The v8 extensions which are restricted to extension-related contexts. 167 // The v8 extensions which are restricted to extension-related contexts.
164 std::set<std::string> restricted_v8_extensions_; 168 std::set<std::string> restricted_v8_extensions_;
165 169
166 // All declared function names. 170 // All declared function names.
167 std::set<std::string> function_names_; 171 std::set<std::string> function_names_;
168 172
169 // The extensions that are active in this process. 173 // The extensions and apps that are active in this process.
170 std::set<std::string> active_extension_ids_; 174 std::set<std::string> active_extension_ids_;
171 175
172 // The applications that are active in this process.
173 std::set<std::string> active_application_ids_;
174
175 // True once WebKit has been initialized (and it is therefore safe to poke). 176 // True once WebKit has been initialized (and it is therefore safe to poke).
176 bool is_webkit_initialized_; 177 bool is_webkit_initialized_;
177 178
178 std::string test_extension_id_; 179 std::string test_extension_id_;
179 180
180 // Status of webrequest usage for known extensions. 181 // Status of webrequest usage for known extensions.
181 // TODO(mpcomplete): remove. http://crbug.com/100411 182 // TODO(mpcomplete): remove. http://crbug.com/100411
182 bool webrequest_adblock_; 183 bool webrequest_adblock_;
183 bool webrequest_adblock_plus_; 184 bool webrequest_adblock_plus_;
184 bool webrequest_other_; 185 bool webrequest_other_;
185 186
186 DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher); 187 DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher);
187 }; 188 };
188 189
189 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ 190 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698