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

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

Issue 1854983002: [Extensions] Add more bindings access checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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 | « extensions/renderer/object_backed_native_handler.h ('k') | 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/object_backed_native_handler.h" 5 #include "extensions/renderer/object_backed_native_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "content/public/child/worker_thread.h" 11 #include "content/public/child/worker_thread.h"
12 #include "extensions/common/extension_api.h"
12 #include "extensions/renderer/console.h" 13 #include "extensions/renderer/console.h"
13 #include "extensions/renderer/module_system.h" 14 #include "extensions/renderer/module_system.h"
14 #include "extensions/renderer/script_context.h" 15 #include "extensions/renderer/script_context.h"
15 #include "extensions/renderer/script_context_set.h" 16 #include "extensions/renderer/script_context_set.h"
16 #include "extensions/renderer/v8_helpers.h" 17 #include "extensions/renderer/v8_helpers.h"
17 #include "v8/include/v8.h" 18 #include "v8/include/v8.h"
18 19
19 namespace extensions { 20 namespace extensions {
20 21
21 namespace { 22 namespace {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const std::string& name, 96 const std::string& name,
96 const std::string& feature_name, 97 const std::string& feature_name,
97 const HandlerFunction& handler_function) { 98 const HandlerFunction& handler_function) {
98 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 99 v8::Isolate* isolate = v8::Isolate::GetCurrent();
99 v8::HandleScope handle_scope(isolate); 100 v8::HandleScope handle_scope(isolate);
100 v8::Context::Scope context_scope(context_->v8_context()); 101 v8::Context::Scope context_scope(context_->v8_context());
101 102
102 v8::Local<v8::Object> data = v8::Object::New(isolate); 103 v8::Local<v8::Object> data = v8::Object::New(isolate);
103 SetPrivate(data, kHandlerFunction, 104 SetPrivate(data, kHandlerFunction,
104 v8::External::New(isolate, new HandlerFunction(handler_function))); 105 v8::External::New(isolate, new HandlerFunction(handler_function)));
106 DCHECK(feature_name.empty() ||
107 ExtensionAPI::GetSharedInstance()->GetFeatureDependency(feature_name))
108 << feature_name;
105 SetPrivate(data, kFeatureName, 109 SetPrivate(data, kFeatureName,
106 v8_helpers::ToV8StringUnsafe(isolate, feature_name)); 110 v8_helpers::ToV8StringUnsafe(isolate, feature_name));
107 v8::Local<v8::FunctionTemplate> function_template = 111 v8::Local<v8::FunctionTemplate> function_template =
108 v8::FunctionTemplate::New(isolate, Router, data); 112 v8::FunctionTemplate::New(isolate, Router, data);
109 v8::Local<v8::ObjectTemplate>::New(isolate, object_template_) 113 v8::Local<v8::ObjectTemplate>::New(isolate, object_template_)
110 ->Set(isolate, name.c_str(), function_template); 114 ->Set(isolate, name.c_str(), function_template);
111 router_data_.Append(data); 115 router_data_.Append(data);
112 } 116 }
113 117
114 v8::Isolate* ObjectBackedNativeHandler::GetIsolate() const { 118 v8::Isolate* ObjectBackedNativeHandler::GetIsolate() const {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 v8::Local<v8::Object> obj, 185 v8::Local<v8::Object> obj,
182 const char* key) { 186 const char* key) {
183 obj->DeletePrivate(context, 187 obj->DeletePrivate(context,
184 v8::Private::ForApi( 188 v8::Private::ForApi(
185 context->GetIsolate(), 189 context->GetIsolate(),
186 v8::String::NewFromUtf8(context->GetIsolate(), key))) 190 v8::String::NewFromUtf8(context->GetIsolate(), key)))
187 .FromJust(); 191 .FromJust();
188 } 192 }
189 193
190 } // namespace extensions 194 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/object_backed_native_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698