| 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> |
| 6 #include <stdint.h> |
| 7 |
| 5 #include <map> | 8 #include <map> |
| 6 #include <string> | 9 #include <string> |
| 7 | 10 |
| 8 #include "base/barrier_closure.h" | 11 #include "base/barrier_closure.h" |
| 9 #include "base/bind.h" | 12 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" |
| 11 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "build/build_config.h" |
| 14 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 21 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 22 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 19 #include "chrome/browser/notifications/notification_test_util.h" | 24 #include "chrome/browser/notifications/notification_test_util.h" |
| 20 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 25 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" | 27 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" |
| 23 #include "chrome/browser/push_messaging/push_messaging_constants.h" | 28 #include "chrome/browser/push_messaging/push_messaging_constants.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void RequestAndDenyPermission(); | 171 void RequestAndDenyPermission(); |
| 167 | 172 |
| 168 void TryToSubscribeSuccessfully( | 173 void TryToSubscribeSuccessfully( |
| 169 const std::string& expected_push_subscription_id); | 174 const std::string& expected_push_subscription_id); |
| 170 | 175 |
| 171 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { | 176 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { |
| 172 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; | 177 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; |
| 173 } | 178 } |
| 174 | 179 |
| 175 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( | 180 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( |
| 176 int64 service_worker_registration_id); | 181 int64_t service_worker_registration_id); |
| 177 | 182 |
| 178 void SendMessageAndWaitUntilHandled( | 183 void SendMessageAndWaitUntilHandled( |
| 179 const PushMessagingAppIdentifier& app_identifier, | 184 const PushMessagingAppIdentifier& app_identifier, |
| 180 const gcm::IncomingMessage& message); | 185 const gcm::IncomingMessage& message); |
| 181 | 186 |
| 182 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } | 187 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } |
| 183 | 188 |
| 184 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } | 189 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } |
| 185 | 190 |
| 186 #if defined(ENABLE_NOTIFICATIONS) | 191 #if defined(ENABLE_NOTIFICATIONS) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 261 |
| 257 RequestAndAcceptPermission(); | 262 RequestAndAcceptPermission(); |
| 258 | 263 |
| 259 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); | 264 EXPECT_TRUE(RunScript("subscribePush()", &script_result)); |
| 260 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), | 265 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), |
| 261 script_result); | 266 script_result); |
| 262 } | 267 } |
| 263 | 268 |
| 264 PushMessagingAppIdentifier | 269 PushMessagingAppIdentifier |
| 265 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( | 270 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( |
| 266 int64 service_worker_registration_id) { | 271 int64_t service_worker_registration_id) { |
| 267 GURL origin = https_server()->GetURL("/").GetOrigin(); | 272 GURL origin = https_server()->GetURL("/").GetOrigin(); |
| 268 PushMessagingAppIdentifier app_identifier = | 273 PushMessagingAppIdentifier app_identifier = |
| 269 PushMessagingAppIdentifier::FindByServiceWorker( | 274 PushMessagingAppIdentifier::FindByServiceWorker( |
| 270 GetBrowser()->profile(), origin, service_worker_registration_id); | 275 GetBrowser()->profile(), origin, service_worker_registration_id); |
| 271 EXPECT_FALSE(app_identifier.is_null()); | 276 EXPECT_FALSE(app_identifier.is_null()); |
| 272 return app_identifier; | 277 return app_identifier; |
| 273 } | 278 } |
| 274 | 279 |
| 275 void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( | 280 void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( |
| 276 const PushMessagingAppIdentifier& app_identifier, | 281 const PushMessagingAppIdentifier& app_identifier, |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1282 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1278 | 1283 |
| 1279 // After dropping the last subscription background mode is still inactive. | 1284 // After dropping the last subscription background mode is still inactive. |
| 1280 std::string script_result; | 1285 std::string script_result; |
| 1281 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | 1286 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); |
| 1282 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1287 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1283 EXPECT_EQ("unsubscribe result: true", script_result); | 1288 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1284 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1289 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1285 } | 1290 } |
| 1286 #endif // defined(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1291 #endif // defined(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |