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

Side by Side Diff: third_party/WebKit/Source/modules/notifications/Notification.h

Issue 1904163002: Move Web Notifications to use Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@skbitmap-blink
Patch Set: resolves the promise Created 4 years, 8 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 #include "bindings/core/v8/SerializedScriptValue.h" 37 #include "bindings/core/v8/SerializedScriptValue.h"
38 #include "core/dom/ActiveDOMObject.h" 38 #include "core/dom/ActiveDOMObject.h"
39 #include "core/dom/DOMTimeStamp.h" 39 #include "core/dom/DOMTimeStamp.h"
40 #include "modules/EventTargetModules.h" 40 #include "modules/EventTargetModules.h"
41 #include "modules/ModulesExport.h" 41 #include "modules/ModulesExport.h"
42 #include "modules/vibration/NavigatorVibration.h" 42 #include "modules/vibration/NavigatorVibration.h"
43 #include "platform/AsyncMethodRunner.h" 43 #include "platform/AsyncMethodRunner.h"
44 #include "platform/heap/Handle.h" 44 #include "platform/heap/Handle.h"
45 #include "platform/weborigin/KURL.h" 45 #include "platform/weborigin/KURL.h"
46 #include "public/platform/WebVector.h" 46 #include "public/platform/WebVector.h"
47 #include "public/platform/modules/notifications/WebNotificationData.h"
48 #include "public/platform/modules/notifications/WebNotificationDelegate.h" 47 #include "public/platform/modules/notifications/WebNotificationDelegate.h"
48 #include "public/platform/modules/notifications/notification.mojom-wtf.h"
49 #include "public/platform/modules/permissions/permission_status.mojom.h" 49 #include "public/platform/modules/permissions/permission_status.mojom.h"
50 50
51 namespace blink { 51 namespace blink {
52 52
53 class ExecutionContext; 53 class ExecutionContext;
54 class NotificationAction; 54 class NotificationAction;
55 class NotificationManager;
55 class NotificationOptions; 56 class NotificationOptions;
56 class NotificationPermissionCallback; 57 class NotificationPermissionCallback;
57 class NotificationResourcesLoader; 58 class NotificationResourcesLoader;
58 class ScriptState; 59 class ScriptState;
59 60
60 class MODULES_EXPORT Notification final : public EventTargetWithInlineData, publ ic ActiveScriptWrappable, public ActiveDOMObject, public WebNotificationDelegate { 61 class MODULES_EXPORT Notification final : public EventTargetWithInlineData, publ ic ActiveScriptWrappable, public ActiveDOMObject, public WebNotificationDelegate {
61 USING_GARBAGE_COLLECTED_MIXIN(Notification); 62 USING_GARBAGE_COLLECTED_MIXIN(Notification);
62 DEFINE_WRAPPERTYPEINFO(); 63 DEFINE_WRAPPERTYPEINFO();
63 public: 64 public:
64 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for 65 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for
65 // the notification to be displayed to the user when the developer-provided data is valid. 66 // the notification to be displayed to the user when the developer-provided data is valid.
66 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); 67 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&);
67 68
68 // Used for embedder-created Notification objects. If |showing| is true, wil l initialize the 69 // Used for embedder-created Notification objects. If |showing| is true, wil l initialize the
69 // Notification's state as showing, or as closed otherwise. 70 // Notification's state as showing, or as closed otherwise.
70 static Notification* create(ExecutionContext*, int64_t persistentId, const W ebNotificationData&, bool showing); 71 static Notification* create(ExecutionContext*, int64_t persistentId, mojom:: wtf::NotificationPtr, bool showing);
71 72
72 ~Notification() override; 73 ~Notification() override;
73 74
74 void close(); 75 void close();
75 76
76 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); 77 DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
77 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); 78 DEFINE_ATTRIBUTE_EVENT_LISTENER(show);
78 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 79 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
79 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); 80 DEFINE_ATTRIBUTE_EVENT_LISTENER(close);
80 81
(...skipping 13 matching lines...) Expand all
94 NavigatorVibration::VibrationPattern vibrate(bool& isNull) const; 95 NavigatorVibration::VibrationPattern vibrate(bool& isNull) const;
95 DOMTimeStamp timestamp() const; 96 DOMTimeStamp timestamp() const;
96 bool renotify() const; 97 bool renotify() const;
97 bool silent() const; 98 bool silent() const;
98 bool requireInteraction() const; 99 bool requireInteraction() const;
99 ScriptValue data(ScriptState*); 100 ScriptValue data(ScriptState*);
100 HeapVector<NotificationAction> actions() const; 101 HeapVector<NotificationAction> actions() const;
101 102
102 static String permissionString(mojom::PermissionStatus); 103 static String permissionString(mojom::PermissionStatus);
103 static String permission(ExecutionContext*); 104 static String permission(ExecutionContext*);
104 static mojom::PermissionStatus checkPermission(ExecutionContext*);
105 static ScriptPromise requestPermission(ScriptState*, NotificationPermissionC allback*); 105 static ScriptPromise requestPermission(ScriptState*, NotificationPermissionC allback*);
106 106
107 static size_t maxActions(); 107 static size_t maxActions();
108 108
109 // EventTarget interface. 109 // EventTarget interface.
110 ExecutionContext* getExecutionContext() const final { return ActiveDOMObject ::getExecutionContext(); } 110 ExecutionContext* getExecutionContext() const final { return ActiveDOMObject ::getExecutionContext(); }
111 const AtomicString& interfaceName() const override; 111 const AtomicString& interfaceName() const override;
112 112
113 // ActiveDOMObject interface. 113 // ActiveDOMObject interface.
114 void stop() override; 114 void stop() override;
115 115
116 // ActiveScriptWrappable interface. 116 // ActiveScriptWrappable interface.
117 bool hasPendingActivity() const final; 117 bool hasPendingActivity() const final;
118 118
119 DECLARE_VIRTUAL_TRACE(); 119 DECLARE_VIRTUAL_TRACE();
120 120
121 protected: 121 protected:
122 // EventTarget interface. 122 // EventTarget interface.
123 DispatchEventResult dispatchEventInternal(Event*) final; 123 DispatchEventResult dispatchEventInternal(Event*) final;
124 124
125 private: 125 private:
126 Notification(ExecutionContext*, const WebNotificationData&); 126 Notification(ExecutionContext*, mojom::wtf::NotificationPtr);
127
128 // Returns the notification manager responsible for this notification.
129 NotificationManager* manager() const;
127 130
128 // Schedules an asynchronous call to |prepareShow|, allowing the constructor 131 // Schedules an asynchronous call to |prepareShow|, allowing the constructor
129 // to return so that events can be fired on the notification object. 132 // to return so that events can be fired on the notification object.
130 void schedulePrepareShow(); 133 void schedulePrepareShow();
131 134
132 // Checks permission and loads any necessary resources (this may be async) 135 // Checks permission and loads any necessary resources (this may be async)
133 // before showing the notification. 136 // before showing the notification.
134 void prepareShow(); 137 void prepareShow();
135 138
136 // Shows the notification, using the resources loaded by the 139 // Shows the |notification|, using the resources loaded by the given loader.
137 // NotificationResourcesLoader. 140 void didLoadResources(NotificationResourcesLoader*, mojom::wtf::Notification Ptr notification);
138 void didLoadResources(NotificationResourcesLoader*);
139 141
140 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId; } 142 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId; }
141 143
142 WebNotificationData m_data; 144 mojom::wtf::NotificationPtr m_data;
143 145
144 // ScriptValue representations of the developer-associated data. Initialized lazily on first access. 146 // ScriptValue representations of the developer-associated data. Initialized lazily on first access.
145 ScriptValue m_developerData; 147 ScriptValue m_developerData;
146 148
147 // Notifications can either be bound to the page, which means they're identi fied by 149 // Notifications can either be bound to the page, which means they're identi fied by
148 // their delegate, or persistent, which means they're identified by a persis tent Id 150 // their delegate, or persistent, which means they're identified by a persis tent Id
149 // given to us by the embedder. This influences how we close the notificatio n. 151 // given to us by the embedder. This influences how we close the notificatio n.
150 int64_t m_persistentId; 152 int64_t m_persistentId;
151 153
152 enum NotificationState { 154 enum NotificationState {
(...skipping 10 matching lines...) Expand all
163 NotificationState m_state; 165 NotificationState m_state;
164 166
165 Member<AsyncMethodRunner<Notification>> m_prepareShowMethodRunner; 167 Member<AsyncMethodRunner<Notification>> m_prepareShowMethodRunner;
166 168
167 Member<NotificationResourcesLoader> m_loader; 169 Member<NotificationResourcesLoader> m_loader;
168 }; 170 };
169 171
170 } // namespace blink 172 } // namespace blink
171 173
172 #endif // Notification_h 174 #endif // Notification_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698