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 #include "extensions/renderer/script_context.h" | 5 #include "extensions/renderer/script_context.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 v8::Handle<v8::Value> argv[]) const { | 181 v8::Handle<v8::Value> argv[]) const { |
182 v8::EscapableHandleScope handle_scope(isolate()); | 182 v8::EscapableHandleScope handle_scope(isolate()); |
183 v8::Context::Scope scope(v8_context()); | 183 v8::Context::Scope scope(v8_context()); |
184 | 184 |
185 blink::WebScopedMicrotaskSuppression suppression; | 185 blink::WebScopedMicrotaskSuppression suppression; |
186 if (!is_valid_) { | 186 if (!is_valid_) { |
187 return handle_scope.Escape( | 187 return handle_scope.Escape( |
188 v8::Local<v8::Primitive>(v8::Undefined(isolate()))); | 188 v8::Local<v8::Primitive>(v8::Undefined(isolate()))); |
189 } | 189 } |
190 | 190 |
| 191 #ifdef WEB_FRAME_USES_V8_LOCAL |
| 192 v8::Local<v8::Value>* call_args = |
| 193 reinterpret_cast<v8::Local<v8::Value>*>(argv); |
| 194 #else |
| 195 v8::Handle<v8::Value>* call_args = argv; |
| 196 #endif |
| 197 |
191 v8::Handle<v8::Object> global = v8_context()->Global(); | 198 v8::Handle<v8::Object> global = v8_context()->Global(); |
192 if (!web_frame_) | 199 if (!web_frame_) |
193 return handle_scope.Escape(function->Call(global, argc, argv)); | 200 return handle_scope.Escape(function->Call(global, argc, argv)); |
194 return handle_scope.Escape( | 201 return handle_scope.Escape( |
195 v8::Local<v8::Value>(web_frame_->callFunctionEvenIfScriptDisabled( | 202 v8::Local<v8::Value>(web_frame_->callFunctionEvenIfScriptDisabled( |
196 function, global, argc, argv))); | 203 function, global, argc, call_args))); |
197 } | 204 } |
198 | 205 |
199 Feature::Availability ScriptContext::GetAvailability( | 206 Feature::Availability ScriptContext::GetAvailability( |
200 const std::string& api_name) { | 207 const std::string& api_name) { |
201 // Hack: Hosted apps should have the availability of messaging APIs based on | 208 // Hack: Hosted apps should have the availability of messaging APIs based on |
202 // the URL of the page (which might have access depending on some extension | 209 // the URL of the page (which might have access depending on some extension |
203 // with externally_connectable), not whether the app has access to messaging | 210 // with externally_connectable), not whether the app has access to messaging |
204 // (which it won't). | 211 // (which it won't). |
205 const Extension* extension = extension_.get(); | 212 const Extension* extension = extension_.get(); |
206 if (extension && extension->is_hosted_app() && | 213 if (extension && extension->is_hosted_app() && |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 v8::Handle<v8::Value> argv[]) { | 357 v8::Handle<v8::Value> argv[]) { |
351 return context_->CallFunction(function, argc, argv); | 358 return context_->CallFunction(function, argc, argv); |
352 } | 359 } |
353 | 360 |
354 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 361 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { |
355 v8::HandleScope handle_scope(context_->isolate()); | 362 v8::HandleScope handle_scope(context_->isolate()); |
356 return gin::PerContextData::From(context_->v8_context())->context_holder(); | 363 return gin::PerContextData::From(context_->v8_context())->context_holder(); |
357 } | 364 } |
358 | 365 |
359 } // namespace extensions | 366 } // namespace extensions |
OLD | NEW |