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

Side by Side Diff: Source/modules/app_banner/BeforeInstallPromptEvent.h

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

Powered by Google App Engine
This is Rietveld 408576698