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

Unified Diff: extensions/renderer/native_extension_bindings_system.cc

Issue 2891123002: [Extensions Bindings] Handle updating context permissions (Closed)
Patch Set: jbroman's 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 10e7f08100cb61d275751d1c6180687e01605a70..b5226128fe67bc04f61abda1dcb72be96e5f2d05 100644
--- a/extensions/renderer/native_extension_bindings_system.cc
+++ b/extensions/renderer/native_extension_bindings_system.cc
@@ -195,11 +195,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
@@ -209,8 +212,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(),
@@ -353,6 +356,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,
« no previous file with comments | « extensions/renderer/declarative_event_unittest.cc ('k') | extensions/renderer/native_extension_bindings_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698