| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/gcm/fake_gcm_profile_service.h" | 13 #include "chrome/browser/gcm/fake_gcm_profile_service.h" |
| 14 #include "chrome/browser/gcm/gcm_profile_service_factory.h" | 14 #include "chrome/browser/gcm/gcm_profile_service_factory.h" |
| 15 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 15 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 16 #include "chrome/browser/permissions/permission_manager.h" | 16 #include "chrome/browser/permissions/permission_manager.h" |
| 17 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" | 17 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" |
| 18 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | 18 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" |
| 19 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" | 19 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" | 22 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" |
| 23 #include "components/version_info/version_info.h" | 23 #include "components/version_info/version_info.h" |
| 24 #include "content/public/browser/navigation_controller.h" | 24 #include "content/public/browser/navigation_controller.h" |
| 25 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| 26 #include "content/public/browser/permission_type.h" | |
| 27 #include "content/public/browser/service_worker_context.h" | 26 #include "content/public/browser/service_worker_context.h" |
| 28 #include "content/public/browser/storage_partition.h" | 27 #include "content/public/browser/storage_partition.h" |
| 29 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 30 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
| 31 #include "content/public/common/origin_util.h" | 30 #include "content/public/common/origin_util.h" |
| 32 #include "content/public/common/page_type.h" | 31 #include "content/public/common/page_type.h" |
| 33 #include "content/public/test/background_sync_test_util.h" | 32 #include "content/public/test/background_sync_test_util.h" |
| 34 #include "content/public/test/browser_test_utils.h" | 33 #include "content/public/test/browser_test_utils.h" |
| 35 #include "extensions/browser/extension_host.h" | 34 #include "extensions/browser/extension_host.h" |
| 36 #include "extensions/browser/extension_registry.h" | 35 #include "extensions/browser/extension_registry.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 public: | 217 public: |
| 219 ServiceWorkerPushMessagingTest() | 218 ServiceWorkerPushMessagingTest() |
| 220 : gcm_driver_(nullptr), push_service_(nullptr) {} | 219 : gcm_driver_(nullptr), push_service_(nullptr) {} |
| 221 ~ServiceWorkerPushMessagingTest() override {} | 220 ~ServiceWorkerPushMessagingTest() override {} |
| 222 | 221 |
| 223 void GrantNotificationPermissionForTest(const GURL& url) { | 222 void GrantNotificationPermissionForTest(const GURL& url) { |
| 224 GURL origin = url.GetOrigin(); | 223 GURL origin = url.GetOrigin(); |
| 225 DesktopNotificationProfileUtil::GrantPermission(profile(), origin); | 224 DesktopNotificationProfileUtil::GrantPermission(profile(), origin); |
| 226 ASSERT_EQ(blink::mojom::PermissionStatus::GRANTED, | 225 ASSERT_EQ(blink::mojom::PermissionStatus::GRANTED, |
| 227 PermissionManager::Get(profile())->GetPermissionStatus( | 226 PermissionManager::Get(profile())->GetPermissionStatus( |
| 228 content::PermissionType::NOTIFICATIONS, origin, origin)); | 227 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); |
| 229 } | 228 } |
| 230 | 229 |
| 231 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( | 230 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( |
| 232 int64_t service_worker_registration_id, | 231 int64_t service_worker_registration_id, |
| 233 const GURL& origin) { | 232 const GURL& origin) { |
| 234 PushMessagingAppIdentifier app_identifier = | 233 PushMessagingAppIdentifier app_identifier = |
| 235 PushMessagingAppIdentifier::FindByServiceWorker( | 234 PushMessagingAppIdentifier::FindByServiceWorker( |
| 236 profile(), origin, service_worker_registration_id); | 235 profile(), origin, service_worker_registration_id); |
| 237 | 236 |
| 238 EXPECT_FALSE(app_identifier.is_null()); | 237 EXPECT_FALSE(app_identifier.is_null()); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 message.sender_id = "1234567890"; | 859 message.sender_id = "1234567890"; |
| 861 message.raw_data = "testdata"; | 860 message.raw_data = "testdata"; |
| 862 message.decrypted = true; | 861 message.decrypted = true; |
| 863 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); | 862 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); |
| 864 push_service()->OnMessage(app_identifier.app_id(), message); | 863 push_service()->OnMessage(app_identifier.app_id(), message); |
| 865 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); | 864 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); |
| 866 run_loop.Run(); // Wait until the message is handled by push service. | 865 run_loop.Run(); // Wait until the message is handled by push service. |
| 867 } | 866 } |
| 868 | 867 |
| 869 } // namespace extensions | 868 } // namespace extensions |
| OLD | NEW |