| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <memory> | 6 #include <memory> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 class BrowsingDataRemoverTransportSecurityStateBrowserTest | 157 class BrowsingDataRemoverTransportSecurityStateBrowserTest |
| 158 : public BrowsingDataRemoverBrowserTest { | 158 : public BrowsingDataRemoverBrowserTest { |
| 159 public: | 159 public: |
| 160 BrowsingDataRemoverTransportSecurityStateBrowserTest() {} | 160 BrowsingDataRemoverTransportSecurityStateBrowserTest() {} |
| 161 | 161 |
| 162 void SetUpOnMainThread() override { | 162 void SetUpOnMainThread() override { |
| 163 BrowserThread::PostTask( | 163 BrowserThread::PostTask( |
| 164 BrowserThread::IO, FROM_HERE, | 164 BrowserThread::IO, FROM_HERE, |
| 165 base::Bind(&BrowsingDataRemoverTransportSecurityStateBrowserTest:: | 165 base::BindOnce( |
| 166 SetUpTransportSecurityState, | 166 &BrowsingDataRemoverTransportSecurityStateBrowserTest:: |
| 167 base::Unretained(this), | 167 SetUpTransportSecurityState, |
| 168 base::RetainedRef( | 168 base::Unretained(this), |
| 169 browser()->profile()->GetRequestContext()))); | 169 base::RetainedRef(browser()->profile()->GetRequestContext()))); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void CheckTransportSecurityState( | 172 void CheckTransportSecurityState( |
| 173 scoped_refptr<net::URLRequestContextGetter> context_getter, | 173 scoped_refptr<net::URLRequestContextGetter> context_getter, |
| 174 bool should_be_cleared) { | 174 bool should_be_cleared) { |
| 175 net::TransportSecurityState* state = | 175 net::TransportSecurityState* state = |
| 176 context_getter->GetURLRequestContext()->transport_security_state(); | 176 context_getter->GetURLRequestContext()->transport_security_state(); |
| 177 if (should_be_cleared) | 177 if (should_be_cleared) |
| 178 EXPECT_FALSE(state->ShouldUpgradeToSSL("example.test")); | 178 EXPECT_FALSE(state->ShouldUpgradeToSSL("example.test")); |
| 179 else | 179 else |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 ASSERT_EQ(ExternalProtocolHandler::UNKNOWN, block_state); | 291 ASSERT_EQ(ExternalProtocolHandler::UNKNOWN, block_state); |
| 292 } | 292 } |
| 293 | 293 |
| 294 // Verify that TransportSecurityState data is cleared for REMOVE_CACHE. | 294 // Verify that TransportSecurityState data is cleared for REMOVE_CACHE. |
| 295 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverTransportSecurityStateBrowserTest, | 295 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverTransportSecurityStateBrowserTest, |
| 296 ClearTransportSecurityState) { | 296 ClearTransportSecurityState) { |
| 297 RemoveAndWait(BrowsingDataRemover::DATA_TYPE_CACHE); | 297 RemoveAndWait(BrowsingDataRemover::DATA_TYPE_CACHE); |
| 298 base::RunLoop run_loop; | 298 base::RunLoop run_loop; |
| 299 BrowserThread::PostTaskAndReply( | 299 BrowserThread::PostTaskAndReply( |
| 300 BrowserThread::IO, FROM_HERE, | 300 BrowserThread::IO, FROM_HERE, |
| 301 base::Bind(&BrowsingDataRemoverTransportSecurityStateBrowserTest:: | 301 base::BindOnce( |
| 302 CheckTransportSecurityState, | 302 &BrowsingDataRemoverTransportSecurityStateBrowserTest:: |
| 303 base::Unretained(this), | 303 CheckTransportSecurityState, |
| 304 base::RetainedRef(browser()->profile()->GetRequestContext()), | 304 base::Unretained(this), |
| 305 true /* should be cleared */), | 305 base::RetainedRef(browser()->profile()->GetRequestContext()), |
| 306 true /* should be cleared */), |
| 306 run_loop.QuitClosure()); | 307 run_loop.QuitClosure()); |
| 307 } | 308 } |
| 308 | 309 |
| 309 // Verify that TransportSecurityState data is not cleared if REMOVE_CACHE is not | 310 // Verify that TransportSecurityState data is not cleared if REMOVE_CACHE is not |
| 310 // set. | 311 // set. |
| 311 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverTransportSecurityStateBrowserTest, | 312 IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverTransportSecurityStateBrowserTest, |
| 312 PreserveTransportSecurityState) { | 313 PreserveTransportSecurityState) { |
| 313 RemoveAndWait(ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA); | 314 RemoveAndWait(ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA); |
| 314 base::RunLoop run_loop; | 315 base::RunLoop run_loop; |
| 315 BrowserThread::PostTaskAndReply( | 316 BrowserThread::PostTaskAndReply( |
| 316 BrowserThread::IO, FROM_HERE, | 317 BrowserThread::IO, FROM_HERE, |
| 317 base::Bind(&BrowsingDataRemoverTransportSecurityStateBrowserTest:: | 318 base::BindOnce( |
| 318 CheckTransportSecurityState, | 319 &BrowsingDataRemoverTransportSecurityStateBrowserTest:: |
| 319 base::Unretained(this), | 320 CheckTransportSecurityState, |
| 320 base::RetainedRef(browser()->profile()->GetRequestContext()), | 321 base::Unretained(this), |
| 321 false /* should not be cleared */), | 322 base::RetainedRef(browser()->profile()->GetRequestContext()), |
| 323 false /* should not be cleared */), |
| 322 run_loop.QuitClosure()); | 324 run_loop.QuitClosure()); |
| 323 } | 325 } |
| OLD | NEW |