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