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

Unified Diff: extensions/renderer/api_binding.cc

Issue 2768093002: [Reland][Extensions Bindings] Add support for filtered events (Closed)
Patch Set: Fix Created 3 years, 9 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
« no previous file with comments | « extensions/renderer/BUILD.gn ('k') | extensions/renderer/api_binding_js_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_binding.cc
diff --git a/extensions/renderer/api_binding.cc b/extensions/renderer/api_binding.cc
index e16bef1472d75bd955cad24d18260e2a29192ae8..648e8a7279598b9654968c4214b3fecc153d9912 100644
--- a/extensions/renderer/api_binding.cc
+++ b/extensions/renderer/api_binding.cc
@@ -90,15 +90,19 @@ struct APIBinding::MethodData {
struct APIBinding::EventData {
EventData(std::string exposed_name,
std::string full_name,
+ bool supports_filters,
APIEventHandler* event_handler)
: exposed_name(std::move(exposed_name)),
full_name(std::move(full_name)),
+ supports_filters(supports_filters),
event_handler(event_handler) {}
// The name of the event on the API object (e.g. onCreated).
std::string exposed_name;
// The fully-specified name of the event (e.g. tabs.onCreated).
std::string full_name;
+ // Whether the event supports filters.
+ bool supports_filters;
// The associated event handler. This raw pointer is safe because the
// EventData is only accessed from the callbacks associated with the
// APIBinding, and both the APIBinding and APIEventHandler are owned by the
@@ -214,8 +218,12 @@ APIBinding::APIBinding(const std::string& api_name,
CHECK(event_dict->GetString("name", &name));
std::string full_name =
base::StringPrintf("%s.%s", api_name_.c_str(), name.c_str());
- events_.push_back(base::MakeUnique<EventData>(
- std::move(name), std::move(full_name), event_handler));
+ const base::ListValue* filters = nullptr;
+ bool supports_filters =
+ event_dict->GetList("filters", &filters) && !filters->empty();
+ events_.push_back(
+ base::MakeUnique<EventData>(std::move(name), std::move(full_name),
+ supports_filters, event_handler));
}
}
}
@@ -375,7 +383,7 @@ void APIBinding::GetEventObject(
auto* event_data =
static_cast<EventData*>(info.Data().As<v8::External>()->Value());
info.GetReturnValue().Set(event_data->event_handler->CreateEventInstance(
- event_data->full_name, context));
+ event_data->full_name, event_data->supports_filters, context));
}
void APIBinding::GetCustomPropertyObject(
« no previous file with comments | « extensions/renderer/BUILD.gn ('k') | extensions/renderer/api_binding_js_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698