| 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 372 | 372 | 
| 373   std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 373   std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 
| 374   v8::Local<v8::Value> argv[] = { | 374   v8::Local<v8::Value> argv[] = { | 
| 375       v8::Integer::New(isolate(), request_id), | 375       v8::Integer::New(isolate(), request_id), | 
| 376       v8::String::NewFromUtf8(isolate(), name.c_str()), | 376       v8::String::NewFromUtf8(isolate(), name.c_str()), | 
| 377       v8::Boolean::New(isolate(), success), | 377       v8::Boolean::New(isolate(), success), | 
| 378       converter->ToV8Value(&response, | 378       converter->ToV8Value(&response, | 
| 379                            v8::Local<v8::Context>::New(isolate(), v8_context_)), | 379                            v8::Local<v8::Context>::New(isolate(), v8_context_)), | 
| 380       v8::String::NewFromUtf8(isolate(), error.c_str())}; | 380       v8::String::NewFromUtf8(isolate(), error.c_str())}; | 
| 381 | 381 | 
| 382   v8::Local<v8::Value> retval = module_system()->CallModuleMethod( | 382   module_system()->CallModuleMethodSafe("sendRequest", "handleResponse", | 
| 383       "sendRequest", "handleResponse", arraysize(argv), argv); | 383                                         arraysize(argv), argv); | 
| 384 |  | 
| 385   // In debug, the js will validate the callback parameters and return a |  | 
| 386   // string if a validation error has occured. |  | 
| 387   DCHECK(retval.IsEmpty() || retval->IsUndefined()) |  | 
| 388       << *v8::String::Utf8Value(retval); |  | 
| 389 } | 384 } | 
| 390 | 385 | 
| 391 bool ScriptContext::HasAPIPermission(APIPermission::ID permission) const { | 386 bool ScriptContext::HasAPIPermission(APIPermission::ID permission) const { | 
| 392   DCHECK(thread_checker_.CalledOnValidThread()); | 387   DCHECK(thread_checker_.CalledOnValidThread()); | 
| 393   if (effective_extension_.get()) { | 388   if (effective_extension_.get()) { | 
| 394     return effective_extension_->permissions_data()->HasAPIPermission( | 389     return effective_extension_->permissions_data()->HasAPIPermission( | 
| 395         permission); | 390         permission); | 
| 396   } | 391   } | 
| 397   if (context_type() == Feature::WEB_PAGE_CONTEXT) { | 392   if (context_type() == Feature::WEB_PAGE_CONTEXT) { | 
| 398     // Only web page contexts may be granted content capabilities. Other | 393     // Only web page contexts may be granted content capabilities. Other | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 527     v8::Local<v8::Value> argv[]) { | 522     v8::Local<v8::Value> argv[]) { | 
| 528   return context_->CallFunction(function, argc, argv); | 523   return context_->CallFunction(function, argc, argv); | 
| 529 } | 524 } | 
| 530 | 525 | 
| 531 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 526 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 
| 532   v8::HandleScope handle_scope(context_->isolate()); | 527   v8::HandleScope handle_scope(context_->isolate()); | 
| 533   return gin::PerContextData::From(context_->v8_context())->context_holder(); | 528   return gin::PerContextData::From(context_->v8_context())->context_holder(); | 
| 534 } | 529 } | 
| 535 | 530 | 
| 536 }  // namespace extensions | 531 }  // namespace extensions | 
| OLD | NEW | 
|---|