Index: chrome/browser/notifications/notification_browsertest.cc |
diff --git a/chrome/browser/notifications/notification_browsertest.cc b/chrome/browser/notifications/notification_browsertest.cc |
index af06140d92d68968295cc665c21f0d6e263ced15..dd78dc5b33bead339e9f95714eb3d785fe7fdb25 100644 |
--- a/chrome/browser/notifications/notification_browsertest.cc |
+++ b/chrome/browser/notifications/notification_browsertest.cc |
@@ -16,8 +16,7 @@ |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/infobars/infobar_service.h" |
-#include "chrome/browser/notifications/desktop_notification_service.h" |
-#include "chrome/browser/notifications/desktop_notification_service_factory.h" |
+#include "chrome/browser/notifications/desktop_notification_profile_util.h" |
#include "chrome/browser/notifications/notification.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
@@ -124,7 +123,6 @@ class NotificationsTest : public InProcessBrowserTest { |
void CloseBrowserWindow(Browser* browser); |
void CrashTab(Browser* browser, int index); |
- void SetDefaultPermissionSetting(ContentSetting setting); |
void DenyOrigin(const GURL& origin); |
void AllowOrigin(const GURL& origin); |
void AllowAllOrigins(); |
@@ -156,7 +154,6 @@ class NotificationsTest : public InProcessBrowserTest { |
private: |
void DropOriginPreference(const GURL& origin); |
- DesktopNotificationService* GetDesktopNotificationService(); |
}; |
int NotificationsTest::GetNotificationCount() { |
@@ -175,26 +172,21 @@ void NotificationsTest::CrashTab(Browser* browser, int index) { |
content::CrashTab(browser->tab_strip_model()->GetWebContentsAt(index)); |
} |
-void NotificationsTest::SetDefaultPermissionSetting(ContentSetting setting) { |
- DesktopNotificationService* service = GetDesktopNotificationService(); |
- service->SetDefaultContentSetting(setting); |
-} |
- |
void NotificationsTest::DenyOrigin(const GURL& origin) { |
DropOriginPreference(origin); |
- GetDesktopNotificationService()->DenyPermission(origin); |
+ DesktopNotificationProfileUtil::DenyPermission(browser()->profile(), origin); |
} |
void NotificationsTest::AllowOrigin(const GURL& origin) { |
DropOriginPreference(origin); |
- GetDesktopNotificationService()->GrantPermission(origin); |
+ DesktopNotificationProfileUtil::GrantPermission(browser()->profile(), origin); |
} |
void NotificationsTest::AllowAllOrigins() { |
- GetDesktopNotificationService()->ResetAllOrigins(); |
- GetDesktopNotificationService()->SetDefaultContentSetting( |
+ DesktopNotificationProfileUtil::ResetAllOrigins(browser()->profile()); |
+ DesktopNotificationProfileUtil::SetDefaultContentSetting(browser()->profile(), |
CONTENT_SETTING_ALLOW); |
-} |
+ } |
void NotificationsTest::VerifyInfoBar(const Browser* browser, int index) { |
InfoBarService* infobar_service = InfoBarService::FromWebContents( |
@@ -325,8 +317,8 @@ bool NotificationsTest::PerformActionOnInfoBar( |
void NotificationsTest::GetPrefsByContentSetting( |
ContentSetting setting, |
ContentSettingsForOneType* settings) { |
- DesktopNotificationService* service = GetDesktopNotificationService(); |
- service->GetNotificationsSettings(settings); |
+ DesktopNotificationProfileUtil::GetNotificationsSettings( |
+ browser()->profile(), settings); |
for (ContentSettingsForOneType::iterator it = settings->begin(); |
it != settings->end(); ) { |
if (it->setting != setting || it->source.compare("preference") != 0) |
@@ -350,15 +342,10 @@ bool NotificationsTest::CheckOriginInSetting( |
} |
void NotificationsTest::DropOriginPreference(const GURL& origin) { |
- GetDesktopNotificationService()->ClearSetting( |
+ DesktopNotificationProfileUtil::ClearSetting(browser()->profile(), |
ContentSettingsPattern::FromURLNoWildcard(origin)); |
} |
-DesktopNotificationService* NotificationsTest::GetDesktopNotificationService() { |
- Profile* profile = browser()->profile(); |
- return DesktopNotificationServiceFactory::GetForProfile(profile); |
-} |
- |
// If this flakes, use http://crbug.com/62311 and http://crbug.com/74428. |
IN_PROC_BROWSER_TEST_F(NotificationsTest, TestUserGestureInfobar) { |
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
@@ -497,7 +484,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestAllowNotificationsFromAllSites) { |
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
// Verify that all domains can be allowed to show notifications. |
- SetDefaultPermissionSetting(CONTENT_SETTING_ALLOW); |
+ DesktopNotificationProfileUtil::SetDefaultContentSetting(browser()->profile(), |
+ CONTENT_SETTING_ALLOW); |
ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); |
std::string result = CreateSimpleNotification(browser(), true); |
@@ -513,7 +501,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestDenyNotificationsFromAllSites) { |
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
// Verify that no domain can show notifications. |
- SetDefaultPermissionSetting(CONTENT_SETTING_BLOCK); |
+ DesktopNotificationProfileUtil::SetDefaultContentSetting( |
+ browser()->profile(), CONTENT_SETTING_BLOCK); |
ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); |
std::string result = CreateSimpleNotification(browser(), false); |
@@ -528,7 +517,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestDenyDomainAndAllowAll) { |
// Verify that denying a domain and allowing all shouldn't show |
// notifications from the denied domain. |
DenyOrigin(GetTestPageURL().GetOrigin()); |
- SetDefaultPermissionSetting(CONTENT_SETTING_ALLOW); |
+ DesktopNotificationProfileUtil::SetDefaultContentSetting( |
+ browser()->profile(), CONTENT_SETTING_ALLOW); |
ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); |
@@ -544,7 +534,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestAllowDomainAndDenyAll) { |
// Verify that allowing a domain and denying all others should show |
// notifications from the allowed domain. |
AllowOrigin(GetTestPageURL().GetOrigin()); |
- SetDefaultPermissionSetting(CONTENT_SETTING_BLOCK); |
+ DesktopNotificationProfileUtil::SetDefaultContentSetting( |
+ browser()->profile(), CONTENT_SETTING_BLOCK); |
ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); |