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" | |
23 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | |
24 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | |
25 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 22 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
27 #include "chrome/browser/engagement/site_engagement_score.h" | 24 #include "chrome/browser/engagement/site_engagement_score.h" |
28 #include "chrome/browser/engagement/site_engagement_service.h" | 25 #include "chrome/browser/engagement/site_engagement_service.h" |
29 #include "chrome/browser/gcm/fake_gcm_profile_service.h" | 26 #include "chrome/browser/gcm/fake_gcm_profile_service.h" |
30 #include "chrome/browser/gcm/gcm_profile_service_factory.h" | 27 #include "chrome/browser/gcm/gcm_profile_service_factory.h" |
31 #include "chrome/browser/gcm/instance_id/instance_id_profile_service.h" | 28 #include "chrome/browser/gcm/instance_id/instance_id_profile_service.h" |
32 #include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h" | 29 #include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h" |
33 #include "chrome/browser/lifetime/keep_alive_registry.h" | 30 #include "chrome/browser/lifetime/keep_alive_registry.h" |
34 #include "chrome/browser/lifetime/keep_alive_types.h" | 31 #include "chrome/browser/lifetime/keep_alive_types.h" |
(...skipping 12 matching lines...) Expand all Loading... |
47 #include "chrome/common/features.h" | 44 #include "chrome/common/features.h" |
48 #include "chrome/test/base/in_process_browser_test.h" | 45 #include "chrome/test/base/in_process_browser_test.h" |
49 #include "chrome/test/base/ui_test_utils.h" | 46 #include "chrome/test/base/ui_test_utils.h" |
50 #include "components/content_settings/core/browser/host_content_settings_map.h" | 47 #include "components/content_settings/core/browser/host_content_settings_map.h" |
51 #include "components/content_settings/core/common/content_settings.h" | 48 #include "components/content_settings/core/common/content_settings.h" |
52 #include "components/content_settings/core/common/content_settings_types.h" | 49 #include "components/content_settings/core/common/content_settings_types.h" |
53 #include "components/gcm_driver/common/gcm_messages.h" | 50 #include "components/gcm_driver/common/gcm_messages.h" |
54 #include "components/gcm_driver/gcm_client.h" | 51 #include "components/gcm_driver/gcm_client.h" |
55 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" | 52 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" |
56 #include "components/gcm_driver/instance_id/instance_id_driver.h" | 53 #include "components/gcm_driver/instance_id/instance_id_driver.h" |
| 54 #include "content/public/browser/browsing_data_remover.h" |
57 #include "content/public/browser/web_contents.h" | 55 #include "content/public/browser/web_contents.h" |
58 #include "content/public/common/content_switches.h" | 56 #include "content/public/common/content_switches.h" |
59 #include "content/public/common/push_subscription_options.h" | 57 #include "content/public/common/push_subscription_options.h" |
60 #include "content/public/test/browser_test_utils.h" | 58 #include "content/public/test/browser_test_utils.h" |
| 59 #include "content/public/test/browsing_data_remover_test_util.h" |
61 #include "content/public/test/test_utils.h" | 60 #include "content/public/test/test_utils.h" |
62 #include "net/test/embedded_test_server/embedded_test_server.h" | 61 #include "net/test/embedded_test_server/embedded_test_server.h" |
63 #include "testing/gmock/include/gmock/gmock.h" | 62 #include "testing/gmock/include/gmock/gmock.h" |
64 #include "ui/base/window_open_disposition.h" | 63 #include "ui/base/window_open_disposition.h" |
65 | 64 |
66 #if BUILDFLAG(ENABLE_BACKGROUND) | 65 #if BUILDFLAG(ENABLE_BACKGROUND) |
67 #include "chrome/browser/background/background_mode_manager.h" | 66 #include "chrome/browser/background/background_mode_manager.h" |
68 #endif | 67 #endif |
69 | 68 |
70 namespace { | 69 namespace { |
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 // Checks automatically unsubscribing due to a revoked permission after | 2186 // Checks automatically unsubscribing due to a revoked permission after |
2188 // previously clearing site data, under legacy conditions (ie. when | 2187 // previously clearing site data, under legacy conditions (ie. when |
2189 // unregistering a worker did not unsubscribe from push.) | 2188 // unregistering a worker did not unsubscribe from push.) |
2190 IN_PROC_BROWSER_TEST_F( | 2189 IN_PROC_BROWSER_TEST_F( |
2191 PushMessagingBrowserTest, | 2190 PushMessagingBrowserTest, |
2192 ResetPushPermissionAfterClearingSiteDataUnderLegacyConditions) { | 2191 ResetPushPermissionAfterClearingSiteDataUnderLegacyConditions) { |
2193 std::string app_id; | 2192 std::string app_id; |
2194 ASSERT_NO_FATAL_FAILURE(SetupOrphanedPushSubscription(&app_id)); | 2193 ASSERT_NO_FATAL_FAILURE(SetupOrphanedPushSubscription(&app_id)); |
2195 | 2194 |
2196 // Simulate a user clearing site data (including Service Workers, crucially). | 2195 // Simulate a user clearing site data (including Service Workers, crucially). |
2197 BrowsingDataRemover* remover = | 2196 content::BrowsingDataRemover* remover = |
2198 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowser()->profile()); | 2197 content::BrowserContext::GetBrowsingDataRemover(GetBrowser()->profile()); |
2199 BrowsingDataRemoverCompletionObserver observer(remover); | 2198 content::BrowsingDataRemoverCompletionObserver observer(remover); |
2200 remover->RemoveAndReply( | 2199 remover->RemoveAndReply( |
2201 base::Time(), base::Time::Max(), | 2200 base::Time(), base::Time::Max(), |
2202 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA, | 2201 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA, |
2203 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, &observer); | 2202 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, &observer); |
2204 observer.BlockUntilCompletion(); | 2203 observer.BlockUntilCompletion(); |
2205 | 2204 |
2206 base::RunLoop run_loop; | 2205 base::RunLoop run_loop; |
2207 push_service()->SetContentSettingChangedCallbackForTesting( | 2206 push_service()->SetContentSettingChangedCallbackForTesting( |
2208 run_loop.QuitClosure()); | 2207 run_loop.QuitClosure()); |
2209 // This shouldn't (asynchronously) cause a DCHECK. | 2208 // This shouldn't (asynchronously) cause a DCHECK. |
2210 // TODO(johnme): Get this test running on Android with legacy GCM | 2209 // TODO(johnme): Get this test running on Android with legacy GCM |
2211 // registrations, which have a different codepath due to sender_id being | 2210 // registrations, which have a different codepath due to sender_id being |
2212 // required for unsubscribing there. | 2211 // required for unsubscribing there. |
2213 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 2212 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 push_service()->SetUnsubscribeCallbackForTesting(run_loop.QuitClosure()); | 2378 push_service()->SetUnsubscribeCallbackForTesting(run_loop.QuitClosure()); |
2380 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 2379 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
2381 EXPECT_EQ("unsubscribe result: true", script_result); | 2380 EXPECT_EQ("unsubscribe result: true", script_result); |
2382 // Background mode is only guaranteed to have updated once the unsubscribe | 2381 // Background mode is only guaranteed to have updated once the unsubscribe |
2383 // callback for testing has been run (PushSubscription.unsubscribe() usually | 2382 // callback for testing has been run (PushSubscription.unsubscribe() usually |
2384 // resolves before that, in order to avoid blocking on network retries etc). | 2383 // resolves before that, in order to avoid blocking on network retries etc). |
2385 run_loop.Run(); | 2384 run_loop.Run(); |
2386 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2385 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
2387 } | 2386 } |
2388 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 2387 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
OLD | NEW |