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

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

Issue 2393513004: Convert app banners to use Mojo. (Closed)
Patch Set: Fix Win clang compile Created 4 years, 2 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 "bindings/core/v8/ScriptPromiseProperty.h"
10 #include "core/frame/LocalFrame.h"
10 #include "modules/EventModules.h" 11 #include "modules/EventModules.h"
11 #include "modules/app_banner/AppBannerPromptResult.h" 12 #include "modules/app_banner/AppBannerPromptResult.h"
12 #include "platform/heap/Handle.h" 13 #include "mojo/public/cpp/bindings/binding.h"
14 #include "public/platform/modules/app_banner/app_banner.mojom-blink.h"
13 15
14 namespace blink { 16 namespace blink {
15 17
16 class BeforeInstallPromptEvent; 18 class BeforeInstallPromptEvent;
17 class BeforeInstallPromptEventInit; 19 class BeforeInstallPromptEventInit;
18 class WebAppBannerClient;
19 20
20 using UserChoiceProperty = 21 using UserChoiceProperty =
21 ScriptPromiseProperty<Member<BeforeInstallPromptEvent>, 22 ScriptPromiseProperty<Member<BeforeInstallPromptEvent>,
22 Member<AppBannerPromptResult>, 23 Member<AppBannerPromptResult>,
23 ToV8UndefinedGenerator>; 24 ToV8UndefinedGenerator>;
24 25
25 class BeforeInstallPromptEvent final : public Event { 26 class BeforeInstallPromptEvent final : public Event,
27 public mojom::blink::AppBannerEvent {
26 DEFINE_WRAPPERTYPEINFO(); 28 DEFINE_WRAPPERTYPEINFO();
27 29
28 public: 30 public:
29 ~BeforeInstallPromptEvent() override; 31 ~BeforeInstallPromptEvent() override;
30 32
31 static BeforeInstallPromptEvent* create(const AtomicString& name, 33 static BeforeInstallPromptEvent* create(const AtomicString& name,
32 ExecutionContext* executionContext, 34 LocalFrame* frame,
33 const Vector<String>& platforms,
34 int requestId, 35 int requestId,
35 WebAppBannerClient* client) { 36 const Vector<String>& platforms) {
36 return new BeforeInstallPromptEvent(name, executionContext, platforms, 37 return new BeforeInstallPromptEvent(name, frame, requestId, platforms);
37 requestId, client);
38 } 38 }
39 39
40 static BeforeInstallPromptEvent* create( 40 static BeforeInstallPromptEvent* create(
41 const AtomicString& name, 41 const AtomicString& name,
42 const BeforeInstallPromptEventInit& init) { 42 const BeforeInstallPromptEventInit& init) {
43 return new BeforeInstallPromptEvent(name, init); 43 return new BeforeInstallPromptEvent(name, init);
44 } 44 }
45 45
46 Vector<String> platforms() const; 46 Vector<String> platforms() const;
47 ScriptPromise userChoice(ScriptState*); 47 ScriptPromise userChoice(ScriptState*);
48 ScriptPromise prompt(ScriptState*); 48 ScriptPromise prompt(ScriptState*);
49 49
50 const AtomicString& interfaceName() const override; 50 const AtomicString& interfaceName() const override;
51 void preventDefault() override; 51 void preventDefault() override;
52 52
53 DECLARE_VIRTUAL_TRACE(); 53 DECLARE_VIRTUAL_TRACE();
54 54
55 private: 55 private:
56 BeforeInstallPromptEvent(const AtomicString& name, 56 BeforeInstallPromptEvent(const AtomicString& name,
57 ExecutionContext*, 57 LocalFrame*,
58 const Vector<String>& platforms,
59 int requestId, 58 int requestId,
60 WebAppBannerClient*); 59 const Vector<String>& platforms);
61 BeforeInstallPromptEvent(const AtomicString& name, 60 BeforeInstallPromptEvent(const AtomicString& name,
62 const BeforeInstallPromptEventInit&); 61 const BeforeInstallPromptEventInit&);
63 62
63 // mojom::blink::AppBannerEvent methods:
64 void BannerAccepted(int requestId, const WTF::String& platform) override;
65 void BannerDismissed(int requestId) override;
66
67 mojom::blink::AppBannerServicePtr m_bannerService;
Sam McNally 2016/10/06 07:17:44 You'll need a prefinalizer to clean up the mojo co
dominickn 2016/10/06 22:58:12 Done.
68 mojo::Binding<mojom::blink::AppBannerEvent> m_binding;
69 int m_requestId;
64 Vector<String> m_platforms; 70 Vector<String> m_platforms;
65
66 int m_requestId;
67 WebAppBannerClient* m_client;
68 Member<UserChoiceProperty> m_userChoice; 71 Member<UserChoiceProperty> m_userChoice;
69 bool m_registered; 72 bool m_promptCalled;
70 }; 73 };
71 74
72 DEFINE_TYPE_CASTS(BeforeInstallPromptEvent, 75 DEFINE_TYPE_CASTS(BeforeInstallPromptEvent,
73 Event, 76 Event,
74 event, 77 event,
75 event->interfaceName() == 78 event->interfaceName() ==
76 EventNames::BeforeInstallPromptEvent, 79 EventNames::BeforeInstallPromptEvent,
77 event.interfaceName() == 80 event.interfaceName() ==
78 EventNames::BeforeInstallPromptEvent); 81 EventNames::BeforeInstallPromptEvent);
79 82
80 } // namespace blink 83 } // namespace blink
81 84
82 #endif // BeforeInstallPromptEvent_h 85 #endif // BeforeInstallPromptEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698