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 17 matching lines...) Expand all Loading... |
28 error_message_ = ""; | 28 error_message_ = ""; |
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, | |
39 blink::WebPushRegistrationCallbacks* callbacks, | |
40 blink::WebServiceWorkerProvider* service_worker_provider) { | |
41 registerPushMessaging(callbacks, service_worker_provider); | |
42 } | |
43 | |
44 void MockWebPushClient::registerPushMessaging( | |
45 blink::WebPushRegistrationCallbacks* callbacks, | 38 blink::WebPushRegistrationCallbacks* callbacks, |
46 blink::WebServiceWorkerProvider* service_worker_provider) { | 39 blink::WebServiceWorkerProvider* service_worker_provider) { |
47 DCHECK(callbacks); | 40 DCHECK(callbacks); |
48 | 41 |
49 if (!error_message_.empty()) { | 42 if (!error_message_.empty()) { |
50 scoped_ptr<blink::WebPushError> error( | 43 scoped_ptr<blink::WebPushError> error( |
51 new blink::WebPushError(blink::WebPushError::ErrorTypeAbort, | 44 new blink::WebPushError(blink::WebPushError::ErrorTypeAbort, |
52 WebString::fromUTF8(error_message_))); | 45 WebString::fromUTF8(error_message_))); |
53 callbacks->onError(error.release()); | 46 callbacks->onError(error.release()); |
54 } else { | 47 } else { |
55 DCHECK(!end_point_.empty() && !registration_id_.empty()); | 48 DCHECK(!end_point_.empty() && !registration_id_.empty()); |
56 | 49 |
57 scoped_ptr<blink::WebPushRegistration> registration( | 50 scoped_ptr<blink::WebPushRegistration> registration( |
58 new blink::WebPushRegistration(WebString::fromUTF8(end_point_), | 51 new blink::WebPushRegistration(WebString::fromUTF8(end_point_), |
59 WebString::fromUTF8(registration_id_))); | 52 WebString::fromUTF8(registration_id_))); |
60 callbacks->onSuccess(registration.release()); | 53 callbacks->onSuccess(registration.release()); |
61 } | 54 } |
62 | 55 |
63 delete callbacks; | 56 delete callbacks; |
64 } | 57 } |
65 | 58 |
66 } // namespace content | 59 } // namespace content |
OLD | NEW |