OLD | NEW |
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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "extensions/common/features/feature.h" | 17 #include "extensions/common/features/feature.h" |
18 #include "extensions/common/permissions/api_permission_set.h" | 18 #include "extensions/common/permissions/api_permission_set.h" |
19 #include "extensions/renderer/module_system.h" | 19 #include "extensions/renderer/module_system.h" |
20 #include "extensions/renderer/request_sender.h" | 20 #include "extensions/renderer/request_sender.h" |
21 #include "extensions/renderer/safe_builtins.h" | 21 #include "extensions/renderer/safe_builtins.h" |
| 22 #include "extensions/renderer/script_injection_callback.h" |
22 #include "gin/runner.h" | 23 #include "gin/runner.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 #include "v8/include/v8.h" | 25 #include "v8/include/v8.h" |
25 | 26 |
26 namespace blink { | 27 namespace blink { |
27 class WebFrame; | 28 class WebFrame; |
28 class WebLocalFrame; | 29 class WebLocalFrame; |
29 } | 30 } |
30 | 31 |
31 namespace content { | 32 namespace content { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 content::RenderFrame* GetRenderFrame() const; | 111 content::RenderFrame* GetRenderFrame() const; |
111 | 112 |
112 // DEPRECATED. | 113 // DEPRECATED. |
113 v8::Local<v8::Value> CallFunction(const v8::Local<v8::Function>& function, | 114 v8::Local<v8::Value> CallFunction(const v8::Local<v8::Function>& function, |
114 int argc, | 115 int argc, |
115 v8::Local<v8::Value> argv[]) const; | 116 v8::Local<v8::Value> argv[]) const; |
116 | 117 |
117 // Safely calls the v8::Function, respecting the page load deferrer and | 118 // Safely calls the v8::Function, respecting the page load deferrer and |
118 // possibly executing asynchronously. | 119 // possibly executing asynchronously. |
119 // Doesn't catch exceptions; callers must do that if they want. | 120 // Doesn't catch exceptions; callers must do that if they want. |
120 // USE THIS METHOD RATHER THAN v8::Function::Call WHEREVER POSSIBLE. | 121 // USE THESE METHODS RATHER THAN v8::Function::Call WHEREVER POSSIBLE. |
121 // TODO(devlin): Remove the above variants in favor of this. | 122 // TODO(devlin): Remove the above variants in favor of this. |
122 void SafeCallFunction(const v8::Local<v8::Function>& function, | 123 void SafeCallFunction(const v8::Local<v8::Function>& function, |
123 int argc, | 124 int argc, |
124 v8::Local<v8::Value> argv[]); | 125 v8::Local<v8::Value> argv[]); |
| 126 void SafeCallFunction( |
| 127 const v8::Local<v8::Function>& function, |
| 128 int argc, |
| 129 v8::Local<v8::Value> argv[], |
| 130 const ScriptInjectionCallback::CompleteCallback& callback); |
125 | 131 |
126 void DispatchEvent(const char* event_name, v8::Local<v8::Array> args) const; | 132 void DispatchEvent(const char* event_name, v8::Local<v8::Array> args) const; |
127 | 133 |
128 // Returns the availability of the API |api_name|. | 134 // Returns the availability of the API |api_name|. |
129 Feature::Availability GetAvailability(const std::string& api_name); | 135 Feature::Availability GetAvailability(const std::string& api_name); |
130 // Returns the availability of the API |api_name|. | 136 // Returns the availability of the API |api_name|. |
131 // |check_alias| Whether API that has an alias that is available should be | 137 // |check_alias| Whether API that has an alias that is available should be |
132 // considered available (even if the API itself is not available). | 138 // considered available (even if the API itself is not available). |
133 Feature::Availability GetAvailability(const std::string& api_name, | 139 Feature::Availability GetAvailability(const std::string& api_name, |
134 CheckAliasStatus check_alias); | 140 CheckAliasStatus check_alias); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 std::unique_ptr<Runner> runner_; | 276 std::unique_ptr<Runner> runner_; |
271 | 277 |
272 base::ThreadChecker thread_checker_; | 278 base::ThreadChecker thread_checker_; |
273 | 279 |
274 DISALLOW_COPY_AND_ASSIGN(ScriptContext); | 280 DISALLOW_COPY_AND_ASSIGN(ScriptContext); |
275 }; | 281 }; |
276 | 282 |
277 } // namespace extensions | 283 } // namespace extensions |
278 | 284 |
279 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ | 285 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
OLD | NEW |