| 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 v8::Local<v8::Value> ScriptContext::CallFunction( | 204 v8::Local<v8::Value> ScriptContext::CallFunction( |
| 205 const v8::Local<v8::Function>& function) const { | 205 const v8::Local<v8::Function>& function) const { |
| 206 DCHECK(thread_checker_.CalledOnValidThread()); | 206 DCHECK(thread_checker_.CalledOnValidThread()); |
| 207 return CallFunction(function, 0, nullptr); | 207 return CallFunction(function, 0, nullptr); |
| 208 } | 208 } |
| 209 | 209 |
| 210 Feature::Availability ScriptContext::GetAvailability( | 210 Feature::Availability ScriptContext::GetAvailability( |
| 211 const std::string& api_name) { | 211 const std::string& api_name) { |
| 212 DCHECK(thread_checker_.CalledOnValidThread()); | 212 DCHECK(thread_checker_.CalledOnValidThread()); |
| 213 if (api_name == "test") { | 213 if (base::StartsWith(api_name, "test", base::CompareCase::SENSITIVE)) { |
| 214 bool allowed = base::CommandLine::ForCurrentProcess()-> | 214 bool allowed = base::CommandLine::ForCurrentProcess()-> |
| 215 HasSwitch(::switches::kTestType); | 215 HasSwitch(::switches::kTestType); |
| 216 Feature::AvailabilityResult result = | 216 Feature::AvailabilityResult result = |
| 217 allowed ? Feature::IS_AVAILABLE : Feature::MISSING_COMMAND_LINE_SWITCH; | 217 allowed ? Feature::IS_AVAILABLE : Feature::MISSING_COMMAND_LINE_SWITCH; |
| 218 return Feature::Availability(result, | 218 return Feature::Availability(result, |
| 219 allowed ? "" : "Only allowed in tests"); | 219 allowed ? "" : "Only allowed in tests"); |
| 220 } | 220 } |
| 221 // Hack: Hosted apps should have the availability of messaging APIs based on | 221 // Hack: Hosted apps should have the availability of messaging APIs based on |
| 222 // the URL of the page (which might have access depending on some extension | 222 // the URL of the page (which might have access depending on some extension |
| 223 // with externally_connectable), not whether the app has access to messaging | 223 // with externally_connectable), not whether the app has access to messaging |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 v8::Local<v8::Value> argv[]) { | 480 v8::Local<v8::Value> argv[]) { |
| 481 return context_->CallFunction(function, argc, argv); | 481 return context_->CallFunction(function, argc, argv); |
| 482 } | 482 } |
| 483 | 483 |
| 484 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 484 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { |
| 485 v8::HandleScope handle_scope(context_->isolate()); | 485 v8::HandleScope handle_scope(context_->isolate()); |
| 486 return gin::PerContextData::From(context_->v8_context())->context_holder(); | 486 return gin::PerContextData::From(context_->v8_context())->context_holder(); |
| 487 } | 487 } |
| 488 | 488 |
| 489 } // namespace extensions | 489 } // namespace extensions |
| OLD | NEW |