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

Unified Diff: extensions/renderer/api_binding_js_util.cc

Issue 2912883004: [Extensions Bindings] Don't allow `event` module with native bindings (Closed)
Patch Set: lazyboy's Created 3 years, 6 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/api_binding_js_util.h ('k') | extensions/renderer/declarative_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_binding_js_util.cc
diff --git a/extensions/renderer/api_binding_js_util.cc b/extensions/renderer/api_binding_js_util.cc
index 1f84df277dfb2bda2c6c386054afad6571cd099f..29c39bef26ef3a25b4460ed5b61037b271e8d90f 100644
--- a/extensions/renderer/api_binding_js_util.cc
+++ b/extensions/renderer/api_binding_js_util.cc
@@ -9,15 +9,17 @@
#include "extensions/renderer/api_request_handler.h"
#include "extensions/renderer/api_signature.h"
#include "extensions/renderer/api_type_reference_map.h"
+#include "extensions/renderer/declarative_event.h"
#include "gin/converter.h"
#include "gin/dictionary.h"
+#include "gin/handle.h"
#include "gin/object_template_builder.h"
namespace extensions {
gin::WrapperInfo APIBindingJSUtil::kWrapperInfo = {gin::kEmbedderNativeGin};
-APIBindingJSUtil::APIBindingJSUtil(const APITypeReferenceMap* type_refs,
+APIBindingJSUtil::APIBindingJSUtil(APITypeReferenceMap* type_refs,
APIRequestHandler* request_handler,
APIEventHandler* event_handler,
const binding::RunJSFunction& run_js)
@@ -35,6 +37,8 @@ gin::ObjectTemplateBuilder APIBindingJSUtil::GetObjectTemplateBuilder(
.SetMethod("registerEventArgumentMassager",
&APIBindingJSUtil::RegisterEventArgumentMassager)
.SetMethod("createCustomEvent", &APIBindingJSUtil::CreateCustomEvent)
+ .SetMethod("createCustomDeclarativeEvent",
+ &APIBindingJSUtil::CreateCustomDeclarativeEvent)
.SetMethod("invalidateEvent", &APIBindingJSUtil::InvalidateEvent)
.SetMethod("setLastError", &APIBindingJSUtil::SetLastError)
.SetMethod("clearLastError", &APIBindingJSUtil::ClearLastError)
@@ -137,6 +141,23 @@ void APIBindingJSUtil::CreateCustomEvent(gin::Arguments* arguments,
arguments->Return(event);
}
+void APIBindingJSUtil::CreateCustomDeclarativeEvent(
+ gin::Arguments* arguments,
+ const std::string& event_name,
+ const std::vector<std::string>& actions_list,
+ const std::vector<std::string>& conditions_list,
+ int webview_instance_id) {
+ v8::Isolate* isolate = arguments->isolate();
+ v8::HandleScope handle_scope(isolate);
+
+ gin::Handle<DeclarativeEvent> event = gin::CreateHandle(
+ isolate,
+ new DeclarativeEvent(event_name, type_refs_, request_handler_,
+ actions_list, conditions_list, webview_instance_id));
+
+ arguments->Return(event.ToV8());
+}
+
void APIBindingJSUtil::InvalidateEvent(gin::Arguments* arguments,
v8::Local<v8::Object> event) {
v8::Isolate* isolate = arguments->isolate();
« no previous file with comments | « extensions/renderer/api_binding_js_util.h ('k') | extensions/renderer/declarative_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698