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

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

Issue 1866103002: [Extensions] Expand bindings access checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master 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
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"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // don't inject many bindings into worker threads. 67 // don't inject many bindings into worker threads.
68 // TODO(devlin): Figure out a way around this. 68 // TODO(devlin): Figure out a way around this.
69 if (content::WorkerThread::GetCurrentId() == 0) { 69 if (content::WorkerThread::GetCurrentId() == 0) {
70 ScriptContext* script_context = 70 ScriptContext* script_context =
71 ScriptContextSet::GetContextByV8Context(context); 71 ScriptContextSet::GetContextByV8Context(context);
72 v8::Local<v8::String> feature_name_string = 72 v8::Local<v8::String> feature_name_string =
73 feature_name_value->ToString(context).ToLocalChecked(); 73 feature_name_value->ToString(context).ToLocalChecked();
74 std::string feature_name = *v8::String::Utf8Value(feature_name_string); 74 std::string feature_name = *v8::String::Utf8Value(feature_name_string);
75 // TODO(devlin): Eventually, we should fail if either script_context is null 75 // TODO(devlin): Eventually, we should fail if either script_context is null
76 // or feature_name is empty. 76 // or feature_name is empty.
77 if (script_context && 77 if (script_context && !feature_name.empty()) {
78 !feature_name.empty() && 78 Feature::Availability availability =
79 !script_context->GetAvailability(feature_name).is_available()) { 79 script_context->GetAvailability(feature_name);
80 return; 80 if (!availability.is_available()) {
81 DVLOG(1) << feature_name
82 << " is not available: " << availability.message();
83 return;
84 }
81 } 85 }
82 } 86 }
83 // This CHECK is *important*. Otherwise, we'll go around happily executing 87 // This CHECK is *important*. Otherwise, we'll go around happily executing
84 // something random. See crbug.com/548273. 88 // something random. See crbug.com/548273.
85 CHECK(handler_function_value->IsExternal()); 89 CHECK(handler_function_value->IsExternal());
86 static_cast<HandlerFunction*>( 90 static_cast<HandlerFunction*>(
87 handler_function_value.As<v8::External>()->Value())->Run(args); 91 handler_function_value.As<v8::External>()->Value())->Run(args);
88 92
89 // Verify that the return value, if any, is accessible by the context. 93 // Verify that the return value, if any, is accessible by the context.
90 v8::ReturnValue<v8::Value> ret = args.GetReturnValue(); 94 v8::ReturnValue<v8::Value> ret = args.GetReturnValue();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 v8::Local<v8::Object> obj, 217 v8::Local<v8::Object> obj,
214 const char* key) { 218 const char* key) {
215 obj->DeletePrivate(context, 219 obj->DeletePrivate(context,
216 v8::Private::ForApi( 220 v8::Private::ForApi(
217 context->GetIsolate(), 221 context->GetIsolate(),
218 v8::String::NewFromUtf8(context->GetIsolate(), key))) 222 v8::String::NewFromUtf8(context->GetIsolate(), key)))
219 .FromJust(); 223 .FromJust();
220 } 224 }
221 225
222 } // namespace extensions 226 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/lazy_background_page_native_handler.cc ('k') | extensions/renderer/print_native_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698