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 <set> | 10 #include <set> |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 new content::MessageLoopRunner; | 369 new content::MessageLoopRunner; |
370 quit_closure_ = message_loop_runner->QuitClosure(); | 370 quit_closure_ = message_loop_runner->QuitClosure(); |
371 cookie_store_->SetCookieWithOptionsAsync( | 371 cookie_store_->SetCookieWithOptionsAsync( |
372 kOrigin1, "A=1", net::CookieOptions(), | 372 kOrigin1, "A=1", net::CookieOptions(), |
373 base::Bind(&RemoveCookieTester::SetCookieCallback, | 373 base::Bind(&RemoveCookieTester::SetCookieCallback, |
374 base::Unretained(this))); | 374 base::Unretained(this))); |
375 message_loop_runner->Run(); | 375 message_loop_runner->Run(); |
376 } | 376 } |
377 | 377 |
378 protected: | 378 protected: |
379 void SetMonster(net::CookieStore* monster) { | 379 void SetMonster(scoped_ptr<net::CookieStore> monster) { |
380 cookie_store_ = monster; | 380 cookie_store_ = std::move(monster); |
381 } | 381 } |
382 | 382 |
383 private: | 383 private: |
384 void GetCookieCallback(const std::string& cookies) { | 384 void GetCookieCallback(const std::string& cookies) { |
385 if (cookies == "A=1") { | 385 if (cookies == "A=1") { |
386 get_cookie_success_ = true; | 386 get_cookie_success_ = true; |
387 } else { | 387 } else { |
388 EXPECT_EQ("", cookies); | 388 EXPECT_EQ("", cookies); |
389 get_cookie_success_ = false; | 389 get_cookie_success_ = false; |
390 } | 390 } |
391 quit_closure_.Run(); | 391 quit_closure_.Run(); |
392 } | 392 } |
393 | 393 |
394 void SetCookieCallback(bool result) { | 394 void SetCookieCallback(bool result) { |
395 ASSERT_TRUE(result); | 395 ASSERT_TRUE(result); |
396 quit_closure_.Run(); | 396 quit_closure_.Run(); |
397 } | 397 } |
398 | 398 |
399 bool get_cookie_success_ = false; | 399 bool get_cookie_success_ = false; |
400 base::Closure quit_closure_; | 400 base::Closure quit_closure_; |
401 net::CookieStore* cookie_store_ = nullptr; | 401 scoped_ptr<net::CookieStore> cookie_store_; |
402 | 402 |
403 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); | 403 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); |
404 }; | 404 }; |
405 | 405 |
406 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { | 406 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { |
407 public: | 407 public: |
408 RemoveSafeBrowsingCookieTester() | 408 RemoveSafeBrowsingCookieTester() |
409 : browser_process_(TestingBrowserProcess::GetGlobal()) { | 409 : browser_process_(TestingBrowserProcess::GetGlobal()) { |
410 scoped_refptr<safe_browsing::SafeBrowsingService> sb_service = | 410 scoped_refptr<safe_browsing::SafeBrowsingService> sb_service = |
411 safe_browsing::SafeBrowsingService::CreateSafeBrowsingService(); | 411 safe_browsing::SafeBrowsingService::CreateSafeBrowsingService(); |
412 browser_process_->SetSafeBrowsingService(sb_service.get()); | 412 browser_process_->SetSafeBrowsingService(sb_service.get()); |
413 sb_service->Initialize(); | 413 sb_service->Initialize(); |
414 base::MessageLoop::current()->RunUntilIdle(); | 414 base::MessageLoop::current()->RunUntilIdle(); |
415 | 415 |
416 // Create a cookiemonster that does not have persistant storage, and replace | 416 // Create a cookiemonster that does not have persistant storage, and replace |
417 // the SafeBrowsingService created one with it. | 417 // the SafeBrowsingService created one with it. |
418 net::CookieStore* monster = | 418 scoped_ptr<net::CookieStore> monster = |
419 content::CreateCookieStore(content::CookieStoreConfig()); | 419 content::CreateCookieStore(content::CookieStoreConfig()); |
420 sb_service->url_request_context()->GetURLRequestContext()-> | 420 sb_service->url_request_context()->GetURLRequestContext()->set_cookie_store( |
421 set_cookie_store(monster); | 421 monster.get()); |
422 SetMonster(monster); | 422 SetMonster(std::move(monster)); |
Randy Smith (Not in Mondays)
2016/03/01 20:48:43
You look to be changing the deletion semantics of
mmenke
2016/03/01 22:44:45
Hrm...Actually, I'm not sure we even need to creat
| |
423 } | 423 } |
424 | 424 |
425 virtual ~RemoveSafeBrowsingCookieTester() { | 425 virtual ~RemoveSafeBrowsingCookieTester() { |
426 browser_process_->safe_browsing_service()->ShutDown(); | 426 browser_process_->safe_browsing_service()->ShutDown(); |
427 base::MessageLoop::current()->RunUntilIdle(); | 427 base::MessageLoop::current()->RunUntilIdle(); |
428 browser_process_->SetSafeBrowsingService(nullptr); | 428 browser_process_->SetSafeBrowsingService(nullptr); |
429 } | 429 } |
430 | 430 |
431 private: | 431 private: |
432 TestingBrowserProcess* browser_process_; | 432 TestingBrowserProcess* browser_process_; |
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2270 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { | 2270 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { |
2271 RemovePasswordsTester tester(GetProfile()); | 2271 RemovePasswordsTester tester(GetProfile()); |
2272 const url::Origin expectedOrigin(kOrigin1); | 2272 const url::Origin expectedOrigin(kOrigin1); |
2273 | 2273 |
2274 EXPECT_CALL(*tester.store(), | 2274 EXPECT_CALL(*tester.store(), |
2275 RemoveLoginsByOriginAndTimeImpl(SameOrigin(expectedOrigin), _, _)) | 2275 RemoveLoginsByOriginAndTimeImpl(SameOrigin(expectedOrigin), _, _)) |
2276 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2276 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2277 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, | 2277 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
2278 BrowsingDataRemover::REMOVE_PASSWORDS, kOrigin1); | 2278 BrowsingDataRemover::REMOVE_PASSWORDS, kOrigin1); |
2279 } | 2279 } |
OLD | NEW |