| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef EXTENSIONS_RENDERER_DECLARATIVE_EVENT_H_ | |
| 6 #define EXTENSIONS_RENDERER_DECLARATIVE_EVENT_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "gin/wrappable.h" | |
| 11 #include "v8/include/v8.h" | |
| 12 | |
| 13 namespace gin { | |
| 14 class Arguments; | |
| 15 } | |
| 16 | |
| 17 namespace extensions { | |
| 18 class APIRequestHandler; | |
| 19 class APITypeReferenceMap; | |
| 20 | |
| 21 // A gin::Wrappable object for declarative events (i.e., events that support | |
| 22 // "rules"). Unlike regular events, these do not have associated listeners, and | |
| 23 // extensions register an action to perform when the event happens. | |
| 24 class DeclarativeEvent final : public gin::Wrappable<DeclarativeEvent> { | |
| 25 public: | |
| 26 DeclarativeEvent(const std::string& name, | |
| 27 APITypeReferenceMap* type_refs, | |
| 28 APIRequestHandler* request_handler, | |
| 29 const std::vector<std::string>& actions_list, | |
| 30 const std::vector<std::string>& conditions_list, | |
| 31 int webview_instance_id); | |
| 32 ~DeclarativeEvent() override; | |
| 33 | |
| 34 static gin::WrapperInfo kWrapperInfo; | |
| 35 | |
| 36 // gin::Wrappable: | |
| 37 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | |
| 38 v8::Isolate* isolate) final; | |
| 39 | |
| 40 private: | |
| 41 // Bound methods for the JS object. | |
| 42 void AddRules(gin::Arguments* arguments); | |
| 43 void RemoveRules(gin::Arguments* arguments); | |
| 44 void GetRules(gin::Arguments* arguments); | |
| 45 | |
| 46 void HandleFunction(const std::string& signature_name, | |
| 47 const std::string& request_name, | |
| 48 gin::Arguments* arguments); | |
| 49 | |
| 50 std::string event_name_; | |
| 51 | |
| 52 APITypeReferenceMap* type_refs_; | |
| 53 | |
| 54 APIRequestHandler* request_handler_; | |
| 55 | |
| 56 const int webview_instance_id_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(DeclarativeEvent); | |
| 59 }; | |
| 60 | |
| 61 } // namespace extensions | |
| 62 | |
| 63 #endif // EXTENSIONS_RENDERER_DECLARATIVE_EVENT_H_ | |
| OLD | NEW |