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

Side by Side Diff: chrome/browser/notifications/notification_browsertest.cc

Issue 1312453005: Removed Profile::GetHostContentSettingsMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed Notification Subscription from SupervisedProvider Created 5 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <deque> 5 #include <deque>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/test/simple_test_clock.h" 16 #include "base/test/simple_test_clock.h"
17 #include "base/time/clock.h" 17 #include "base/time/clock.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
20 #include "chrome/browser/infobars/infobar_service.h" 21 #include "chrome/browser/infobars/infobar_service.h"
21 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 22 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
22 #include "chrome/browser/notifications/notification.h" 23 #include "chrome/browser/notifications/notification.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_tabstrip.h" 26 #include "chrome/browser/ui/browser_tabstrip.h"
26 #include "chrome/browser/ui/browser_window.h" 27 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 29 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
29 #include "chrome/test/base/in_process_browser_test.h" 30 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 DesktopNotificationProfileUtil::DenyPermission(browser()->profile(), origin); 220 DesktopNotificationProfileUtil::DenyPermission(browser()->profile(), origin);
220 } 221 }
221 222
222 void NotificationsTest::AllowOrigin(const GURL& origin) { 223 void NotificationsTest::AllowOrigin(const GURL& origin) {
223 DropOriginPreference(origin); 224 DropOriginPreference(origin);
224 DesktopNotificationProfileUtil::GrantPermission(browser()->profile(), origin); 225 DesktopNotificationProfileUtil::GrantPermission(browser()->profile(), origin);
225 } 226 }
226 227
227 void NotificationsTest::AllowAllOrigins() { 228 void NotificationsTest::AllowAllOrigins() {
228 // Reset all origins 229 // Reset all origins
229 browser()->profile()->GetHostContentSettingsMap()->ClearSettingsForOneType( 230 HostContentSettingsMapFactory::GetForProfile(browser()->profile())
230 CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 231 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
231 SetDefaultContentSetting(CONTENT_SETTING_ALLOW); 232 SetDefaultContentSetting(CONTENT_SETTING_ALLOW);
232 } 233 }
233 234
234 void NotificationsTest::SetDefaultContentSetting(ContentSetting setting) { 235 void NotificationsTest::SetDefaultContentSetting(ContentSetting setting) {
235 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 236 HostContentSettingsMapFactory::GetForProfile(browser()->profile())
236 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting); 237 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting);
237 } 238 }
238 239
239 std::string NotificationsTest::CreateNotification( 240 std::string NotificationsTest::CreateNotification(
240 Browser* browser, 241 Browser* browser,
241 bool wait_for_new_balloon, 242 bool wait_for_new_balloon,
242 const char* icon, 243 const char* icon,
243 const char* title, 244 const char* title,
244 const char* body, 245 const char* body,
245 const char* replace_id) { 246 const char* replace_id) {
246 std::string script = base::StringPrintf( 247 std::string script = base::StringPrintf(
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 message_center::MessageCenter::Get()->GetVisibleNotifications(); 691 message_center::MessageCenter::Get()->GetVisibleNotifications();
691 EXPECT_EQ(base::ASCIIToUTF16("Title2"), (*notifications.rbegin())->title()); 692 EXPECT_EQ(base::ASCIIToUTF16("Title2"), (*notifications.rbegin())->title());
692 EXPECT_EQ(base::ASCIIToUTF16("Body2"), 693 EXPECT_EQ(base::ASCIIToUTF16("Body2"),
693 (*notifications.rbegin())->message()); 694 (*notifications.rbegin())->message());
694 } 695 }
695 696
696 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestLastUsage) { 697 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestLastUsage) {
697 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 698 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
698 699
699 HostContentSettingsMap* settings_map = 700 HostContentSettingsMap* settings_map =
700 browser()->profile()->GetHostContentSettingsMap(); 701 HostContentSettingsMapFactory::GetForProfile(browser()->profile());
701 base::SimpleTestClock* clock = new base::SimpleTestClock(); 702 base::SimpleTestClock* clock = new base::SimpleTestClock();
702 settings_map->SetPrefClockForTesting(scoped_ptr<base::Clock>(clock)); 703 settings_map->SetPrefClockForTesting(scoped_ptr<base::Clock>(clock));
703 clock->SetNow(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(10)); 704 clock->SetNow(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(10));
704 705
705 // Creates a simple notification. 706 // Creates a simple notification.
706 AllowAllOrigins(); 707 AllowAllOrigins();
707 ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); 708 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
708 709
709 std::string result = CreateSimpleNotification(browser(), true); 710 std::string result = CreateSimpleNotification(browser(), true);
710 EXPECT_NE("-1", result); 711 EXPECT_NE("-1", result);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 true); // by_user 832 true); // by_user
832 833
833 ASSERT_EQ(0, GetNotificationCount()); 834 ASSERT_EQ(0, GetNotificationCount());
834 835
835 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did 836 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did
836 // crash. Work around this timing issue by creating another notification, 837 // crash. Work around this timing issue by creating another notification,
837 // which requires interaction with the renderer process. 838 // which requires interaction with the renderer process.
838 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat"); 839 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat");
839 EXPECT_NE("-1", result); 840 EXPECT_NE("-1", result);
840 } 841 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698