OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "modules/push_messaging/PushController.h" | 5 #include "modules/push_messaging/PushController.h" |
6 | 6 |
7 #include "public/platform/modules/push_messaging/WebPushClient.h" | 7 #include "public/platform/modules/push_messaging/WebPushClient.h" |
8 #include "wtf/Assertions.h" | 8 #include "wtf/Assertions.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 PushController::PushController(WebPushClient* client) : m_client(client) {} | 12 PushController::PushController(LocalFrame& frame, WebPushClient* client) |
13 | 13 : Supplement<LocalFrame>(frame), m_client(client) {} |
14 PushController* PushController::create(WebPushClient* client) { | |
15 return new PushController(client); | |
16 } | |
17 | 14 |
18 WebPushClient& PushController::clientFrom(LocalFrame* frame) { | 15 WebPushClient& PushController::clientFrom(LocalFrame* frame) { |
19 PushController* controller = PushController::from(frame); | 16 PushController* controller = PushController::from(frame); |
20 DCHECK(controller); | 17 DCHECK(controller); |
21 WebPushClient* client = controller->client(); | 18 WebPushClient* client = controller->client(); |
22 DCHECK(client); | 19 DCHECK(client); |
23 return *client; | 20 return *client; |
24 } | 21 } |
25 | 22 |
26 const char* PushController::supplementName() { | 23 const char* PushController::supplementName() { |
27 return "PushController"; | 24 return "PushController"; |
28 } | 25 } |
29 | 26 |
30 void providePushControllerTo(LocalFrame& frame, WebPushClient* client) { | 27 void providePushControllerTo(LocalFrame& frame, WebPushClient* client) { |
31 PushController::provideTo(frame, PushController::supplementName(), | 28 PushController::provideTo(frame, PushController::supplementName(), |
32 PushController::create(client)); | 29 new PushController(frame, client)); |
33 } | 30 } |
34 | 31 |
35 } // namespace blink | 32 } // namespace blink |
OLD | NEW |