| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 GetBrowser()->tab_strip_model()->GetActiveWebContents()); | 189 GetBrowser()->tab_strip_model()->GetActiveWebContents()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void RequestAndAcceptPermission(); | 192 void RequestAndAcceptPermission(); |
| 193 void RequestAndDenyPermission(); | 193 void RequestAndDenyPermission(); |
| 194 | 194 |
| 195 void TryToSubscribeSuccessfully( | 195 void TryToSubscribeSuccessfully( |
| 196 const std::string& expected_push_subscription_info, | 196 const std::string& expected_push_subscription_info, |
| 197 bool use_key = true); | 197 bool use_key = true); |
| 198 | 198 |
| 199 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { | 199 std::string GetEndpointForSubscriptionId(const std::string& subscription_id, |
| 200 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; | 200 bool standard_protocol = true) { |
| 201 return push_service()->GetEndpoint(standard_protocol).spec() + |
| 202 subscription_id; |
| 201 } | 203 } |
| 202 | 204 |
| 203 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( | 205 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( |
| 204 int64_t service_worker_registration_id); | 206 int64_t service_worker_registration_id); |
| 205 | 207 |
| 206 void SendMessageAndWaitUntilHandled( | 208 void SendMessageAndWaitUntilHandled( |
| 207 const PushMessagingAppIdentifier& app_identifier, | 209 const PushMessagingAppIdentifier& app_identifier, |
| 208 const gcm::IncomingMessage& message); | 210 const gcm::IncomingMessage& message); |
| 209 | 211 |
| 210 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } | 212 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 if (use_key) { | 290 if (use_key) { |
| 289 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); | 291 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); |
| 290 ASSERT_EQ("manifest removed", script_result); | 292 ASSERT_EQ("manifest removed", script_result); |
| 291 | 293 |
| 292 EXPECT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 294 EXPECT_TRUE(RunScript("documentSubscribePush()", &script_result)); |
| 293 } else { | 295 } else { |
| 294 // Test backwards compatibility with old ID based subscriptions. | 296 // Test backwards compatibility with old ID based subscriptions. |
| 295 EXPECT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); | 297 EXPECT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); |
| 296 } | 298 } |
| 297 | 299 |
| 298 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_info), | 300 EXPECT_EQ( |
| 299 script_result); | 301 GetEndpointForSubscriptionId(expected_push_subscription_info, use_key), |
| 302 script_result); |
| 300 } | 303 } |
| 301 | 304 |
| 302 PushMessagingAppIdentifier | 305 PushMessagingAppIdentifier |
| 303 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( | 306 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( |
| 304 int64_t service_worker_registration_id) { | 307 int64_t service_worker_registration_id) { |
| 305 GURL origin = https_server()->GetURL("/").GetOrigin(); | 308 GURL origin = https_server()->GetURL("/").GetOrigin(); |
| 306 PushMessagingAppIdentifier app_identifier = | 309 PushMessagingAppIdentifier app_identifier = |
| 307 PushMessagingAppIdentifier::FindByServiceWorker( | 310 PushMessagingAppIdentifier::FindByServiceWorker( |
| 308 GetBrowser()->profile(), origin, service_worker_registration_id); | 311 GetBrowser()->profile(), origin, service_worker_registration_id); |
| 309 EXPECT_FALSE(app_identifier.is_null()); | 312 EXPECT_FALSE(app_identifier.is_null()); |
| (...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1453 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1451 | 1454 |
| 1452 // After dropping the last subscription background mode is still inactive. | 1455 // After dropping the last subscription background mode is still inactive. |
| 1453 std::string script_result; | 1456 std::string script_result; |
| 1454 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | 1457 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); |
| 1455 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1458 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1456 EXPECT_EQ("unsubscribe result: true", script_result); | 1459 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1457 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1460 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1458 } | 1461 } |
| 1459 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1462 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |