| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 v8::Local<v8::Object> global = v8_context()->Global(); | 212 v8::Local<v8::Object> global = v8_context()->Global(); |
| 213 if (web_frame_) { | 213 if (web_frame_) { |
| 214 web_frame_->requestExecuteV8Function(v8_context(), function, global, argc, | 214 web_frame_->requestExecuteV8Function(v8_context(), function, global, argc, |
| 215 argv, nullptr); | 215 argv, nullptr); |
| 216 } else { | 216 } else { |
| 217 // TODO(devlin): This probably isn't safe. | 217 // TODO(devlin): This probably isn't safe. |
| 218 function->Call(global, argc, argv); | 218 function->Call(global, argc, argv); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 v8::Local<v8::Value> ScriptContext::CallFunction( | |
| 223 const v8::Local<v8::Function>& function) const { | |
| 224 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 225 return CallFunction(function, 0, nullptr); | |
| 226 } | |
| 227 | |
| 228 Feature::Availability ScriptContext::GetAvailability( | 222 Feature::Availability ScriptContext::GetAvailability( |
| 229 const std::string& api_name) { | 223 const std::string& api_name) { |
| 230 DCHECK(thread_checker_.CalledOnValidThread()); | 224 DCHECK(thread_checker_.CalledOnValidThread()); |
| 231 if (base::StartsWith(api_name, "test", base::CompareCase::SENSITIVE)) { | 225 if (base::StartsWith(api_name, "test", base::CompareCase::SENSITIVE)) { |
| 232 bool allowed = base::CommandLine::ForCurrentProcess()-> | 226 bool allowed = base::CommandLine::ForCurrentProcess()-> |
| 233 HasSwitch(::switches::kTestType); | 227 HasSwitch(::switches::kTestType); |
| 234 Feature::AvailabilityResult result = | 228 Feature::AvailabilityResult result = |
| 235 allowed ? Feature::IS_AVAILABLE : Feature::MISSING_COMMAND_LINE_SWITCH; | 229 allowed ? Feature::IS_AVAILABLE : Feature::MISSING_COMMAND_LINE_SWITCH; |
| 236 return Feature::Availability(result, | 230 return Feature::Availability(result, |
| 237 allowed ? "" : "Only allowed in tests"); | 231 allowed ? "" : "Only allowed in tests"); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 v8::Local<v8::Value> argv[]) { | 512 v8::Local<v8::Value> argv[]) { |
| 519 return context_->CallFunction(function, argc, argv); | 513 return context_->CallFunction(function, argc, argv); |
| 520 } | 514 } |
| 521 | 515 |
| 522 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 516 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { |
| 523 v8::HandleScope handle_scope(context_->isolate()); | 517 v8::HandleScope handle_scope(context_->isolate()); |
| 524 return gin::PerContextData::From(context_->v8_context())->context_holder(); | 518 return gin::PerContextData::From(context_->v8_context())->context_holder(); |
| 525 } | 519 } |
| 526 | 520 |
| 527 } // namespace extensions | 521 } // namespace extensions |
| OLD | NEW |