| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "components/autofill/core/browser/credit_card.h" | 42 #include "components/autofill/core/browser/credit_card.h" |
| 43 #include "components/autofill/core/browser/personal_data_manager.h" | 43 #include "components/autofill/core/browser/personal_data_manager.h" |
| 44 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 44 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 45 #include "content/public/browser/cookie_store_factory.h" | 45 #include "content/public/browser/cookie_store_factory.h" |
| 46 #include "content/public/browser/dom_storage_context.h" | 46 #include "content/public/browser/dom_storage_context.h" |
| 47 #include "content/public/browser/local_storage_usage_info.h" | 47 #include "content/public/browser/local_storage_usage_info.h" |
| 48 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
| 49 #include "content/public/browser/storage_partition.h" | 49 #include "content/public/browser/storage_partition.h" |
| 50 #include "content/public/test/test_browser_thread.h" | 50 #include "content/public/test/test_browser_thread.h" |
| 51 #include "content/public/test/test_browser_thread_bundle.h" | 51 #include "content/public/test/test_browser_thread_bundle.h" |
| 52 #include "net/cookies/cookie_store.h" |
| 52 #include "net/ssl/server_bound_cert_service.h" | 53 #include "net/ssl/server_bound_cert_service.h" |
| 53 #include "net/ssl/server_bound_cert_store.h" | 54 #include "net/ssl/server_bound_cert_store.h" |
| 54 #include "net/ssl/ssl_client_cert_type.h" | 55 #include "net/ssl/ssl_client_cert_type.h" |
| 55 #include "net/url_request/url_request_context.h" | 56 #include "net/url_request/url_request_context.h" |
| 56 #include "net/url_request/url_request_context_getter.h" | 57 #include "net/url_request/url_request_context_getter.h" |
| 57 #include "testing/gmock/include/gmock/gmock.h" | 58 #include "testing/gmock/include/gmock/gmock.h" |
| 58 #include "testing/gtest/include/gtest/gtest.h" | 59 #include "testing/gtest/include/gtest/gtest.h" |
| 59 | 60 |
| 60 using content::BrowserThread; | 61 using content::BrowserThread; |
| 61 using content::StoragePartition; | 62 using content::StoragePartition; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 229 |
| 229 DISALLOW_COPY_AND_ASSIGN(TestStoragePartition); | 230 DISALLOW_COPY_AND_ASSIGN(TestStoragePartition); |
| 230 }; | 231 }; |
| 231 | 232 |
| 232 } // namespace | 233 } // namespace |
| 233 | 234 |
| 234 // Testers ------------------------------------------------------------------- | 235 // Testers ------------------------------------------------------------------- |
| 235 | 236 |
| 236 class RemoveCookieTester { | 237 class RemoveCookieTester { |
| 237 public: | 238 public: |
| 238 RemoveCookieTester() : get_cookie_success_(false), monster_(NULL) { | 239 RemoveCookieTester() : get_cookie_success_(false), cookie_store_(NULL) { |
| 239 } | 240 } |
| 240 | 241 |
| 241 // Returns true, if the given cookie exists in the cookie store. | 242 // Returns true, if the given cookie exists in the cookie store. |
| 242 bool ContainsCookie() { | 243 bool ContainsCookie() { |
| 243 get_cookie_success_ = false; | 244 get_cookie_success_ = false; |
| 244 monster_->GetCookiesWithOptionsAsync( | 245 cookie_store_->GetCookiesWithOptionsAsync( |
| 245 kOrigin1, net::CookieOptions(), | 246 kOrigin1, net::CookieOptions(), |
| 246 base::Bind(&RemoveCookieTester::GetCookieCallback, | 247 base::Bind(&RemoveCookieTester::GetCookieCallback, |
| 247 base::Unretained(this))); | 248 base::Unretained(this))); |
| 248 await_completion_.BlockUntilNotified(); | 249 await_completion_.BlockUntilNotified(); |
| 249 return get_cookie_success_; | 250 return get_cookie_success_; |
| 250 } | 251 } |
| 251 | 252 |
| 252 void AddCookie() { | 253 void AddCookie() { |
| 253 monster_->SetCookieWithOptionsAsync( | 254 cookie_store_->SetCookieWithOptionsAsync( |
| 254 kOrigin1, "A=1", net::CookieOptions(), | 255 kOrigin1, "A=1", net::CookieOptions(), |
| 255 base::Bind(&RemoveCookieTester::SetCookieCallback, | 256 base::Bind(&RemoveCookieTester::SetCookieCallback, |
| 256 base::Unretained(this))); | 257 base::Unretained(this))); |
| 257 await_completion_.BlockUntilNotified(); | 258 await_completion_.BlockUntilNotified(); |
| 258 } | 259 } |
| 259 | 260 |
| 260 protected: | 261 protected: |
| 261 void SetMonster(net::CookieStore* monster) { | 262 void SetMonster(net::CookieStore* monster) { |
| 262 monster_ = monster; | 263 cookie_store_ = monster; |
| 263 } | 264 } |
| 264 | 265 |
| 265 private: | 266 private: |
| 266 void GetCookieCallback(const std::string& cookies) { | 267 void GetCookieCallback(const std::string& cookies) { |
| 267 if (cookies == "A=1") { | 268 if (cookies == "A=1") { |
| 268 get_cookie_success_ = true; | 269 get_cookie_success_ = true; |
| 269 } else { | 270 } else { |
| 270 EXPECT_EQ("", cookies); | 271 EXPECT_EQ("", cookies); |
| 271 get_cookie_success_ = false; | 272 get_cookie_success_ = false; |
| 272 } | 273 } |
| 273 await_completion_.Notify(); | 274 await_completion_.Notify(); |
| 274 } | 275 } |
| 275 | 276 |
| 276 void SetCookieCallback(bool result) { | 277 void SetCookieCallback(bool result) { |
| 277 ASSERT_TRUE(result); | 278 ASSERT_TRUE(result); |
| 278 await_completion_.Notify(); | 279 await_completion_.Notify(); |
| 279 } | 280 } |
| 280 | 281 |
| 281 bool get_cookie_success_; | 282 bool get_cookie_success_; |
| 282 AwaitCompletionHelper await_completion_; | 283 AwaitCompletionHelper await_completion_; |
| 283 net::CookieStore* monster_; | 284 net::CookieStore* cookie_store_; |
| 284 | 285 |
| 285 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); | 286 DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); |
| 286 }; | 287 }; |
| 287 | 288 |
| 288 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 289 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
| 289 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { | 290 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { |
| 290 public: | 291 public: |
| 291 RemoveSafeBrowsingCookieTester() | 292 RemoveSafeBrowsingCookieTester() |
| 292 : browser_process_(TestingBrowserProcess::GetGlobal()) { | 293 : browser_process_(TestingBrowserProcess::GetGlobal()) { |
| 293 scoped_refptr<SafeBrowsingService> sb_service = | 294 scoped_refptr<SafeBrowsingService> sb_service = |
| 294 SafeBrowsingService::CreateSafeBrowsingService(); | 295 SafeBrowsingService::CreateSafeBrowsingService(); |
| 295 browser_process_->SetSafeBrowsingService(sb_service.get()); | 296 browser_process_->SetSafeBrowsingService(sb_service.get()); |
| 296 sb_service->Initialize(); | 297 sb_service->Initialize(); |
| 297 base::MessageLoop::current()->RunUntilIdle(); | 298 base::MessageLoop::current()->RunUntilIdle(); |
| 298 | 299 |
| 299 // Create a cookiemonster that does not have persistant storage, and replace | 300 // Create a cookiemonster that does not have persistant storage, and replace |
| 300 // the SafeBrowsingService created one with it. | 301 // the SafeBrowsingService created one with it. |
| 301 net::CookieStore* monster = content::CreateInMemoryCookieStore(NULL); | 302 net::CookieStore* monster = |
| 303 content::CreateCookieStore(content::CookieStoreConfig()); |
| 302 sb_service->url_request_context()->GetURLRequestContext()-> | 304 sb_service->url_request_context()->GetURLRequestContext()-> |
| 303 set_cookie_store(monster); | 305 set_cookie_store(monster); |
| 304 SetMonster(monster); | 306 SetMonster(monster); |
| 305 } | 307 } |
| 306 | 308 |
| 307 virtual ~RemoveSafeBrowsingCookieTester() { | 309 virtual ~RemoveSafeBrowsingCookieTester() { |
| 308 browser_process_->safe_browsing_service()->ShutDown(); | 310 browser_process_->safe_browsing_service()->ShutDown(); |
| 309 base::MessageLoop::current()->RunUntilIdle(); | 311 base::MessageLoop::current()->RunUntilIdle(); |
| 310 browser_process_->SetSafeBrowsingService(NULL); | 312 browser_process_->SetSafeBrowsingService(NULL); |
| 311 } | 313 } |
| (...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 EXPECT_CALL(*cryptohome_client, TpmAttestationDeleteKeys(_, _, _, _)) | 1592 EXPECT_CALL(*cryptohome_client, TpmAttestationDeleteKeys(_, _, _, _)) |
| 1591 .WillOnce(WithArgs<3>(Invoke(FakeDBusCall))); | 1593 .WillOnce(WithArgs<3>(Invoke(FakeDBusCall))); |
| 1592 | 1594 |
| 1593 BlockUntilBrowsingDataRemoved( | 1595 BlockUntilBrowsingDataRemoved( |
| 1594 BrowsingDataRemover::EVERYTHING, | 1596 BrowsingDataRemover::EVERYTHING, |
| 1595 BrowsingDataRemover::REMOVE_CONTENT_LICENSES, false); | 1597 BrowsingDataRemover::REMOVE_CONTENT_LICENSES, false); |
| 1596 | 1598 |
| 1597 chromeos::DBusThreadManager::Shutdown(); | 1599 chromeos::DBusThreadManager::Shutdown(); |
| 1598 } | 1600 } |
| 1599 #endif | 1601 #endif |
| OLD | NEW |