| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 new content::MessageLoopRunner; | 336 new content::MessageLoopRunner; |
| 337 quit_closure_ = message_loop_runner->QuitClosure(); | 337 quit_closure_ = message_loop_runner->QuitClosure(); |
| 338 cookie_store_->SetCookieWithOptionsAsync( | 338 cookie_store_->SetCookieWithOptionsAsync( |
| 339 kOrigin1, "A=1", net::CookieOptions(), | 339 kOrigin1, "A=1", net::CookieOptions(), |
| 340 base::Bind(&RemoveCookieTester::SetCookieCallback, | 340 base::Bind(&RemoveCookieTester::SetCookieCallback, |
| 341 base::Unretained(this))); | 341 base::Unretained(this))); |
| 342 message_loop_runner->Run(); | 342 message_loop_runner->Run(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 protected: | 345 protected: |
| 346 void SetMonster(net::CookieStore* monster) { | 346 void SetCookieStore(net::CookieStore* cookie_store) { |
| 347 cookie_store_ = monster; | 347 cookie_store_ = cookie_store; |
| 348 } | 348 } |
| 349 | 349 |
| 350 private: | 350 private: |
| 351 void GetCookieCallback(const std::string& cookies) { | 351 void GetCookieCallback(const std::string& cookies) { |
| 352 if (cookies == "A=1") { | 352 if (cookies == "A=1") { |
| 353 get_cookie_success_ = true; | 353 get_cookie_success_ = true; |
| 354 } else { | 354 } else { |
| 355 EXPECT_EQ("", cookies); | 355 EXPECT_EQ("", cookies); |
| 356 get_cookie_success_ = false; | 356 get_cookie_success_ = false; |
| 357 } | 357 } |
| 358 quit_closure_.Run(); | 358 quit_closure_.Run(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void SetCookieCallback(bool result) { | 361 void SetCookieCallback(bool result) { |
| 362 ASSERT_TRUE(result); | 362 ASSERT_TRUE(result); |
| 363 quit_closure_.Run(); | 363 quit_closure_.Run(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 bool get_cookie_success_ = false; | 366 bool get_cookie_success_ = false; |
| 367 base::Closure quit_closure_; | 367 base::Closure quit_closure_; |
| 368 |
| 369 // CookieStore must out live |this|. |
| 368 net::CookieStore* cookie_store_ = nullptr; | 370 net::CookieStore* cookie_store_ = nullptr; |
| 369 | 371 |
| 370 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); | 372 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); |
| 371 }; | 373 }; |
| 372 | 374 |
| 375 void RunClosureAfterCookiesCleared(const base::Closure& task, |
| 376 int cookies_deleted) { |
| 377 task.Run(); |
| 378 } |
| 379 |
| 373 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { | 380 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { |
| 374 public: | 381 public: |
| 375 RemoveSafeBrowsingCookieTester() | 382 RemoveSafeBrowsingCookieTester() |
| 376 : browser_process_(TestingBrowserProcess::GetGlobal()) { | 383 : browser_process_(TestingBrowserProcess::GetGlobal()) { |
| 377 scoped_refptr<safe_browsing::SafeBrowsingService> sb_service = | 384 scoped_refptr<safe_browsing::SafeBrowsingService> sb_service = |
| 378 safe_browsing::SafeBrowsingService::CreateSafeBrowsingService(); | 385 safe_browsing::SafeBrowsingService::CreateSafeBrowsingService(); |
| 379 browser_process_->SetSafeBrowsingService(sb_service.get()); | 386 browser_process_->SetSafeBrowsingService(sb_service.get()); |
| 380 sb_service->Initialize(); | 387 sb_service->Initialize(); |
| 381 base::MessageLoop::current()->RunUntilIdle(); | 388 base::MessageLoop::current()->RunUntilIdle(); |
| 382 | 389 |
| 383 // Create a cookiemonster that does not have persistant storage, and replace | 390 // Make sure the safe browsing cookie store has no cookies. |
| 384 // the SafeBrowsingService created one with it. | 391 // TODO(mmenke): Is this really needed? |
| 385 net::CookieStore* monster = | 392 base::RunLoop run_loop; |
| 386 content::CreateCookieStore(content::CookieStoreConfig()); | 393 net::URLRequestContext* request_context = |
| 387 sb_service->url_request_context()->GetURLRequestContext()-> | 394 sb_service->url_request_context()->GetURLRequestContext(); |
| 388 set_cookie_store(monster); | 395 request_context->cookie_store()->DeleteAllAsync( |
| 389 SetMonster(monster); | 396 base::Bind(&RunClosureAfterCookiesCleared, run_loop.QuitClosure())); |
| 397 run_loop.Run(); |
| 398 |
| 399 SetCookieStore(request_context->cookie_store()); |
| 390 } | 400 } |
| 391 | 401 |
| 392 virtual ~RemoveSafeBrowsingCookieTester() { | 402 virtual ~RemoveSafeBrowsingCookieTester() { |
| 393 browser_process_->safe_browsing_service()->ShutDown(); | 403 browser_process_->safe_browsing_service()->ShutDown(); |
| 394 base::MessageLoop::current()->RunUntilIdle(); | 404 base::MessageLoop::current()->RunUntilIdle(); |
| 395 browser_process_->SetSafeBrowsingService(nullptr); | 405 browser_process_->SetSafeBrowsingService(nullptr); |
| 396 } | 406 } |
| 397 | 407 |
| 398 private: | 408 private: |
| 399 TestingBrowserProcess* browser_process_; | 409 TestingBrowserProcess* browser_process_; |
| (...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2266 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) | 2276 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) |
| 2267 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2277 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2268 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) | 2278 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) |
| 2269 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2279 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2270 | 2280 |
| 2271 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2281 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 2272 BrowsingDataRemover::REMOVE_COOKIES | | 2282 BrowsingDataRemover::REMOVE_COOKIES | |
| 2273 BrowsingDataRemover::REMOVE_PASSWORDS, | 2283 BrowsingDataRemover::REMOVE_PASSWORDS, |
| 2274 false); | 2284 false); |
| 2275 } | 2285 } |
| OLD | NEW |