Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(860)

Side by Side Diff: extensions/renderer/script_context.cc

Issue 2932913004: [Extensions] Use CallModuleMethodSafe() in ScriptContext (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698