Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/extensions/service_worker_apitest.cc

Issue 2020063003: Use GetPermissionStatus instead of DesktopNotificationProfileUtil::GetContentSetting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove embber param for notifications Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/notifications/desktop_notification_profile_util.h" 13 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
14 #include "chrome/browser/permissions/permission_manager.h"
14 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" 15 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h"
15 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" 16 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
16 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 17 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
17 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 18 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
18 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
21 #include "components/version_info/version_info.h" 22 #include "components/version_info/version_info.h"
22 #include "content/public/browser/navigation_controller.h" 23 #include "content/public/browser/navigation_controller.h"
23 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/permission_type.h"
24 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
26 #include "content/public/common/page_type.h" 28 #include "content/public/common/page_type.h"
27 #include "content/public/test/background_sync_test_util.h" 29 #include "content/public/test/background_sync_test_util.h"
28 #include "content/public/test/browser_test_utils.h" 30 #include "content/public/test/browser_test_utils.h"
29 #include "extensions/browser/extension_host.h" 31 #include "extensions/browser/extension_host.h"
30 #include "extensions/browser/extension_registry.h" 32 #include "extensions/browser/extension_registry.h"
31 #include "extensions/browser/process_manager.h" 33 #include "extensions/browser/process_manager.h"
32 #include "extensions/test/background_page_watcher.h" 34 #include "extensions/test/background_page_watcher.h"
33 #include "extensions/test/extension_test_message_listener.h" 35 #include "extensions/test/extension_test_message_listener.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 193
192 class ServiceWorkerPushMessagingTest : public ServiceWorkerTest { 194 class ServiceWorkerPushMessagingTest : public ServiceWorkerTest {
193 public: 195 public:
194 ServiceWorkerPushMessagingTest() 196 ServiceWorkerPushMessagingTest()
195 : gcm_service_(nullptr), push_service_(nullptr) {} 197 : gcm_service_(nullptr), push_service_(nullptr) {}
196 ~ServiceWorkerPushMessagingTest() override {} 198 ~ServiceWorkerPushMessagingTest() override {}
197 199
198 void GrantNotificationPermissionForTest(const GURL& url) { 200 void GrantNotificationPermissionForTest(const GURL& url) {
199 GURL origin = url.GetOrigin(); 201 GURL origin = url.GetOrigin();
200 DesktopNotificationProfileUtil::GrantPermission(profile(), origin); 202 DesktopNotificationProfileUtil::GrantPermission(profile(), origin);
201 ASSERT_EQ( 203 ASSERT_EQ(blink::mojom::PermissionStatus::GRANTED,
202 CONTENT_SETTING_ALLOW, 204 PermissionManager::Get(profile())->GetPermissionStatus(
203 DesktopNotificationProfileUtil::GetContentSetting(profile(), origin)); 205 content::PermissionType::NOTIFICATIONS, origin, origin));
204 } 206 }
205 207
206 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( 208 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration(
207 int64_t service_worker_registration_id, 209 int64_t service_worker_registration_id,
208 const GURL& origin) { 210 const GURL& origin) {
209 PushMessagingAppIdentifier app_identifier = 211 PushMessagingAppIdentifier app_identifier =
210 PushMessagingAppIdentifier::FindByServiceWorker( 212 PushMessagingAppIdentifier::FindByServiceWorker(
211 profile(), origin, service_worker_registration_id); 213 profile(), origin, service_worker_registration_id);
212 214
213 EXPECT_FALSE(app_identifier.is_null()); 215 EXPECT_FALSE(app_identifier.is_null());
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 message.sender_id = "1234567890"; 756 message.sender_id = "1234567890";
755 message.raw_data = "testdata"; 757 message.raw_data = "testdata";
756 message.decrypted = true; 758 message.decrypted = true;
757 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); 759 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure());
758 push_service()->OnMessage(app_identifier.app_id(), message); 760 push_service()->OnMessage(app_identifier.app_id(), message);
759 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); 761 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied());
760 run_loop.Run(); // Wait until the message is handled by push service. 762 run_loop.Run(); // Wait until the message is handled by push service.
761 } 763 }
762 764
763 } // namespace extensions 765 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698