| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 36 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 37 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" | 37 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" |
| 38 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 38 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 39 #include "chrome/browser/domain_reliability/service_factory.h" | 39 #include "chrome/browser/domain_reliability/service_factory.h" |
| 40 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 40 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 41 #include "chrome/browser/favicon/favicon_service_factory.h" | 41 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 42 #include "chrome/browser/history/history_service_factory.h" | 42 #include "chrome/browser/history/history_service_factory.h" |
| 43 #include "chrome/browser/password_manager/password_store_factory.h" | 43 #include "chrome/browser/password_manager/password_store_factory.h" |
| 44 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" | 44 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| 45 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 45 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 46 #include "chrome/browser/storage/durable_storage_permission_context.h" |
| 46 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
| 47 #include "chrome/test/base/testing_browser_process.h" | 48 #include "chrome/test/base/testing_browser_process.h" |
| 48 #include "chrome/test/base/testing_profile.h" | 49 #include "chrome/test/base/testing_profile.h" |
| 49 #include "components/autofill/core/browser/autofill_profile.h" | 50 #include "components/autofill/core/browser/autofill_profile.h" |
| 50 #include "components/autofill/core/browser/autofill_test_utils.h" | 51 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 51 #include "components/autofill/core/browser/credit_card.h" | 52 #include "components/autofill/core/browser/credit_card.h" |
| 52 #include "components/autofill/core/browser/personal_data_manager.h" | 53 #include "components/autofill/core/browser/personal_data_manager.h" |
| 53 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 54 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 54 #include "components/autofill/core/common/autofill_constants.h" | 55 #include "components/autofill/core/common/autofill_constants.h" |
| 55 #include "components/bookmarks/browser/bookmark_model.h" | 56 #include "components/bookmarks/browser/bookmark_model.h" |
| (...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 host_settings[0].primary_pattern) | 2622 host_settings[0].primary_pattern) |
| 2622 << host_settings[0].primary_pattern.ToString(); | 2623 << host_settings[0].primary_pattern.ToString(); |
| 2623 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin4), | 2624 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin4), |
| 2624 host_settings[1].primary_pattern) | 2625 host_settings[1].primary_pattern) |
| 2625 << host_settings[1].primary_pattern.ToString(); | 2626 << host_settings[1].primary_pattern.ToString(); |
| 2626 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin3), | 2627 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin3), |
| 2627 host_settings[2].primary_pattern) | 2628 host_settings[2].primary_pattern) |
| 2628 << host_settings[2].primary_pattern.ToString(); | 2629 << host_settings[2].primary_pattern.ToString(); |
| 2629 } | 2630 } |
| 2630 | 2631 |
| 2632 TEST_F(BrowsingDataRemoverTest, RemoveDurablePermission) { |
| 2633 // Add our settings. |
| 2634 HostContentSettingsMap* host_content_settings_map = |
| 2635 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2636 |
| 2637 DurableStoragePermissionContext durable_permission(GetProfile()); |
| 2638 durable_permission.UpdateContentSetting(kOrigin1, GURL(), |
| 2639 CONTENT_SETTING_ALLOW); |
| 2640 durable_permission.UpdateContentSetting(kOrigin2, GURL(), |
| 2641 CONTENT_SETTING_ALLOW); |
| 2642 |
| 2643 // Clear all except for origin1 and origin3. |
| 2644 RegistrableDomainFilterBuilder filter( |
| 2645 RegistrableDomainFilterBuilder::BLACKLIST); |
| 2646 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
| 2647 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
| 2648 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, |
| 2649 BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, |
| 2650 filter); |
| 2651 |
| 2652 EXPECT_EQ(BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, GetRemovalMask()); |
| 2653 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 2654 |
| 2655 // Verify we only have allow for the first origin. |
| 2656 ContentSettingsForOneType host_settings; |
| 2657 host_content_settings_map->GetSettingsForOneType( |
| 2658 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, std::string(), &host_settings); |
| 2659 |
| 2660 ASSERT_EQ(2u, host_settings.size()); |
| 2661 // Only the first should should have a setting. |
| 2662 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin1), |
| 2663 host_settings[0].primary_pattern) |
| 2664 << host_settings[0].primary_pattern.ToString(); |
| 2665 EXPECT_EQ(CONTENT_SETTING_ALLOW, host_settings[0].setting); |
| 2666 |
| 2667 // And our wildcard. |
| 2668 EXPECT_EQ(ContentSettingsPattern::Wildcard(), |
| 2669 host_settings[1].primary_pattern) |
| 2670 << host_settings[1].primary_pattern.ToString(); |
| 2671 EXPECT_EQ(CONTENT_SETTING_ASK, host_settings[1].setting); |
| 2672 } |
| 2673 |
| 2631 // Test that removing cookies clears HTTP auth data. | 2674 // Test that removing cookies clears HTTP auth data. |
| 2632 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemoveCookies) { | 2675 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemoveCookies) { |
| 2633 net::HttpNetworkSession* http_session = GetProfile() | 2676 net::HttpNetworkSession* http_session = GetProfile() |
| 2634 ->GetRequestContext() | 2677 ->GetRequestContext() |
| 2635 ->GetURLRequestContext() | 2678 ->GetURLRequestContext() |
| 2636 ->http_transaction_factory() | 2679 ->http_transaction_factory() |
| 2637 ->GetSession(); | 2680 ->GetSession(); |
| 2638 DCHECK(http_session); | 2681 DCHECK(http_session); |
| 2639 | 2682 |
| 2640 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); | 2683 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2998 EXPECT_TRUE(remover->is_removing()); | 3041 EXPECT_TRUE(remover->is_removing()); |
| 2999 | 3042 |
| 3000 // Add one more deletion and wait for it. | 3043 // Add one more deletion and wait for it. |
| 3001 BlockUntilBrowsingDataRemoved( | 3044 BlockUntilBrowsingDataRemoved( |
| 3002 browsing_data::ALL_TIME, | 3045 browsing_data::ALL_TIME, |
| 3003 BrowsingDataRemover::REMOVE_COOKIES, | 3046 BrowsingDataRemover::REMOVE_COOKIES, |
| 3004 BrowsingDataHelper::UNPROTECTED_WEB); | 3047 BrowsingDataHelper::UNPROTECTED_WEB); |
| 3005 | 3048 |
| 3006 EXPECT_FALSE(remover->is_removing()); | 3049 EXPECT_FALSE(remover->is_removing()); |
| 3007 } | 3050 } |
| OLD | NEW |