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/WebPushRegistration.h" | 10 #include "third_party/WebKit/public/platform/WebPushRegistration.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 void MockWebPushClient::SetMockErrorValues(const std::string& message) { | 31 void MockWebPushClient::SetMockErrorValues(const std::string& message) { |
32 end_point_ = ""; | 32 end_point_ = ""; |
33 registration_id_ = ""; | 33 registration_id_ = ""; |
34 error_message_ = message; | 34 error_message_ = message; |
35 } | 35 } |
36 | 36 |
37 void MockWebPushClient::registerPushMessaging( | 37 void MockWebPushClient::registerPushMessaging( |
38 const WebString& sender_id, | 38 const WebString& sender_id, |
39 blink::WebPushRegistrationCallbacks* callbacks) { | |
40 registerPushMessaging(sender_id, callbacks, NULL); | |
41 } | |
42 | |
43 void MockWebPushClient::registerPushMessaging( | |
44 const WebString& sender_id, | |
45 blink::WebPushRegistrationCallbacks* callbacks, | 39 blink::WebPushRegistrationCallbacks* callbacks, |
46 blink::WebServiceWorkerProvider* service_worker_provider) { | 40 blink::WebServiceWorkerProvider* service_worker_provider) { |
| 41 registerPushMessaging(callbacks, service_worker_provider); |
| 42 } |
| 43 |
| 44 void MockWebPushClient::registerPushMessaging( |
| 45 blink::WebPushRegistrationCallbacks* callbacks, |
| 46 blink::WebServiceWorkerProvider* service_worker_provider) { |
47 DCHECK(callbacks); | 47 DCHECK(callbacks); |
48 | 48 |
49 if (!error_message_.empty()) { | 49 if (!error_message_.empty()) { |
50 scoped_ptr<blink::WebPushError> error( | 50 scoped_ptr<blink::WebPushError> error( |
51 new blink::WebPushError(blink::WebPushError::ErrorTypeAbort, | 51 new blink::WebPushError(blink::WebPushError::ErrorTypeAbort, |
52 WebString::fromUTF8(error_message_))); | 52 WebString::fromUTF8(error_message_))); |
53 callbacks->onError(error.release()); | 53 callbacks->onError(error.release()); |
54 } else { | 54 } else { |
55 DCHECK(!end_point_.empty() && !registration_id_.empty()); | 55 DCHECK(!end_point_.empty() && !registration_id_.empty()); |
56 | 56 |
57 scoped_ptr<blink::WebPushRegistration> registration( | 57 scoped_ptr<blink::WebPushRegistration> registration( |
58 new blink::WebPushRegistration(WebString::fromUTF8(end_point_), | 58 new blink::WebPushRegistration(WebString::fromUTF8(end_point_), |
59 WebString::fromUTF8(registration_id_))); | 59 WebString::fromUTF8(registration_id_))); |
60 callbacks->onSuccess(registration.release()); | 60 callbacks->onSuccess(registration.release()); |
61 } | 61 } |
62 | 62 |
63 delete callbacks; | 63 delete callbacks; |
64 } | 64 } |
65 | 65 |
66 } // namespace content | 66 } // namespace content |
OLD | NEW |