Chromium Code Reviews| 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" |
| 11 #include "content/public/common/push_subscription_options.h" | |
| 12 #include "content/public/common/push_subscription_options.h" | |
|
Peter Beverloo
2016/02/26 16:02:33
nit: double include
harkness
2016/02/26 17:12:04
Done.
| |
| 11 #include "content/shell/browser/layout_test/layout_test_browser_context.h" | 13 #include "content/shell/browser/layout_test/layout_test_browser_context.h" |
| 12 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h " | 14 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h " |
| 13 #include "content/shell/browser/layout_test/layout_test_permission_manager.h" | 15 #include "content/shell/browser/layout_test/layout_test_permission_manager.h" |
| 14 | 16 |
| 15 namespace content { | 17 namespace content { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 // NIST P-256 public key made available to layout tests. Must be an uncompressed | 21 // NIST P-256 public key made available to layout tests. Must be an uncompressed |
| 20 // point in accordance with SEC1 2.3.3. | 22 // point in accordance with SEC1 2.3.3. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 LayoutTestPushMessagingService::~LayoutTestPushMessagingService() { | 62 LayoutTestPushMessagingService::~LayoutTestPushMessagingService() { |
| 61 } | 63 } |
| 62 | 64 |
| 63 GURL LayoutTestPushMessagingService::GetPushEndpoint() { | 65 GURL LayoutTestPushMessagingService::GetPushEndpoint() { |
| 64 return GURL("https://example.com/LayoutTestEndpoint"); | 66 return GURL("https://example.com/LayoutTestEndpoint"); |
| 65 } | 67 } |
| 66 | 68 |
| 67 void LayoutTestPushMessagingService::SubscribeFromDocument( | 69 void LayoutTestPushMessagingService::SubscribeFromDocument( |
| 68 const GURL& requesting_origin, | 70 const GURL& requesting_origin, |
| 69 int64_t service_worker_registration_id, | 71 int64_t service_worker_registration_id, |
| 70 const std::string& sender_id, | |
| 71 int renderer_id, | 72 int renderer_id, |
| 72 int render_frame_id, | 73 int render_frame_id, |
| 73 bool user_visible, | 74 const PushSubscriptionOptions& options, |
| 74 const PushMessagingService::RegisterCallback& callback) { | 75 const PushMessagingService::RegisterCallback& callback) { |
| 75 SubscribeFromWorker(requesting_origin, service_worker_registration_id, | 76 SubscribeFromWorker(requesting_origin, service_worker_registration_id, |
| 76 sender_id, user_visible, callback); | 77 options, callback); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void LayoutTestPushMessagingService::SubscribeFromWorker( | 80 void LayoutTestPushMessagingService::SubscribeFromWorker( |
| 80 const GURL& requesting_origin, | 81 const GURL& requesting_origin, |
| 81 int64_t service_worker_registration_id, | 82 int64_t service_worker_registration_id, |
| 82 const std::string& sender_id, | 83 const PushSubscriptionOptions& options, |
| 83 bool user_visible, | |
| 84 const PushMessagingService::RegisterCallback& callback) { | 84 const PushMessagingService::RegisterCallback& callback) { |
| 85 if (GetPermissionStatus(requesting_origin, user_visible) == | 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 callback.Run("layoutTestRegistrationId", p256dh, auth, | 92 callback.Run("layoutTestRegistrationId", p256dh, auth, |
| 93 PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE); | 93 PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE); |
| 94 } else { | 94 } else { |
| 95 callback.Run("registration_id", std::vector<uint8_t>() /* p256dh */, | 95 callback.Run("registration_id", std::vector<uint8_t>() /* p256dh */, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 125 | 125 |
| 126 void LayoutTestPushMessagingService::Unsubscribe( | 126 void LayoutTestPushMessagingService::Unsubscribe( |
| 127 const GURL& requesting_origin, | 127 const GURL& requesting_origin, |
| 128 int64_t service_worker_registration_id, | 128 int64_t service_worker_registration_id, |
| 129 const std::string& sender_id, | 129 const std::string& sender_id, |
| 130 const UnregisterCallback& callback) { | 130 const UnregisterCallback& callback) { |
| 131 callback.Run(PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED); | 131 callback.Run(PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace content | 134 } // namespace content |
| OLD | NEW |