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

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

Issue 2936083002: [Extensions] Remove unsafe variants of CallModuleMethod (Closed)
Patch Set: . Created 3 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
« no previous file with comments | « extensions/renderer/module_system.cc ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SCRIPT_CONTEXT_H_ 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const SafeBuiltins* safe_builtins() const { return &safe_builtins_; } 102 const SafeBuiltins* safe_builtins() const { return &safe_builtins_; }
103 103
104 // Returns the ID of the extension associated with this context, or empty 104 // Returns the ID of the extension associated with this context, or empty
105 // string if there is no such extension. 105 // string if there is no such extension.
106 const std::string& GetExtensionID() const; 106 const std::string& GetExtensionID() const;
107 107
108 // Returns the RenderFrame associated with this context. Can return NULL if 108 // Returns the RenderFrame associated with this context. Can return NULL if
109 // the context is in the process of being destroyed. 109 // the context is in the process of being destroyed.
110 content::RenderFrame* GetRenderFrame() const; 110 content::RenderFrame* GetRenderFrame() const;
111 111
112 // DEPRECATED.
113 v8::Local<v8::Value> CallFunction(const v8::Local<v8::Function>& function,
114 int argc,
115 v8::Local<v8::Value> argv[]) const;
116
117 // Safely calls the v8::Function, respecting the page load deferrer and 112 // Safely calls the v8::Function, respecting the page load deferrer and
118 // possibly executing asynchronously. 113 // possibly executing asynchronously.
119 // Doesn't catch exceptions; callers must do that if they want. 114 // Doesn't catch exceptions; callers must do that if they want.
120 // USE THESE METHODS RATHER THAN v8::Function::Call WHEREVER POSSIBLE. 115 // USE THESE METHODS RATHER THAN v8::Function::Call WHEREVER POSSIBLE.
121 // TODO(devlin): Remove the above variants in favor of this.
122 void SafeCallFunction(const v8::Local<v8::Function>& function, 116 void SafeCallFunction(const v8::Local<v8::Function>& function,
123 int argc, 117 int argc,
124 v8::Local<v8::Value> argv[]); 118 v8::Local<v8::Value> argv[]);
125 void SafeCallFunction( 119 void SafeCallFunction(
126 const v8::Local<v8::Function>& function, 120 const v8::Local<v8::Function>& function,
127 int argc, 121 int argc,
128 v8::Local<v8::Value> argv[], 122 v8::Local<v8::Value> argv[],
129 const ScriptInjectionCallback::CompleteCallback& callback); 123 const ScriptInjectionCallback::CompleteCallback& callback);
130 124
131 // Returns the availability of the API |api_name|. 125 // Returns the availability of the API |api_name|.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 213
220 // Runs |code|, labelling the script that gets created as |name| (the name is 214 // Runs |code|, labelling the script that gets created as |name| (the name is
221 // used in the devtools and stack traces). |exception_handler| will be called 215 // used in the devtools and stack traces). |exception_handler| will be called
222 // re-entrantly if an exception is thrown during the script's execution. 216 // re-entrantly if an exception is thrown during the script's execution.
223 v8::Local<v8::Value> RunScript( 217 v8::Local<v8::Value> RunScript(
224 v8::Local<v8::String> name, 218 v8::Local<v8::String> name,
225 v8::Local<v8::String> code, 219 v8::Local<v8::String> code,
226 const RunScriptExceptionHandler& exception_handler); 220 const RunScriptExceptionHandler& exception_handler);
227 221
228 private: 222 private:
223 // DEPRECATED.
224 v8::Local<v8::Value> CallFunction(const v8::Local<v8::Function>& function,
225 int argc,
226 v8::Local<v8::Value> argv[]) const;
227
229 class Runner; 228 class Runner;
230 229
231 // Whether this context is valid. 230 // Whether this context is valid.
232 bool is_valid_; 231 bool is_valid_;
233 232
234 // The v8 context the bindings are accessible to. 233 // The v8 context the bindings are accessible to.
235 v8::Global<v8::Context> v8_context_; 234 v8::Global<v8::Context> v8_context_;
236 235
237 // The WebLocalFrame associated with this context. This can be NULL because 236 // The WebLocalFrame associated with this context. This can be NULL because
238 // this object can outlive is destroyed asynchronously. 237 // this object can outlive is destroyed asynchronously.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 std::unique_ptr<Runner> runner_; 272 std::unique_ptr<Runner> runner_;
274 273
275 base::ThreadChecker thread_checker_; 274 base::ThreadChecker thread_checker_;
276 275
277 DISALLOW_COPY_AND_ASSIGN(ScriptContext); 276 DISALLOW_COPY_AND_ASSIGN(ScriptContext);
278 }; 277 };
279 278
280 } // namespace extensions 279 } // namespace extensions
281 280
282 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 281 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
OLDNEW
« no previous file with comments | « extensions/renderer/module_system.cc ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698