| 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" | |
| 10 #include "modules/EventModules.h" | 9 #include "modules/EventModules.h" |
| 11 #include "modules/app_banner/AppBannerPromptResult.h" | |
| 12 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 13 | 11 |
| 14 namespace blink { | 12 namespace blink { |
| 15 | 13 |
| 16 class BeforeInstallPromptEvent; | |
| 17 class BeforeInstallPromptEventInit; | 14 class BeforeInstallPromptEventInit; |
| 18 class WebAppBannerClient; | 15 class WebAppBannerClient; |
| 19 | 16 |
| 20 using UserChoiceProperty = ScriptPromiseProperty<RawPtrWillBeMember<BeforeInstal
lPromptEvent>, Member<AppBannerPromptResult>, ToV8UndefinedGenerator>; | |
| 21 using PromptProperty = ScriptPromiseProperty<RawPtrWillBeMember<BeforeInstallPro
mptEvent>, ToV8UndefinedGenerator, Member<DOMException>>; | |
| 22 | |
| 23 class BeforeInstallPromptEvent final : public Event { | 17 class BeforeInstallPromptEvent final : public Event { |
| 24 DEFINE_WRAPPERTYPEINFO(); | 18 DEFINE_WRAPPERTYPEINFO(); |
| 25 public: | 19 public: |
| 26 ~BeforeInstallPromptEvent() override; | 20 ~BeforeInstallPromptEvent() override; |
| 27 | 21 |
| 28 // For EventModules.cpp | 22 // For EventModules.cpp |
| 29 static PassRefPtrWillBeRawPtr<BeforeInstallPromptEvent> create() | 23 static PassRefPtrWillBeRawPtr<BeforeInstallPromptEvent> create() |
| 30 { | 24 { |
| 31 return adoptRefWillBeNoop(new BeforeInstallPromptEvent()); | 25 return adoptRefWillBeNoop(new BeforeInstallPromptEvent()); |
| 32 } | 26 } |
| 33 | 27 |
| 34 static PassRefPtrWillBeRawPtr<BeforeInstallPromptEvent> create(const AtomicS
tring& name, ExecutionContext* executionContext, const Vector<String>& platforms
, int requestId, WebAppBannerClient* client) | 28 static PassRefPtrWillBeRawPtr<BeforeInstallPromptEvent> create(const AtomicS
tring& name, const Vector<String>& platforms, int requestId, WebAppBannerClient*
client) |
| 35 { | 29 { |
| 36 return adoptRefWillBeNoop(new BeforeInstallPromptEvent(name, executionCo
ntext, platforms, requestId, client)); | 30 return adoptRefWillBeNoop(new BeforeInstallPromptEvent(name, platforms,
requestId, client)); |
| 37 } | 31 } |
| 38 | 32 |
| 39 static PassRefPtrWillBeRawPtr<BeforeInstallPromptEvent> create(const AtomicS
tring& name, const BeforeInstallPromptEventInit& init) | 33 static PassRefPtrWillBeRawPtr<BeforeInstallPromptEvent> create(const AtomicS
tring& name, const BeforeInstallPromptEventInit& init) |
| 40 { | 34 { |
| 41 return adoptRefWillBeNoop(new BeforeInstallPromptEvent(name, init)); | 35 return adoptRefWillBeNoop(new BeforeInstallPromptEvent(name, init)); |
| 42 } | 36 } |
| 43 | 37 |
| 44 Vector<String> platforms() const; | 38 Vector<String> platforms() const; |
| 45 ScriptPromise userChoice(ScriptState*); | 39 ScriptPromise userChoice(ScriptState*); |
| 46 ScriptPromise prompt(ScriptState*); | |
| 47 | 40 |
| 48 const AtomicString& interfaceName() const override; | 41 const AtomicString& interfaceName() const override; |
| 49 | 42 |
| 50 UserChoiceProperty* userChoiceProperty() { return m_userChoice.get(); }; | 43 ScriptPromise prompt(ScriptState*); |
| 51 | |
| 52 DECLARE_VIRTUAL_TRACE(); | |
| 53 | 44 |
| 54 private: | 45 private: |
| 55 BeforeInstallPromptEvent(); | 46 BeforeInstallPromptEvent(); |
| 56 BeforeInstallPromptEvent(const AtomicString& name, ExecutionContext*, const
Vector<String>& platforms, int requestId, WebAppBannerClient*); | 47 BeforeInstallPromptEvent(const AtomicString& name, const Vector<String>& pla
tforms, int requestId, WebAppBannerClient*); |
| 57 BeforeInstallPromptEvent(const AtomicString& name, const BeforeInstallPrompt
EventInit&); | 48 BeforeInstallPromptEvent(const AtomicString& name, const BeforeInstallPrompt
EventInit&); |
| 58 | 49 |
| 59 Vector<String> m_platforms; | 50 Vector<String> m_platforms; |
| 51 ScriptPromise m_userChoice; |
| 60 | 52 |
| 61 int m_requestId; | 53 int m_requestId; |
| 62 WebAppBannerClient* m_client; | 54 WebAppBannerClient* m_client; |
| 63 PersistentWillBeMember<UserChoiceProperty> m_userChoice; | 55 bool m_redispatched; |
| 64 PersistentWillBeMember<PromptProperty> m_prompt; | |
| 65 }; | 56 }; |
| 66 | 57 |
| 67 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); |
| 68 | 59 |
| 69 } // namespace blink | 60 } // namespace blink |
| 70 | 61 |
| 71 #endif // BeforeInstallPromptEvent_h | 62 #endif // BeforeInstallPromptEvent_h |
| OLD | NEW |