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

Unified Diff: extensions/renderer/native_extension_bindings_system.cc

Issue 2891123002: [Extensions Bindings] Handle updating context permissions (Closed)
Patch Set: Add TODO Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/native_extension_bindings_system.cc
diff --git a/extensions/renderer/native_extension_bindings_system.cc b/extensions/renderer/native_extension_bindings_system.cc
index cd6ec5179ca4f6353f450a85bbba92a20b6aaeaa..3e98b9c9d8a442cf3e5683beac83ff7ec372ec98 100644
--- a/extensions/renderer/native_extension_bindings_system.cc
+++ b/extensions/renderer/native_extension_bindings_system.cc
@@ -184,11 +184,14 @@ const base::DictionaryValue& GetAPISchema(const std::string& api_name) {
return *schema;
}
-// Returns true if the method specified by |method_name| is available to the
-// given |context|.
-bool IsAPIMethodAvailable(ScriptContext* context,
- const std::string& method_name) {
- return context->GetAvailability(method_name).is_available();
+// Returns true if the feature specified by |name| is available to the given
+// |context|.
+bool IsAPIFeatureAvailable(v8::Local<v8::Context> context,
+ const std::string& name) {
+ ScriptContext* script_context =
+ ScriptContextSet::GetContextByV8Context(context);
+ DCHECK(script_context);
+ return script_context->GetAvailability(name).is_available();
}
// Instantiates the binding object for the given |name|. |name| must specify a
@@ -198,8 +201,8 @@ v8::Local<v8::Object> CreateRootBinding(v8::Local<v8::Context> context,
const std::string& name,
APIBindingsSystem* bindings_system) {
APIBindingHooks* hooks = nullptr;
- v8::Local<v8::Object> binding_object = bindings_system->CreateAPIInstance(
- name, context, base::Bind(&IsAPIMethodAvailable, script_context), &hooks);
+ v8::Local<v8::Object> binding_object =
+ bindings_system->CreateAPIInstance(name, context, &hooks);
gin::Handle<APIBindingBridge> bridge_handle = gin::CreateHandle(
context->GetIsolate(),
@@ -342,6 +345,7 @@ NativeExtensionBindingsSystem::NativeExtensionBindingsSystem(
base::Bind(&CallJsFunction),
base::Bind(&CallJsFunctionSync),
base::Bind(&GetAPISchema),
+ base::Bind(&IsAPIFeatureAvailable),
base::Bind(&NativeExtensionBindingsSystem::SendRequest,
base::Unretained(this)),
base::Bind(&NativeExtensionBindingsSystem::OnEventListenerChanged,

Powered by Google App Engine
This is Rietveld 408576698