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

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

Issue 2393513004: Convert app banners to use Mojo. (Closed)
Patch Set: Rebase 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 "mojo/public/cpp/system/message_pipe.h"
15 #include "public/platform/modules/app_banner/app_banner.mojom-blink.h"
16 #include <utility>
13 17
14 namespace blink { 18 namespace blink {
15 19
16 class BeforeInstallPromptEvent; 20 class BeforeInstallPromptEvent;
17 class BeforeInstallPromptEventInit; 21 class BeforeInstallPromptEventInit;
18 class WebAppBannerClient;
19 22
20 using UserChoiceProperty = 23 using UserChoiceProperty =
21 ScriptPromiseProperty<Member<BeforeInstallPromptEvent>, 24 ScriptPromiseProperty<Member<BeforeInstallPromptEvent>,
22 Member<AppBannerPromptResult>, 25 Member<AppBannerPromptResult>,
23 ToV8UndefinedGenerator>; 26 ToV8UndefinedGenerator>;
24 27
25 class BeforeInstallPromptEvent final : public Event { 28 class BeforeInstallPromptEvent final : public Event,
29 public mojom::blink::AppBannerEvent {
26 DEFINE_WRAPPERTYPEINFO(); 30 DEFINE_WRAPPERTYPEINFO();
31 USING_PRE_FINALIZER(BeforeInstallPromptEvent, dispose);
haraken 2016/10/07 07:09:40 The reason we need to add the pre-finalizer is tha
dominickn 2016/10/13 00:18:15 I believe this has landed now.
dominickn 2016/10/17 05:38:45 Follow up: we have both an InterfacePtr and a bind
27 32
28 public: 33 public:
29 ~BeforeInstallPromptEvent() override; 34 ~BeforeInstallPromptEvent() override;
30 35
31 static BeforeInstallPromptEvent* create(const AtomicString& name, 36 static BeforeInstallPromptEvent* create(
32 ExecutionContext* executionContext, 37 const AtomicString& name,
33 const Vector<String>& platforms, 38 LocalFrame* frame,
dcheng 2016/10/07 07:03:16 Nit: LocalFrame, as |frame| can't be null here.
dominickn 2016/10/13 00:18:15 Do you mean LocalFrame&?
34 int requestId, 39 mojo::ScopedMessagePipeHandle serviceHandle,
35 WebAppBannerClient* client) { 40 mojo::ScopedMessagePipeHandle eventHandle,
36 return new BeforeInstallPromptEvent(name, executionContext, platforms, 41 const Vector<String>& platforms) {
37 requestId, client); 42 return new BeforeInstallPromptEvent(name, frame, std::move(serviceHandle),
43 std::move(eventHandle), platforms);
38 } 44 }
39 45
40 static BeforeInstallPromptEvent* create( 46 static BeforeInstallPromptEvent* create(
41 const AtomicString& name, 47 const AtomicString& name,
42 const BeforeInstallPromptEventInit& init) { 48 const BeforeInstallPromptEventInit& init) {
43 return new BeforeInstallPromptEvent(name, init); 49 return new BeforeInstallPromptEvent(name, init);
44 } 50 }
45 51
52 void dispose();
53
46 Vector<String> platforms() const; 54 Vector<String> platforms() const;
47 ScriptPromise userChoice(ScriptState*); 55 ScriptPromise userChoice(ScriptState*);
48 ScriptPromise prompt(ScriptState*); 56 ScriptPromise prompt(ScriptState*);
49 57
50 const AtomicString& interfaceName() const override; 58 const AtomicString& interfaceName() const override;
51 void preventDefault() override; 59 void preventDefault() override;
52 60
53 DECLARE_VIRTUAL_TRACE(); 61 DECLARE_VIRTUAL_TRACE();
54 62
55 private: 63 private:
56 BeforeInstallPromptEvent(const AtomicString& name, 64 BeforeInstallPromptEvent(const AtomicString& name,
57 ExecutionContext*, 65 LocalFrame*,
58 const Vector<String>& platforms, 66 mojo::ScopedMessagePipeHandle serviceHandle,
59 int requestId, 67 mojo::ScopedMessagePipeHandle eventHandle,
60 WebAppBannerClient*); 68 const Vector<String>& platforms);
61 BeforeInstallPromptEvent(const AtomicString& name, 69 BeforeInstallPromptEvent(const AtomicString& name,
62 const BeforeInstallPromptEventInit&); 70 const BeforeInstallPromptEventInit&);
63 71
72 // mojom::blink::AppBannerEvent methods:
73 void BannerAccepted(const WTF::String& platform) override;
74 void BannerDismissed() override;
75
76 mojom::blink::AppBannerServicePtr m_bannerService;
77 mojo::Binding<mojom::blink::AppBannerEvent> m_binding;
esprehn 2016/10/07 00:39:52 What is a Binding vs a ServicePtr? Why do we need
dcheng 2016/10/07 07:03:16 ServicePtr is an InterfacePtr and manages a messag
dominickn 2016/10/17 05:38:45 As dcheng said, we need both of these here so that
64 Vector<String> m_platforms; 78 Vector<String> m_platforms;
65
66 int m_requestId;
67 WebAppBannerClient* m_client;
68 Member<UserChoiceProperty> m_userChoice; 79 Member<UserChoiceProperty> m_userChoice;
69 bool m_registered; 80 bool m_promptCalled;
70 }; 81 };
71 82
72 DEFINE_TYPE_CASTS(BeforeInstallPromptEvent, 83 DEFINE_TYPE_CASTS(BeforeInstallPromptEvent,
73 Event, 84 Event,
74 event, 85 event,
75 event->interfaceName() == 86 event->interfaceName() ==
76 EventNames::BeforeInstallPromptEvent, 87 EventNames::BeforeInstallPromptEvent,
77 event.interfaceName() == 88 event.interfaceName() ==
78 EventNames::BeforeInstallPromptEvent); 89 EventNames::BeforeInstallPromptEvent);
79 90
80 } // namespace blink 91 } // namespace blink
81 92
82 #endif // BeforeInstallPromptEvent_h 93 #endif // BeforeInstallPromptEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698