| 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" | 
| 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, requesting_origin, user_visible) == | 85   if (GetPermissionStatus(requesting_origin, requesting_origin, | 
|  | 86                           options.user_visible_only) == | 
| 86       blink::WebPushPermissionStatusGranted) { | 87       blink::WebPushPermissionStatusGranted) { | 
| 87     std::vector<uint8_t> p256dh( | 88     std::vector<uint8_t> p256dh( | 
| 88         kTestP256Key, kTestP256Key + arraysize(kTestP256Key)); | 89         kTestP256Key, kTestP256Key + arraysize(kTestP256Key)); | 
| 89     std::vector<uint8_t> auth( | 90     std::vector<uint8_t> auth( | 
| 90         kAuthentication, kAuthentication + arraysize(kAuthentication)); | 91         kAuthentication, kAuthentication + arraysize(kAuthentication)); | 
| 91 | 92 | 
| 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 */, | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 129 | 130 | 
| 130 void LayoutTestPushMessagingService::Unsubscribe( | 131 void LayoutTestPushMessagingService::Unsubscribe( | 
| 131     const GURL& requesting_origin, | 132     const GURL& requesting_origin, | 
| 132     int64_t service_worker_registration_id, | 133     int64_t service_worker_registration_id, | 
| 133     const std::string& sender_id, | 134     const std::string& sender_id, | 
| 134     const UnregisterCallback& callback) { | 135     const UnregisterCallback& callback) { | 
| 135   callback.Run(PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED); | 136   callback.Run(PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED); | 
| 136 } | 137 } | 
| 137 | 138 | 
| 138 }  // namespace content | 139 }  // namespace content | 
| OLD | NEW | 
|---|