Chromium Code Reviews| 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 | |
|
msramek
2016/09/21 13:46:11
I don't think that's what we're verifying. Both ad
| |
| 2656 ContentSettingsForOneType host_settings; | |
| 2657 host_content_settings_map->GetSettingsForOneType( | |
| 2658 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, std::string(), &host_settings); | |
| 2659 | |
| 2660 ASSERT_TRUE(host_settings.size() >= 1u); | |
|
msramek
2016/09/21 13:46:11
This seems unnecessary given the next line.
dmurph
2016/09/21 20:37:51
Done.
| |
| 2661 EXPECT_EQ(2u, host_settings.size()); | |
| 2662 // The second origin should be deleted. | |
|
msramek
2016/09/21 13:46:11
nit: I would instead say "only the first origin sh
dmurph
2016/09/21 20:37:51
Done.
| |
| 2663 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin1), | |
| 2664 host_settings[0].primary_pattern) | |
| 2665 << host_settings[0].primary_pattern.ToString(); | |
| 2666 EXPECT_EQ(CONTENT_SETTING_ALLOW, host_settings[0].setting) | |
| 2667 << host_settings[0].primary_pattern.ToString(); | |
|
msramek
2016/09/21 13:46:11
This output seems out of place - should that be |h
dmurph
2016/09/21 20:37:51
Done.
| |
| 2668 | |
| 2669 // And our wildcard. | |
| 2670 EXPECT_EQ(ContentSettingsPattern::Wildcard(), | |
| 2671 host_settings[1].primary_pattern) | |
| 2672 << host_settings[1].primary_pattern.ToString(); | |
| 2673 EXPECT_EQ(CONTENT_SETTING_ASK, host_settings[1].setting) | |
| 2674 << host_settings[1].primary_pattern.ToString(); | |
| 2675 } | |
| 2676 | |
| 2631 // Test that removing cookies clears HTTP auth data. | 2677 // Test that removing cookies clears HTTP auth data. |
| 2632 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemoveCookies) { | 2678 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemoveCookies) { |
| 2633 net::HttpNetworkSession* http_session = GetProfile() | 2679 net::HttpNetworkSession* http_session = GetProfile() |
| 2634 ->GetRequestContext() | 2680 ->GetRequestContext() |
| 2635 ->GetURLRequestContext() | 2681 ->GetURLRequestContext() |
| 2636 ->http_transaction_factory() | 2682 ->http_transaction_factory() |
| 2637 ->GetSession(); | 2683 ->GetSession(); |
| 2638 DCHECK(http_session); | 2684 DCHECK(http_session); |
| 2639 | 2685 |
| 2640 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); | 2686 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()); | 3044 EXPECT_TRUE(remover->is_removing()); |
| 2999 | 3045 |
| 3000 // Add one more deletion and wait for it. | 3046 // Add one more deletion and wait for it. |
| 3001 BlockUntilBrowsingDataRemoved( | 3047 BlockUntilBrowsingDataRemoved( |
| 3002 browsing_data::ALL_TIME, | 3048 browsing_data::ALL_TIME, |
| 3003 BrowsingDataRemover::REMOVE_COOKIES, | 3049 BrowsingDataRemover::REMOVE_COOKIES, |
| 3004 BrowsingDataHelper::UNPROTECTED_WEB); | 3050 BrowsingDataHelper::UNPROTECTED_WEB); |
| 3005 | 3051 |
| 3006 EXPECT_FALSE(remover->is_removing()); | 3052 EXPECT_FALSE(remover->is_removing()); |
| 3007 } | 3053 } |
| OLD | NEW |