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

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. init() can cause frames to detach 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"
15 #include <utility>
13 16
14 namespace blink { 17 namespace blink {
15 18
16 class BeforeInstallPromptEvent; 19 class BeforeInstallPromptEvent;
17 class BeforeInstallPromptEventInit; 20 class BeforeInstallPromptEventInit;
18 class WebAppBannerClient;
19 21
20 using UserChoiceProperty = 22 using UserChoiceProperty =
21 ScriptPromiseProperty<Member<BeforeInstallPromptEvent>, 23 ScriptPromiseProperty<Member<BeforeInstallPromptEvent>,
22 Member<AppBannerPromptResult>, 24 Member<AppBannerPromptResult>,
23 ToV8UndefinedGenerator>; 25 ToV8UndefinedGenerator>;
24 26
25 class BeforeInstallPromptEvent final : public Event { 27 class BeforeInstallPromptEvent final : public Event,
28 public mojom::blink::AppBannerEvent {
26 DEFINE_WRAPPERTYPEINFO(); 29 DEFINE_WRAPPERTYPEINFO();
30 USING_PRE_FINALIZER(BeforeInstallPromptEvent, dispose);
27 31
28 public: 32 public:
29 ~BeforeInstallPromptEvent() override; 33 ~BeforeInstallPromptEvent() override;
30 34
31 static BeforeInstallPromptEvent* create(const AtomicString& name, 35 static BeforeInstallPromptEvent* create(
32 ExecutionContext* executionContext, 36 const AtomicString& name,
33 const Vector<String>& platforms, 37 LocalFrame* frame,
34 int requestId, 38 mojom::blink::AppBannerServicePtr servicePtr,
35 WebAppBannerClient* client) { 39 mojom::blink::AppBannerEventRequest eventRequest,
36 return new BeforeInstallPromptEvent(name, executionContext, platforms, 40 const Vector<String>& platforms) {
37 requestId, client); 41 return new BeforeInstallPromptEvent(name, frame, std::move(servicePtr),
42 std::move(eventRequest), platforms);
38 } 43 }
39 44
40 static BeforeInstallPromptEvent* create( 45 static BeforeInstallPromptEvent* create(
41 const AtomicString& name, 46 const AtomicString& name,
42 const BeforeInstallPromptEventInit& init) { 47 const BeforeInstallPromptEventInit& init) {
43 return new BeforeInstallPromptEvent(name, init); 48 return new BeforeInstallPromptEvent(name, init);
44 } 49 }
45 50
51 void dispose();
52
46 Vector<String> platforms() const; 53 Vector<String> platforms() const;
47 ScriptPromise userChoice(ScriptState*); 54 ScriptPromise userChoice(ScriptState*);
48 ScriptPromise prompt(ScriptState*); 55 ScriptPromise prompt(ScriptState*);
49 56
50 const AtomicString& interfaceName() const override; 57 const AtomicString& interfaceName() const override;
51 void preventDefault() override; 58 void preventDefault() override;
52 59
53 DECLARE_VIRTUAL_TRACE(); 60 DECLARE_VIRTUAL_TRACE();
54 61
55 private: 62 private:
56 BeforeInstallPromptEvent(const AtomicString& name, 63 BeforeInstallPromptEvent(const AtomicString& name,
57 ExecutionContext*, 64 LocalFrame*,
dcheng 2016/10/19 06:15:58 Let's make LocalFrame* a reference here (and in cr
dominickn 2016/10/19 08:17:00 Done.
58 const Vector<String>& platforms, 65 mojom::blink::AppBannerServicePtr,
59 int requestId, 66 mojom::blink::AppBannerEventRequest,
60 WebAppBannerClient*); 67 const Vector<String>& platforms);
61 BeforeInstallPromptEvent(const AtomicString& name, 68 BeforeInstallPromptEvent(const AtomicString& name,
62 const BeforeInstallPromptEventInit&); 69 const BeforeInstallPromptEventInit&);
63 70
71 // mojom::blink::AppBannerEvent methods:
72 void BannerAccepted(const String& platform) override;
73 void BannerDismissed() override;
74
75 mojom::blink::AppBannerServicePtr m_bannerService;
76 mojo::Binding<mojom::blink::AppBannerEvent> m_binding;
64 Vector<String> m_platforms; 77 Vector<String> m_platforms;
65
66 int m_requestId;
67 WebAppBannerClient* m_client;
68 Member<UserChoiceProperty> m_userChoice; 78 Member<UserChoiceProperty> m_userChoice;
69 bool m_registered; 79 bool m_promptCalled;
70 }; 80 };
71 81
72 DEFINE_TYPE_CASTS(BeforeInstallPromptEvent, 82 DEFINE_TYPE_CASTS(BeforeInstallPromptEvent,
73 Event, 83 Event,
74 event, 84 event,
75 event->interfaceName() == 85 event->interfaceName() ==
76 EventNames::BeforeInstallPromptEvent, 86 EventNames::BeforeInstallPromptEvent,
77 event.interfaceName() == 87 event.interfaceName() ==
78 EventNames::BeforeInstallPromptEvent); 88 EventNames::BeforeInstallPromptEvent);
79 89
80 } // namespace blink 90 } // namespace blink
81 91
82 #endif // BeforeInstallPromptEvent_h 92 #endif // BeforeInstallPromptEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698