| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/notifications/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
| 11 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 10 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 11 #include "chrome/common/content_settings.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
| 14 #include "content/browser/renderer_host/test_render_view_host.h" | 14 #include "content/browser/renderer_host/test_render_view_host.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // The HasPermission method of the DesktopNotificationService wants to be called | 20 // The HasPermission method of the DesktopNotificationService wants to be called |
| 21 // on the IO thread. This class routes calls to the cache on the IO thread. | 21 // on the IO thread. This class routes calls to the cache on the IO thread. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionAllowed, | 155 EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionAllowed, |
| 156 proxy_->ServiceHasPermission(service_, https_url)); | 156 proxy_->ServiceHasPermission(service_, https_url)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 TEST_F(DesktopNotificationServiceTest, GetNotificationsSettings) { | 159 TEST_F(DesktopNotificationServiceTest, GetNotificationsSettings) { |
| 160 service_->GrantPermission(GURL("http://allowed2.com")); | 160 service_->GrantPermission(GURL("http://allowed2.com")); |
| 161 service_->GrantPermission(GURL("http://allowed.com")); | 161 service_->GrantPermission(GURL("http://allowed.com")); |
| 162 service_->DenyPermission(GURL("http://denied2.com")); | 162 service_->DenyPermission(GURL("http://denied2.com")); |
| 163 service_->DenyPermission(GURL("http://denied.com")); | 163 service_->DenyPermission(GURL("http://denied.com")); |
| 164 | 164 |
| 165 HostContentSettingsMap::SettingsForOneType settings; | 165 ContentSettingsForOneType settings; |
| 166 service_->GetNotificationsSettings(&settings); | 166 service_->GetNotificationsSettings(&settings); |
| 167 ASSERT_EQ(4u, settings.size()); | 167 ASSERT_EQ(4u, settings.size()); |
| 168 | 168 |
| 169 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( | 169 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( |
| 170 GURL("http://allowed.com")), | 170 GURL("http://allowed.com")), |
| 171 settings[0].a); | 171 settings[0].a); |
| 172 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 172 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 173 settings[0].c); | 173 settings[0].c); |
| 174 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( | 174 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( |
| 175 GURL("http://allowed2.com")), | 175 GURL("http://allowed2.com")), |
| 176 settings[1].a); | 176 settings[1].a); |
| 177 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 177 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 178 settings[1].c); | 178 settings[1].c); |
| 179 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( | 179 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( |
| 180 GURL("http://denied.com")), | 180 GURL("http://denied.com")), |
| 181 settings[2].a); | 181 settings[2].a); |
| 182 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 182 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 183 settings[2].c); | 183 settings[2].c); |
| 184 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( | 184 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( |
| 185 GURL("http://denied2.com")), | 185 GURL("http://denied2.com")), |
| 186 settings[3].a); | 186 settings[3].a); |
| 187 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 187 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 188 settings[3].c); | 188 settings[3].c); |
| 189 } | 189 } |
| OLD | NEW |