OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BeforeInstallPromptEvent_h | 5 #ifndef BeforeInstallPromptEvent_h |
6 #define BeforeInstallPromptEvent_h | 6 #define BeforeInstallPromptEvent_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseProperty.h" | 9 #include "bindings/core/v8/ScriptPromiseProperty.h" |
10 #include "modules/EventModules.h" | 10 #include "modules/EventModules.h" |
11 #include "modules/app_banner/AppBannerPromptResult.h" | 11 #include "modules/app_banner/AppBannerPromptResult.h" |
12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 class BeforeInstallPromptEvent; | 16 class BeforeInstallPromptEvent; |
17 class BeforeInstallPromptEventInit; | 17 class BeforeInstallPromptEventInit; |
18 class WebAppBannerClient; | 18 class WebAppBannerClient; |
19 | 19 |
20 using UserChoiceProperty = ScriptPromiseProperty<Member<BeforeInstallPromptEvent
>, Member<AppBannerPromptResult>, ToV8UndefinedGenerator>; | 20 using UserChoiceProperty = ScriptPromiseProperty<Member<BeforeInstallPromptEvent
>, Member<AppBannerPromptResult>, ToV8UndefinedGenerator>; |
21 | 21 |
22 class BeforeInstallPromptEvent final : public Event { | 22 class BeforeInstallPromptEvent final : public Event { |
23 DEFINE_WRAPPERTYPEINFO(); | 23 DEFINE_WRAPPERTYPEINFO(); |
24 public: | 24 public: |
25 ~BeforeInstallPromptEvent() override; | 25 ~BeforeInstallPromptEvent() override; |
26 | 26 |
27 // For EventModules.cpp | |
28 static BeforeInstallPromptEvent* create() | |
29 { | |
30 return new BeforeInstallPromptEvent(); | |
31 } | |
32 | |
33 static BeforeInstallPromptEvent* create(const AtomicString& name, ExecutionC
ontext* executionContext, const Vector<String>& platforms, int requestId, WebApp
BannerClient* client) | 27 static BeforeInstallPromptEvent* create(const AtomicString& name, ExecutionC
ontext* executionContext, const Vector<String>& platforms, int requestId, WebApp
BannerClient* client) |
34 { | 28 { |
35 return new BeforeInstallPromptEvent(name, executionContext, platforms, r
equestId, client); | 29 return new BeforeInstallPromptEvent(name, executionContext, platforms, r
equestId, client); |
36 } | 30 } |
37 | 31 |
38 static BeforeInstallPromptEvent* create(const AtomicString& name, const Befo
reInstallPromptEventInit& init) | 32 static BeforeInstallPromptEvent* create(const AtomicString& name, const Befo
reInstallPromptEventInit& init) |
39 { | 33 { |
40 return new BeforeInstallPromptEvent(name, init); | 34 return new BeforeInstallPromptEvent(name, init); |
41 } | 35 } |
42 | 36 |
43 Vector<String> platforms() const; | 37 Vector<String> platforms() const; |
44 ScriptPromise userChoice(ScriptState*); | 38 ScriptPromise userChoice(ScriptState*); |
45 ScriptPromise prompt(ScriptState*); | 39 ScriptPromise prompt(ScriptState*); |
46 | 40 |
47 const AtomicString& interfaceName() const override; | 41 const AtomicString& interfaceName() const override; |
48 void preventDefault() override; | 42 void preventDefault() override; |
49 | 43 |
50 DECLARE_VIRTUAL_TRACE(); | 44 DECLARE_VIRTUAL_TRACE(); |
51 | 45 |
52 private: | 46 private: |
53 BeforeInstallPromptEvent(); | |
54 BeforeInstallPromptEvent(const AtomicString& name, ExecutionContext*, const
Vector<String>& platforms, int requestId, WebAppBannerClient*); | 47 BeforeInstallPromptEvent(const AtomicString& name, ExecutionContext*, const
Vector<String>& platforms, int requestId, WebAppBannerClient*); |
55 BeforeInstallPromptEvent(const AtomicString& name, const BeforeInstallPrompt
EventInit&); | 48 BeforeInstallPromptEvent(const AtomicString& name, const BeforeInstallPrompt
EventInit&); |
56 | 49 |
57 Vector<String> m_platforms; | 50 Vector<String> m_platforms; |
58 | 51 |
59 int m_requestId; | 52 int m_requestId; |
60 WebAppBannerClient* m_client; | 53 WebAppBannerClient* m_client; |
61 Member<UserChoiceProperty> m_userChoice; | 54 Member<UserChoiceProperty> m_userChoice; |
62 bool m_registered; | 55 bool m_registered; |
63 }; | 56 }; |
64 | 57 |
65 DEFINE_TYPE_CASTS(BeforeInstallPromptEvent, Event, event, event->interfaceName()
== EventNames::BeforeInstallPromptEvent, event.interfaceName() == EventNames::B
eforeInstallPromptEvent); | 58 DEFINE_TYPE_CASTS(BeforeInstallPromptEvent, Event, event, event->interfaceName()
== EventNames::BeforeInstallPromptEvent, event.interfaceName() == EventNames::B
eforeInstallPromptEvent); |
66 | 59 |
67 } // namespace blink | 60 } // namespace blink |
68 | 61 |
69 #endif // BeforeInstallPromptEvent_h | 62 #endif // BeforeInstallPromptEvent_h |
OLD | NEW |