| 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 SetCookieStore(net::CookieStore* cookie_store) { |
| 380 cookie_store_ = monster; | 380 cookie_store_ = cookie_store; |
| 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 |
| 402 // CookieStore must out live |this|. |
| 401 net::CookieStore* cookie_store_ = nullptr; | 403 net::CookieStore* cookie_store_ = nullptr; |
| 402 | 404 |
| 403 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); | 405 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); |
| 404 }; | 406 }; |
| 405 | 407 |
| 408 void RunClosureAfterCookiesCleared(const base::Closure& task, |
| 409 int cookies_deleted) { |
| 410 task.Run(); |
| 411 } |
| 412 |
| 406 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { | 413 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { |
| 407 public: | 414 public: |
| 408 RemoveSafeBrowsingCookieTester() | 415 RemoveSafeBrowsingCookieTester() |
| 409 : browser_process_(TestingBrowserProcess::GetGlobal()) { | 416 : browser_process_(TestingBrowserProcess::GetGlobal()) { |
| 410 scoped_refptr<safe_browsing::SafeBrowsingService> sb_service = | 417 scoped_refptr<safe_browsing::SafeBrowsingService> sb_service = |
| 411 safe_browsing::SafeBrowsingService::CreateSafeBrowsingService(); | 418 safe_browsing::SafeBrowsingService::CreateSafeBrowsingService(); |
| 412 browser_process_->SetSafeBrowsingService(sb_service.get()); | 419 browser_process_->SetSafeBrowsingService(sb_service.get()); |
| 413 sb_service->Initialize(); | 420 sb_service->Initialize(); |
| 414 base::MessageLoop::current()->RunUntilIdle(); | 421 base::MessageLoop::current()->RunUntilIdle(); |
| 415 | 422 |
| 416 // Create a cookiemonster that does not have persistant storage, and replace | 423 // Make sure the safe browsing cookie store has no cookies. |
| 417 // the SafeBrowsingService created one with it. | 424 // TODO(mmenke): Is this really needed? |
| 418 net::CookieStore* monster = | 425 base::RunLoop run_loop; |
| 419 content::CreateCookieStore(content::CookieStoreConfig()); | 426 net::URLRequestContext* request_context = |
| 420 sb_service->url_request_context()->GetURLRequestContext()-> | 427 sb_service->url_request_context()->GetURLRequestContext(); |
| 421 set_cookie_store(monster); | 428 request_context->cookie_store()->DeleteAllAsync( |
| 422 SetMonster(monster); | 429 base::Bind(&RunClosureAfterCookiesCleared, run_loop.QuitClosure())); |
| 430 run_loop.Run(); |
| 431 |
| 432 SetCookieStore(request_context->cookie_store()); |
| 423 } | 433 } |
| 424 | 434 |
| 425 virtual ~RemoveSafeBrowsingCookieTester() { | 435 virtual ~RemoveSafeBrowsingCookieTester() { |
| 426 browser_process_->safe_browsing_service()->ShutDown(); | 436 browser_process_->safe_browsing_service()->ShutDown(); |
| 427 base::MessageLoop::current()->RunUntilIdle(); | 437 base::MessageLoop::current()->RunUntilIdle(); |
| 428 browser_process_->SetSafeBrowsingService(nullptr); | 438 browser_process_->SetSafeBrowsingService(nullptr); |
| 429 } | 439 } |
| 430 | 440 |
| 431 private: | 441 private: |
| 432 TestingBrowserProcess* browser_process_; | 442 TestingBrowserProcess* browser_process_; |
| (...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 EXPECT_CALL(*tester.store(), RemoveLoginsCreatedBetweenImpl(_, _)) | 2304 EXPECT_CALL(*tester.store(), RemoveLoginsCreatedBetweenImpl(_, _)) |
| 2295 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2305 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2296 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) | 2306 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) |
| 2297 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2307 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2298 | 2308 |
| 2299 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2309 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 2300 BrowsingDataRemover::REMOVE_COOKIES | | 2310 BrowsingDataRemover::REMOVE_COOKIES | |
| 2301 BrowsingDataRemover::REMOVE_PASSWORDS, | 2311 BrowsingDataRemover::REMOVE_PASSWORDS, |
| 2302 false); | 2312 false); |
| 2303 } | 2313 } |
| OLD | NEW |