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/browser/layout_test/layout_test_push_messaging_service.h " | 5 #include "content/shell/browser/layout_test/layout_test_push_messaging_service.h " |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "content/public/browser/permission_type.h" | 10 #include "content/public/browser/permission_type.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 int64_t service_worker_registration_id, | 82 int64_t service_worker_registration_id, |
83 const PushSubscriptionOptions& options, | 83 const PushSubscriptionOptions& options, |
84 const PushMessagingService::RegisterCallback& callback) { | 84 const PushMessagingService::RegisterCallback& callback) { |
85 if (GetPermissionStatus(requesting_origin, options.user_visible_only) == | 85 if (GetPermissionStatus(requesting_origin, options.user_visible_only) == |
86 blink::WebPushPermissionStatusGranted) { | 86 blink::WebPushPermissionStatusGranted) { |
87 std::vector<uint8_t> p256dh( | 87 std::vector<uint8_t> p256dh( |
88 kTestP256Key, kTestP256Key + arraysize(kTestP256Key)); | 88 kTestP256Key, kTestP256Key + arraysize(kTestP256Key)); |
89 std::vector<uint8_t> auth( | 89 std::vector<uint8_t> auth( |
90 kAuthentication, kAuthentication + arraysize(kAuthentication)); | 90 kAuthentication, kAuthentication + arraysize(kAuthentication)); |
91 | 91 |
92 is_subscribed_ = true; | |
92 callback.Run("layoutTestRegistrationId", p256dh, auth, | 93 callback.Run("layoutTestRegistrationId", p256dh, auth, |
93 PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE); | 94 PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE); |
94 } else { | 95 } else { |
95 callback.Run("registration_id", std::vector<uint8_t>() /* p256dh */, | 96 callback.Run("registration_id", std::vector<uint8_t>() /* p256dh */, |
96 std::vector<uint8_t>() /* auth */, | 97 std::vector<uint8_t>() /* auth */, |
97 PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); | 98 PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 void LayoutTestPushMessagingService::GetEncryptionInfo( | 102 void LayoutTestPushMessagingService::GetEncryptionInfo( |
(...skipping 20 matching lines...) Expand all Loading... | |
122 | 123 |
123 bool LayoutTestPushMessagingService::SupportNonVisibleMessages() { | 124 bool LayoutTestPushMessagingService::SupportNonVisibleMessages() { |
124 return false; | 125 return false; |
125 } | 126 } |
126 | 127 |
127 void LayoutTestPushMessagingService::Unsubscribe( | 128 void LayoutTestPushMessagingService::Unsubscribe( |
128 const GURL& requesting_origin, | 129 const GURL& requesting_origin, |
129 int64_t service_worker_registration_id, | 130 int64_t service_worker_registration_id, |
130 const std::string& sender_id, | 131 const std::string& sender_id, |
131 const UnregisterCallback& callback) { | 132 const UnregisterCallback& callback) { |
132 callback.Run(PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED); | 133 ClearPushSubscriptionId( |
134 LayoutTestContentBrowserClient::Get()->browser_context(), | |
135 requesting_origin, service_worker_registration_id, | |
136 base::Bind(callback, | |
137 is_subscribed_ | |
138 ? PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED | |
139 : PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED)); | |
140 is_subscribed_ = false; | |
Peter Beverloo
2016/09/30 14:26:07
Is there any way a layout test can end up in this
johnme
2016/09/30 17:02:10
Yes, it can. There are layout tests that explicitl
| |
133 } | 141 } |
134 | 142 |
135 } // namespace content | 143 } // namespace content |
OLD | NEW |