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 "content/shell/renderer/test_runner/mock_web_push_client.h" | 5 #include "content/shell/renderer/test_runner/mock_web_push_client.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "third_party/WebKit/public/platform/WebPushError.h" | 9 #include "third_party/WebKit/public/platform/WebPushError.h" |
| 10 #include "third_party/WebKit/public/platform/WebPushPermissionStatus.h" |
10 #include "third_party/WebKit/public/platform/WebPushRegistration.h" | 11 #include "third_party/WebKit/public/platform/WebPushRegistration.h" |
11 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
12 | 13 |
13 using blink::WebString; | 14 using blink::WebString; |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 MockWebPushClient::MockWebPushClient() | 18 MockWebPushClient::MockWebPushClient() |
18 : error_message_( | 19 : error_message_( |
19 "Registration failed (default mock client error message)") { | 20 "Registration failed (default mock client error message)") { |
(...skipping 29 matching lines...) Expand all Loading... |
49 | 50 |
50 scoped_ptr<blink::WebPushRegistration> registration( | 51 scoped_ptr<blink::WebPushRegistration> registration( |
51 new blink::WebPushRegistration(WebString::fromUTF8(end_point_), | 52 new blink::WebPushRegistration(WebString::fromUTF8(end_point_), |
52 WebString::fromUTF8(registration_id_))); | 53 WebString::fromUTF8(registration_id_))); |
53 callbacks->onSuccess(registration.release()); | 54 callbacks->onSuccess(registration.release()); |
54 } | 55 } |
55 | 56 |
56 delete callbacks; | 57 delete callbacks; |
57 } | 58 } |
58 | 59 |
| 60 void MockWebPushClient::getPermissionStatus( |
| 61 blink::WebPushPermissionCallback* callback, |
| 62 blink::WebServiceWorkerProvider* provider) { |
| 63 blink::WebPushPermissionStatus status; |
| 64 if (error_message_.empty()) |
| 65 status = blink::WebPushPermissionStatusGranted; |
| 66 else if (error_message_.compare("deny_permission") == 0) |
| 67 status = blink::WebPushPermissionStatusDenied; |
| 68 else |
| 69 status = blink::WebPushPermissionStatusDefault; |
| 70 |
| 71 callback->onSuccess(&status); |
| 72 delete callback; |
| 73 } |
| 74 |
| 75 |
59 } // namespace content | 76 } // namespace content |
OLD | NEW |