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 <memory> | 10 #include <memory> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 #include "content/public/browser/browser_context.h" | 70 #include "content/public/browser/browser_context.h" |
| 71 #include "content/public/browser/cookie_store_factory.h" | 71 #include "content/public/browser/cookie_store_factory.h" |
| 72 #include "content/public/browser/dom_storage_context.h" | 72 #include "content/public/browser/dom_storage_context.h" |
| 73 #include "content/public/browser/local_storage_usage_info.h" | 73 #include "content/public/browser/local_storage_usage_info.h" |
| 74 #include "content/public/browser/storage_partition.h" | 74 #include "content/public/browser/storage_partition.h" |
| 75 #include "content/public/test/mock_download_manager.h" | 75 #include "content/public/test/mock_download_manager.h" |
| 76 #include "content/public/test/test_browser_thread.h" | 76 #include "content/public/test/test_browser_thread.h" |
| 77 #include "content/public/test/test_browser_thread_bundle.h" | 77 #include "content/public/test/test_browser_thread_bundle.h" |
| 78 #include "content/public/test/test_utils.h" | 78 #include "content/public/test/test_utils.h" |
| 79 #include "net/cookies/cookie_store.h" | 79 #include "net/cookies/cookie_store.h" |
| 80 #include "net/http/http_network_session.h" | |
| 81 #include "net/http/http_transaction_factory.h" | |
| 80 #include "net/ssl/channel_id_service.h" | 82 #include "net/ssl/channel_id_service.h" |
| 81 #include "net/ssl/channel_id_store.h" | 83 #include "net/ssl/channel_id_store.h" |
| 82 #include "net/ssl/ssl_client_cert_type.h" | 84 #include "net/ssl/ssl_client_cert_type.h" |
| 83 #include "net/url_request/url_request_context.h" | 85 #include "net/url_request/url_request_context.h" |
| 84 #include "net/url_request/url_request_context_getter.h" | 86 #include "net/url_request/url_request_context_getter.h" |
| 85 #include "testing/gmock/include/gmock/gmock.h" | 87 #include "testing/gmock/include/gmock/gmock.h" |
| 86 #include "testing/gtest/include/gtest/gtest.h" | 88 #include "testing/gtest/include/gtest/gtest.h" |
| 87 #include "third_party/skia/include/core/SkBitmap.h" | 89 #include "third_party/skia/include/core/SkBitmap.h" |
| 88 #include "ui/gfx/favicon_size.h" | 90 #include "ui/gfx/favicon_size.h" |
| 89 #include "url/origin.h" | 91 #include "url/origin.h" |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 // We don't own these pointers. | 836 // We don't own these pointers. |
| 835 TestingProfile* profile_; | 837 TestingProfile* profile_; |
| 836 content::DOMStorageContext* dom_storage_context_ = nullptr; | 838 content::DOMStorageContext* dom_storage_context_ = nullptr; |
| 837 | 839 |
| 838 std::vector<content::LocalStorageUsageInfo> infos_; | 840 std::vector<content::LocalStorageUsageInfo> infos_; |
| 839 base::Closure quit_closure_; | 841 base::Closure quit_closure_; |
| 840 | 842 |
| 841 DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester); | 843 DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester); |
| 842 }; | 844 }; |
| 843 | 845 |
| 846 class ClearHTTPAuthDataTester { | |
| 847 public: | |
| 848 explicit ClearHTTPAuthDataTester(TestingProfile* profile) { | |
| 849 net::HttpNetworkSession* http_session = profile->GetRequestContext() | |
| 850 ->GetURLRequestContext() | |
| 851 ->http_transaction_factory() | |
| 852 ->GetSession(); | |
| 853 DCHECK(http_session); | |
| 854 http_auth_cache_ = http_session->http_auth_cache(); | |
| 855 | |
| 856 http_auth_cache_->Add( | |
| 857 GURL("http://foo.com"), "Realm1", net::HttpAuth::AUTH_SCHEME_BASIC, | |
| 858 "basic realm=Realm1", net::AuthCredentials(base::ASCIIToUTF16("foo"), | |
| 859 base::ASCIIToUTF16("bar")), | |
| 860 "/"); | |
| 861 } | |
| 862 | |
| 863 ~ClearHTTPAuthDataTester() { | |
| 864 GURL origin("http://foobar.com"); | |
| 865 EXPECT_EQ(nullptr, | |
| 866 http_auth_cache_->Lookup(GURL("http://foo.com"), "Realm1", | |
|
msramek
2016/08/01 14:42:37
Nit: Can you please add the same lookup to the con
| |
| 867 net::HttpAuth::AUTH_SCHEME_BASIC)); | |
| 868 } | |
| 869 | |
| 870 private: | |
| 871 net::HttpAuthCache* http_auth_cache_; | |
| 872 | |
| 873 DISALLOW_COPY_AND_ASSIGN(ClearHTTPAuthDataTester); | |
| 874 }; | |
| 875 | |
| 844 class MockDomainReliabilityService : public DomainReliabilityService { | 876 class MockDomainReliabilityService : public DomainReliabilityService { |
| 845 public: | 877 public: |
| 846 MockDomainReliabilityService() {} | 878 MockDomainReliabilityService() {} |
| 847 | 879 |
| 848 ~MockDomainReliabilityService() override {} | 880 ~MockDomainReliabilityService() override {} |
| 849 | 881 |
| 850 std::unique_ptr<DomainReliabilityMonitor> CreateMonitor( | 882 std::unique_ptr<DomainReliabilityMonitor> CreateMonitor( |
| 851 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) | 883 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) |
| 852 override { | 884 override { |
| 853 NOTREACHED(); | 885 NOTREACHED(); |
| (...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2585 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( | 2617 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2586 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 2618 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 2587 base::Bind(&MatchPrimaryPattern, http_pattern)); | 2619 base::Bind(&MatchPrimaryPattern, http_pattern)); |
| 2588 // Verify we only have one, and it's url1. | 2620 // Verify we only have one, and it's url1. |
| 2589 host_content_settings_map->GetSettingsForOneType( | 2621 host_content_settings_map->GetSettingsForOneType( |
| 2590 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); | 2622 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2591 EXPECT_EQ(1u, host_settings.size()); | 2623 EXPECT_EQ(1u, host_settings.size()); |
| 2592 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), | 2624 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), |
| 2593 host_settings[0].primary_pattern); | 2625 host_settings[0].primary_pattern); |
| 2594 } | 2626 } |
| 2627 | |
| 2628 // Test that removing cookies clears HTTP auth data. | |
| 2629 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemoveCookies) { | |
| 2630 ClearHTTPAuthDataTester tester(GetProfile()); | |
| 2631 | |
| 2632 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | |
| 2633 BrowsingDataRemover::REMOVE_COOKIES, false); | |
| 2634 } | |
| 2635 | |
| 2636 // Test that removing passwords clears HTTP auth data. | |
| 2637 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemovePasswords) { | |
| 2638 ClearHTTPAuthDataTester tester(GetProfile()); | |
| 2639 | |
| 2640 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | |
| 2641 BrowsingDataRemover::REMOVE_PASSWORDS, false); | |
| 2642 } | |
| OLD | NEW |