| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/barrier_closure.h" | 11 #include "base/barrier_closure.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/test/histogram_tester.h" | 18 #include "base/test/histogram_tester.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 22 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 22 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 23 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 23 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 24 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 24 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 25 #include "chrome/browser/browsing_data/chrome_browsing_data_types.h" |
| 25 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 26 #include "chrome/browser/engagement/site_engagement_service.h" | 27 #include "chrome/browser/engagement/site_engagement_service.h" |
| 27 #include "chrome/browser/gcm/fake_gcm_profile_service.h" | 28 #include "chrome/browser/gcm/fake_gcm_profile_service.h" |
| 28 #include "chrome/browser/gcm/gcm_profile_service_factory.h" | 29 #include "chrome/browser/gcm/gcm_profile_service_factory.h" |
| 29 #include "chrome/browser/lifetime/keep_alive_registry.h" | 30 #include "chrome/browser/lifetime/keep_alive_registry.h" |
| 30 #include "chrome/browser/lifetime/keep_alive_types.h" | 31 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 31 #include "chrome/browser/notifications/message_center_display_service.h" | 32 #include "chrome/browser/notifications/message_center_display_service.h" |
| 32 #include "chrome/browser/notifications/notification_test_util.h" | 33 #include "chrome/browser/notifications/notification_test_util.h" |
| 33 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 34 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 34 #include "chrome/browser/permissions/permission_request_manager.h" | 35 #include "chrome/browser/permissions/permission_request_manager.h" |
| (...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 PushMessagingBrowserTest, | 2025 PushMessagingBrowserTest, |
| 2025 ResetPushPermissionAfterClearingSiteDataUnderLegacyConditions) { | 2026 ResetPushPermissionAfterClearingSiteDataUnderLegacyConditions) { |
| 2026 std::string app_id; | 2027 std::string app_id; |
| 2027 ASSERT_NO_FATAL_FAILURE(SetupOrphanedPushSubscription(&app_id)); | 2028 ASSERT_NO_FATAL_FAILURE(SetupOrphanedPushSubscription(&app_id)); |
| 2028 | 2029 |
| 2029 // Simulate a user clearing site data (including Service Workers, crucially). | 2030 // Simulate a user clearing site data (including Service Workers, crucially). |
| 2030 BrowsingDataRemover* remover = | 2031 BrowsingDataRemover* remover = |
| 2031 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowser()->profile()); | 2032 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowser()->profile()); |
| 2032 BrowsingDataRemoverCompletionObserver observer(remover); | 2033 BrowsingDataRemoverCompletionObserver observer(remover); |
| 2033 remover->RemoveAndReply(base::Time(), base::Time::Max(), | 2034 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
| 2034 BrowsingDataRemover::REMOVE_SITE_DATA, | 2035 kBrowsingDataTypeSetSiteData, |
| 2035 BrowsingDataHelper::UNPROTECTED_WEB, &observer); | 2036 BrowsingDataHelper::UNPROTECTED_WEB, &observer); |
| 2036 observer.BlockUntilCompletion(); | 2037 observer.BlockUntilCompletion(); |
| 2037 | 2038 |
| 2038 base::RunLoop run_loop; | 2039 base::RunLoop run_loop; |
| 2039 push_service()->SetContentSettingChangedCallbackForTesting( | 2040 push_service()->SetContentSettingChangedCallbackForTesting( |
| 2040 run_loop.QuitClosure()); | 2041 run_loop.QuitClosure()); |
| 2041 // This shouldn't (asynchronously) cause a DCHECK. | 2042 // This shouldn't (asynchronously) cause a DCHECK. |
| 2042 // TODO(johnme): Get this test running on Android with legacy GCM | 2043 // TODO(johnme): Get this test running on Android with legacy GCM |
| 2043 // registrations, which have a different codepath due to sender_id being | 2044 // registrations, which have a different codepath due to sender_id being |
| 2044 // required for unsubscribing there. | 2045 // required for unsubscribing there. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | 2191 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); |
| 2191 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2192 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 2192 | 2193 |
| 2193 // After dropping the last subscription background mode is still inactive. | 2194 // After dropping the last subscription background mode is still inactive. |
| 2194 std::string script_result; | 2195 std::string script_result; |
| 2195 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 2196 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 2196 EXPECT_EQ("unsubscribe result: true", script_result); | 2197 EXPECT_EQ("unsubscribe result: true", script_result); |
| 2197 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2198 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 2198 } | 2199 } |
| 2199 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 2200 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |