OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/notification_interactive_uitest_support.h
" | 5 #include "chrome/browser/notifications/notification_interactive_uitest_support.h
" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
10 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 10 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
11 #include "chrome/browser/notifications/web_notification_delegate.h" | 11 #include "chrome/browser/notifications/web_notification_delegate.h" |
12 #include "chrome/browser/permissions/permission_request_manager.h" | 12 #include "chrome/browser/permissions/permission_request_manager.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_features.h" | 15 #include "chrome/common/chrome_features.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
17 #include "components/content_settings/core/browser/host_content_settings_map.h" | 17 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 18 #include "components/content_settings/core/common/content_settings_utils.h" |
18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
19 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
20 #include "ui/message_center/message_center.h" | 21 #include "ui/message_center/message_center.h" |
21 #include "ui/message_center/message_center_observer.h" | 22 #include "ui/message_center/message_center_observer.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Used to observe the creation of permission prompt without responding. | 26 // Used to observe the creation of permission prompt without responding. |
26 class PermissionRequestObserver : public PermissionRequestManager::Observer { | 27 class PermissionRequestObserver : public PermissionRequestManager::Observer { |
27 public: | 28 public: |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 return observer.Wait(); | 263 return observer.Wait(); |
263 } | 264 } |
264 | 265 |
265 void NotificationsTest::GetPrefsByContentSetting( | 266 void NotificationsTest::GetPrefsByContentSetting( |
266 ContentSetting setting, | 267 ContentSetting setting, |
267 ContentSettingsForOneType* settings) { | 268 ContentSettingsForOneType* settings) { |
268 DesktopNotificationProfileUtil::GetNotificationsSettings(browser()->profile(), | 269 DesktopNotificationProfileUtil::GetNotificationsSettings(browser()->profile(), |
269 settings); | 270 settings); |
270 for (ContentSettingsForOneType::iterator it = settings->begin(); | 271 for (ContentSettingsForOneType::iterator it = settings->begin(); |
271 it != settings->end();) { | 272 it != settings->end();) { |
272 if (it->setting != setting || it->source.compare("preference") != 0) | 273 if (content_settings::ValueToContentSetting(it->setting_value.get()) != |
| 274 setting || |
| 275 it->source.compare("preference") != 0) { |
273 it = settings->erase(it); | 276 it = settings->erase(it); |
274 else | 277 } else { |
275 ++it; | 278 ++it; |
| 279 } |
276 } | 280 } |
277 } | 281 } |
278 | 282 |
279 bool NotificationsTest::CheckOriginInSetting( | 283 bool NotificationsTest::CheckOriginInSetting( |
280 const ContentSettingsForOneType& settings, | 284 const ContentSettingsForOneType& settings, |
281 const GURL& origin) { | 285 const GURL& origin) { |
282 ContentSettingsPattern pattern = | 286 ContentSettingsPattern pattern = |
283 ContentSettingsPattern::FromURLNoWildcard(origin); | 287 ContentSettingsPattern::FromURLNoWildcard(origin); |
284 for (const auto& setting : settings) { | 288 for (const auto& setting : settings) { |
285 if (setting.primary_pattern == pattern) | 289 if (setting.primary_pattern == pattern) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 #else | 334 #else |
331 feature_list_.InitWithFeatures( | 335 feature_list_.InitWithFeatures( |
332 {features::kPreferHtmlOverPlugins}, | 336 {features::kPreferHtmlOverPlugins}, |
333 {features::kAllowFullscreenWebNotificationsFeature}); | 337 {features::kAllowFullscreenWebNotificationsFeature}); |
334 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) | 338 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) |
335 } | 339 } |
336 | 340 |
337 void NotificationsTest::DropOriginPreference(const GURL& origin) { | 341 void NotificationsTest::DropOriginPreference(const GURL& origin) { |
338 DesktopNotificationProfileUtil::ClearSetting(browser()->profile(), origin); | 342 DesktopNotificationProfileUtil::ClearSetting(browser()->profile(), origin); |
339 } | 343 } |
OLD | NEW |