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 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 PushMessagingBrowserTest, | 2049 PushMessagingBrowserTest, |
2049 ResetPushPermissionAfterClearingSiteDataUnderLegacyConditions) { | 2050 ResetPushPermissionAfterClearingSiteDataUnderLegacyConditions) { |
2050 std::string app_id; | 2051 std::string app_id; |
2051 ASSERT_NO_FATAL_FAILURE(SetupOrphanedPushSubscription(&app_id)); | 2052 ASSERT_NO_FATAL_FAILURE(SetupOrphanedPushSubscription(&app_id)); |
2052 | 2053 |
2053 // Simulate a user clearing site data (including Service Workers, crucially). | 2054 // Simulate a user clearing site data (including Service Workers, crucially). |
2054 BrowsingDataRemover* remover = | 2055 BrowsingDataRemover* remover = |
2055 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowser()->profile()); | 2056 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowser()->profile()); |
2056 BrowsingDataRemoverCompletionObserver observer(remover); | 2057 BrowsingDataRemoverCompletionObserver observer(remover); |
2057 remover->RemoveAndReply(base::Time(), base::Time::Max(), | 2058 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
2058 BrowsingDataRemover::REMOVE_SITE_DATA, | 2059 BrowsingDataTypeSetSiteData(), |
2059 BrowsingDataHelper::UNPROTECTED_WEB, &observer); | 2060 BrowsingDataHelper::UNPROTECTED_WEB, &observer); |
2060 observer.BlockUntilCompletion(); | 2061 observer.BlockUntilCompletion(); |
2061 | 2062 |
2062 base::RunLoop run_loop; | 2063 base::RunLoop run_loop; |
2063 push_service()->SetContentSettingChangedCallbackForTesting( | 2064 push_service()->SetContentSettingChangedCallbackForTesting( |
2064 run_loop.QuitClosure()); | 2065 run_loop.QuitClosure()); |
2065 // This shouldn't (asynchronously) cause a DCHECK. | 2066 // This shouldn't (asynchronously) cause a DCHECK. |
2066 // TODO(johnme): Get this test running on Android with legacy GCM | 2067 // TODO(johnme): Get this test running on Android with legacy GCM |
2067 // registrations, which have a different codepath due to sender_id being | 2068 // registrations, which have a different codepath due to sender_id being |
2068 // required for unsubscribing there. | 2069 // required for unsubscribing there. |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 push_service()->SetUnsubscribeCallbackForTesting(run_loop.QuitClosure()); | 2233 push_service()->SetUnsubscribeCallbackForTesting(run_loop.QuitClosure()); |
2233 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 2234 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
2234 EXPECT_EQ("unsubscribe result: true", script_result); | 2235 EXPECT_EQ("unsubscribe result: true", script_result); |
2235 // Background mode is only guaranteed to have updated once the unsubscribe | 2236 // Background mode is only guaranteed to have updated once the unsubscribe |
2236 // callback for testing has been run (PushSubscription.unsubscribe() usually | 2237 // callback for testing has been run (PushSubscription.unsubscribe() usually |
2237 // resolves before that, in order to avoid blocking on network retries etc). | 2238 // resolves before that, in order to avoid blocking on network retries etc). |
2238 run_loop.Run(); | 2239 run_loop.Run(); |
2239 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2240 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
2240 } | 2241 } |
2241 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 2242 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
OLD | NEW |