| 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 | |
| 198 v8::Handle<v8::Object> global = v8_context()->Global(); | 191 v8::Handle<v8::Object> global = v8_context()->Global(); |
| 199 if (!web_frame_) | 192 if (!web_frame_) |
| 200 return handle_scope.Escape(function->Call(global, argc, argv)); | 193 return handle_scope.Escape(function->Call(global, argc, argv)); |
| 201 return handle_scope.Escape( | 194 return handle_scope.Escape( |
| 202 v8::Local<v8::Value>(web_frame_->callFunctionEvenIfScriptDisabled( | 195 v8::Local<v8::Value>(web_frame_->callFunctionEvenIfScriptDisabled( |
| 203 function, global, argc, call_args))); | 196 function, global, argc, argv))); |
| 204 } | 197 } |
| 205 | 198 |
| 206 Feature::Availability ScriptContext::GetAvailability( | 199 Feature::Availability ScriptContext::GetAvailability( |
| 207 const std::string& api_name) { | 200 const std::string& api_name) { |
| 208 // Hack: Hosted apps should have the availability of messaging APIs based on | 201 // Hack: Hosted apps should have the availability of messaging APIs based on |
| 209 // the URL of the page (which might have access depending on some extension | 202 // the URL of the page (which might have access depending on some extension |
| 210 // with externally_connectable), not whether the app has access to messaging | 203 // with externally_connectable), not whether the app has access to messaging |
| 211 // (which it won't). | 204 // (which it won't). |
| 212 const Extension* extension = extension_.get(); | 205 const Extension* extension = extension_.get(); |
| 213 if (extension && extension->is_hosted_app() && | 206 if (extension && extension->is_hosted_app() && |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 v8::Handle<v8::Value> argv[]) { | 350 v8::Handle<v8::Value> argv[]) { |
| 358 return context_->CallFunction(function, argc, argv); | 351 return context_->CallFunction(function, argc, argv); |
| 359 } | 352 } |
| 360 | 353 |
| 361 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 354 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { |
| 362 v8::HandleScope handle_scope(context_->isolate()); | 355 v8::HandleScope handle_scope(context_->isolate()); |
| 363 return gin::PerContextData::From(context_->v8_context())->context_holder(); | 356 return gin::PerContextData::From(context_->v8_context())->context_holder(); |
| 364 } | 357 } |
| 365 | 358 |
| 366 } // namespace extensions | 359 } // namespace extensions |
| OLD | NEW |