| 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 <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 class AwaitCompletionHelper : public BrowsingDataRemover::Observer { | 127 class AwaitCompletionHelper : public BrowsingDataRemover::Observer { |
| 128 public: | 128 public: |
| 129 AwaitCompletionHelper() : start_(false), already_quit_(false) {} | 129 AwaitCompletionHelper() : start_(false), already_quit_(false) {} |
| 130 virtual ~AwaitCompletionHelper() {} | 130 virtual ~AwaitCompletionHelper() {} |
| 131 | 131 |
| 132 void BlockUntilNotified() { | 132 void BlockUntilNotified() { |
| 133 if (!already_quit_) { | 133 if (!already_quit_) { |
| 134 DCHECK(!start_); | 134 DCHECK(!start_); |
| 135 start_ = true; | 135 start_ = true; |
| 136 MessageLoop::current()->Run(); | 136 base::MessageLoop::current()->Run(); |
| 137 } else { | 137 } else { |
| 138 DCHECK(!start_); | 138 DCHECK(!start_); |
| 139 already_quit_ = false; | 139 already_quit_ = false; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void Notify() { | 143 void Notify() { |
| 144 if (start_) { | 144 if (start_) { |
| 145 DCHECK(!already_quit_); | 145 DCHECK(!already_quit_); |
| 146 MessageLoop::current()->Quit(); | 146 base::MessageLoop::current()->Quit(); |
| 147 start_ = false; | 147 start_ = false; |
| 148 } else { | 148 } else { |
| 149 DCHECK(!already_quit_); | 149 DCHECK(!already_quit_); |
| 150 already_quit_ = true; | 150 already_quit_ = true; |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 protected: | 154 protected: |
| 155 // BrowsingDataRemover::Observer implementation. | 155 // BrowsingDataRemover::Observer implementation. |
| 156 virtual void OnBrowsingDataRemoverDone() OVERRIDE { | 156 virtual void OnBrowsingDataRemoverDone() OVERRIDE { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 234 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
| 235 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { | 235 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { |
| 236 public: | 236 public: |
| 237 RemoveSafeBrowsingCookieTester() | 237 RemoveSafeBrowsingCookieTester() |
| 238 : browser_process_(TestingBrowserProcess::GetGlobal()) { | 238 : browser_process_(TestingBrowserProcess::GetGlobal()) { |
| 239 scoped_refptr<SafeBrowsingService> sb_service = | 239 scoped_refptr<SafeBrowsingService> sb_service = |
| 240 SafeBrowsingService::CreateSafeBrowsingService(); | 240 SafeBrowsingService::CreateSafeBrowsingService(); |
| 241 browser_process_->SetSafeBrowsingService(sb_service); | 241 browser_process_->SetSafeBrowsingService(sb_service); |
| 242 sb_service->Initialize(); | 242 sb_service->Initialize(); |
| 243 MessageLoop::current()->RunUntilIdle(); | 243 base::MessageLoop::current()->RunUntilIdle(); |
| 244 | 244 |
| 245 // Create a cookiemonster that does not have persistant storage, and replace | 245 // Create a cookiemonster that does not have persistant storage, and replace |
| 246 // the SafeBrowsingService created one with it. | 246 // the SafeBrowsingService created one with it. |
| 247 net::CookieStore* monster = new net::CookieMonster(NULL, NULL); | 247 net::CookieStore* monster = new net::CookieMonster(NULL, NULL); |
| 248 sb_service->url_request_context()->GetURLRequestContext()-> | 248 sb_service->url_request_context()->GetURLRequestContext()-> |
| 249 set_cookie_store(monster); | 249 set_cookie_store(monster); |
| 250 SetMonster(monster); | 250 SetMonster(monster); |
| 251 } | 251 } |
| 252 | 252 |
| 253 virtual ~RemoveSafeBrowsingCookieTester() { | 253 virtual ~RemoveSafeBrowsingCookieTester() { |
| 254 browser_process_->safe_browsing_service()->ShutDown(); | 254 browser_process_->safe_browsing_service()->ShutDown(); |
| 255 MessageLoop::current()->RunUntilIdle(); | 255 base::MessageLoop::current()->RunUntilIdle(); |
| 256 browser_process_->SetSafeBrowsingService(NULL); | 256 browser_process_->SetSafeBrowsingService(NULL); |
| 257 } | 257 } |
| 258 | 258 |
| 259 private: | 259 private: |
| 260 TestingBrowserProcess* browser_process_; | 260 TestingBrowserProcess* browser_process_; |
| 261 | 261 |
| 262 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester); | 262 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester); |
| 263 }; | 263 }; |
| 264 #endif | 264 #endif |
| 265 | 265 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 profile.SetRawInfo(autofill::EMAIL_ADDRESS, | 436 profile.SetRawInfo(autofill::EMAIL_ADDRESS, |
| 437 ASCIIToUTF16("sue@example.com")); | 437 ASCIIToUTF16("sue@example.com")); |
| 438 profile.SetRawInfo(autofill::COMPANY_NAME, ASCIIToUTF16("Company X")); | 438 profile.SetRawInfo(autofill::COMPANY_NAME, ASCIIToUTF16("Company X")); |
| 439 profiles.push_back(profile); | 439 profiles.push_back(profile); |
| 440 | 440 |
| 441 profile.set_guid(base::GenerateGUID()); | 441 profile.set_guid(base::GenerateGUID()); |
| 442 profile.set_origin(kChromeOrigin); | 442 profile.set_origin(kChromeOrigin); |
| 443 profiles.push_back(profile); | 443 profiles.push_back(profile); |
| 444 | 444 |
| 445 personal_data_manager_->SetProfiles(&profiles); | 445 personal_data_manager_->SetProfiles(&profiles); |
| 446 MessageLoop::current()->Run(); | 446 base::MessageLoop::current()->Run(); |
| 447 | 447 |
| 448 std::vector<autofill::CreditCard> cards; | 448 std::vector<autofill::CreditCard> cards; |
| 449 autofill::CreditCard card; | 449 autofill::CreditCard card; |
| 450 card.set_guid(base::GenerateGUID()); | 450 card.set_guid(base::GenerateGUID()); |
| 451 card.set_origin(kWebOrigin); | 451 card.set_origin(kWebOrigin); |
| 452 card.SetRawInfo(autofill::CREDIT_CARD_NUMBER, | 452 card.SetRawInfo(autofill::CREDIT_CARD_NUMBER, |
| 453 ASCIIToUTF16("1234-5678-9012-3456")); | 453 ASCIIToUTF16("1234-5678-9012-3456")); |
| 454 cards.push_back(card); | 454 cards.push_back(card); |
| 455 | 455 |
| 456 card.set_guid(base::GenerateGUID()); | 456 card.set_guid(base::GenerateGUID()); |
| 457 card.set_origin(kChromeOrigin); | 457 card.set_origin(kChromeOrigin); |
| 458 cards.push_back(card); | 458 cards.push_back(card); |
| 459 | 459 |
| 460 personal_data_manager_->SetCreditCards(&cards); | 460 personal_data_manager_->SetCreditCards(&cards); |
| 461 MessageLoop::current()->Run(); | 461 base::MessageLoop::current()->Run(); |
| 462 } | 462 } |
| 463 | 463 |
| 464 private: | 464 private: |
| 465 virtual void OnPersonalDataChanged() OVERRIDE { | 465 virtual void OnPersonalDataChanged() OVERRIDE { |
| 466 MessageLoop::current()->Quit(); | 466 base::MessageLoop::current()->Quit(); |
| 467 } | 467 } |
| 468 | 468 |
| 469 autofill::PersonalDataManager* personal_data_manager_; | 469 autofill::PersonalDataManager* personal_data_manager_; |
| 470 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester); | 470 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester); |
| 471 }; | 471 }; |
| 472 | 472 |
| 473 class RemoveLocalStorageTester { | 473 class RemoveLocalStorageTester { |
| 474 public: | 474 public: |
| 475 explicit RemoveLocalStorageTester(TestingProfile* profile) | 475 explicit RemoveLocalStorageTester(TestingProfile* profile) |
| 476 : profile_(profile), dom_storage_context_(NULL) { | 476 : profile_(profile), dom_storage_context_(NULL) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 648 |
| 649 registrar_.RemoveAll(); | 649 registrar_.RemoveAll(); |
| 650 } | 650 } |
| 651 | 651 |
| 652 private: | 652 private: |
| 653 scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_; | 653 scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_; |
| 654 content::NotificationRegistrar registrar_; | 654 content::NotificationRegistrar registrar_; |
| 655 | 655 |
| 656 // message_loop_, as well as all the threads associated with it must be | 656 // message_loop_, as well as all the threads associated with it must be |
| 657 // defined before profile_ to prevent explosions. Oh how I love C++. | 657 // defined before profile_ to prevent explosions. Oh how I love C++. |
| 658 MessageLoopForUI message_loop_; | 658 base::MessageLoopForUI message_loop_; |
| 659 content::TestBrowserThread ui_thread_; | 659 content::TestBrowserThread ui_thread_; |
| 660 content::TestBrowserThread db_thread_; | 660 content::TestBrowserThread db_thread_; |
| 661 content::TestBrowserThread webkit_thread_; | 661 content::TestBrowserThread webkit_thread_; |
| 662 content::TestBrowserThread file_thread_; | 662 content::TestBrowserThread file_thread_; |
| 663 content::TestBrowserThread file_user_blocking_thread_; | 663 content::TestBrowserThread file_user_blocking_thread_; |
| 664 content::TestBrowserThread io_thread_; | 664 content::TestBrowserThread io_thread_; |
| 665 scoped_ptr<TestingProfile> profile_; | 665 scoped_ptr<TestingProfile> profile_; |
| 666 scoped_refptr<quota::MockQuotaManager> quota_manager_; | 666 scoped_refptr<quota::MockQuotaManager> quota_manager_; |
| 667 | 667 |
| 668 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); | 668 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 BlockUntilBrowsingDataRemoved( | 1392 BlockUntilBrowsingDataRemoved( |
| 1393 BrowsingDataRemover::LAST_HOUR, | 1393 BrowsingDataRemover::LAST_HOUR, |
| 1394 BrowsingDataRemover::REMOVE_HISTORY, false); | 1394 BrowsingDataRemover::REMOVE_HISTORY, false); |
| 1395 | 1395 |
| 1396 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1396 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
| 1397 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); | 1397 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); |
| 1398 EXPECT_TRUE(tester.HasOrigin(std::string())); | 1398 EXPECT_TRUE(tester.HasOrigin(std::string())); |
| 1399 EXPECT_FALSE(tester.HasOrigin(kWebOrigin)); | 1399 EXPECT_FALSE(tester.HasOrigin(kWebOrigin)); |
| 1400 EXPECT_TRUE(tester.HasOrigin(kChromeOrigin)); | 1400 EXPECT_TRUE(tester.HasOrigin(kChromeOrigin)); |
| 1401 } | 1401 } |
| OLD | NEW |