| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_remover.h" | 5 #include "chrome/browser/browsing_data_remover.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| 11 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" | |
| 12 #include "chrome/browser/history/history.h" | 11 #include "chrome/browser/history/history.h" |
| 13 #include "chrome/test/testing_profile.h" | 12 #include "chrome/test/testing_profile.h" |
| 14 #include "content/browser/appcache/chrome_appcache_service.h" | 13 #include "content/browser/appcache/chrome_appcache_service.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webkit/appcache/appcache.h" | 15 #include "webkit/appcache/appcache.h" |
| 17 #include "webkit/appcache/appcache_group.h" | 16 #include "webkit/appcache/appcache_group.h" |
| 18 #include "webkit/appcache/appcache_storage.h" | 17 #include "webkit/appcache/appcache_storage.h" |
| 19 #include "webkit/fileapi/file_system_context.h" | 18 #include "webkit/fileapi/file_system_context.h" |
| 20 #include "webkit/fileapi/file_system_operation_context.h" | 19 #include "webkit/fileapi/file_system_operation_context.h" |
| 21 #include "webkit/fileapi/file_system_file_util.h" | 20 #include "webkit/fileapi/file_system_file_util.h" |
| 22 #include "webkit/fileapi/file_system_path_manager.h" | 21 #include "webkit/fileapi/file_system_path_manager.h" |
| 23 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 22 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 23 #include "webkit/quota/mock_special_storage_policy.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 const char kTestkOrigin1[] = "http://host1:1/"; | 27 const char kTestkOrigin1[] = "http://host1:1/"; |
| 28 const char kTestkOrigin2[] = "http://host2:1/"; | 28 const char kTestkOrigin2[] = "http://host2:1/"; |
| 29 const char kTestkOrigin3[] = "http://host3:1/"; | 29 const char kTestkOrigin3[] = "http://host3:1/"; |
| 30 | 30 |
| 31 const GURL kOrigin1(kTestkOrigin1); | 31 const GURL kOrigin1(kTestkOrigin1); |
| 32 const GURL kOrigin2(kTestkOrigin2); | 32 const GURL kOrigin2(kTestkOrigin2); |
| 33 const GURL kOrigin3(kTestkOrigin3); | 33 const GURL kOrigin3(kTestkOrigin3); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 fileapi::kFileSystemTypePersistent)); | 358 fileapi::kFileSystemTypePersistent)); |
| 359 EXPECT_FALSE(tester->FileSystemContainsOriginAndType(kOrigin3, | 359 EXPECT_FALSE(tester->FileSystemContainsOriginAndType(kOrigin3, |
| 360 fileapi::kFileSystemTypeTemporary)); | 360 fileapi::kFileSystemTypeTemporary)); |
| 361 } | 361 } |
| 362 | 362 |
| 363 TEST_F(BrowsingDataRemoverTest, RemoveAppCacheForever) { | 363 TEST_F(BrowsingDataRemoverTest, RemoveAppCacheForever) { |
| 364 // Set up ChromeAppCacheService. | 364 // Set up ChromeAppCacheService. |
| 365 scoped_refptr<ChromeAppCacheService> appcache_service = | 365 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 366 new ChromeAppCacheService(NULL); | 366 new ChromeAppCacheService(NULL); |
| 367 const content::ResourceContext* resource_context = NULL; | 367 const content::ResourceContext* resource_context = NULL; |
| 368 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy = | 368 scoped_refptr<quota::MockSpecialStoragePolicy> mock_policy = |
| 369 new MockExtensionSpecialStoragePolicy; | 369 new quota::MockSpecialStoragePolicy; |
| 370 mock_policy->AddProtected(kProtectedManifest.GetOrigin()); | 370 mock_policy->AddProtected(kProtectedManifest.GetOrigin()); |
| 371 BrowserThread::PostTask( | 371 BrowserThread::PostTask( |
| 372 BrowserThread::IO, FROM_HERE, | 372 BrowserThread::IO, FROM_HERE, |
| 373 NewRunnableMethod(appcache_service.get(), | 373 NewRunnableMethod(appcache_service.get(), |
| 374 &ChromeAppCacheService::InitializeOnIOThread, | 374 &ChromeAppCacheService::InitializeOnIOThread, |
| 375 FilePath(), | 375 FilePath(), |
| 376 resource_context, | 376 resource_context, |
| 377 mock_policy, | 377 mock_policy)); |
| 378 false)); | |
| 379 MessageLoop::current()->RunAllPending(); | 378 MessageLoop::current()->RunAllPending(); |
| 380 TestingProfile* profile = GetProfile(); | 379 TestingProfile* profile = GetProfile(); |
| 381 profile->SetAppCacheService(appcache_service); | 380 profile->SetAppCacheService(appcache_service); |
| 382 profile->SetExtensionSpecialStoragePolicy(mock_policy); | |
| 383 | 381 |
| 384 // Add data into the AppCacheStorage. | 382 // Add data into the AppCacheStorage. |
| 385 AppCacheInserter appcache_inserter; | 383 AppCacheInserter appcache_inserter; |
| 386 appcache_inserter.AddGroupAndCache(appcache_service, kNormalManifest); | 384 appcache_inserter.AddGroupAndCache(appcache_service, kNormalManifest); |
| 387 appcache_inserter.AddGroupAndCache(appcache_service, kProtectedManifest); | 385 appcache_inserter.AddGroupAndCache(appcache_service, kProtectedManifest); |
| 388 | 386 |
| 389 // Verify that adding the data succeeded. | 387 // Verify that adding the data succeeded. |
| 390 AppCacheReader reader(appcache_service); | 388 AppCacheReader reader(appcache_service); |
| 391 std::set<GURL>* origins = reader.ReadAppCaches(); | 389 std::set<GURL>* origins = reader.ReadAppCaches(); |
| 392 EXPECT_EQ(2UL, origins->size()); | 390 EXPECT_EQ(2UL, origins->size()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 405 tester->BlockUntilNotified(); | 403 tester->BlockUntilNotified(); |
| 406 | 404 |
| 407 // Results: appcaches for the normal origin got deleted, appcaches for the | 405 // Results: appcaches for the normal origin got deleted, appcaches for the |
| 408 // protected origin didn't. | 406 // protected origin didn't. |
| 409 origins = reader.ReadAppCaches(); | 407 origins = reader.ReadAppCaches(); |
| 410 EXPECT_EQ(1UL, origins->size()); | 408 EXPECT_EQ(1UL, origins->size()); |
| 411 EXPECT_TRUE(origins->find(kProtectedManifest.GetOrigin()) != origins->end()); | 409 EXPECT_TRUE(origins->find(kProtectedManifest.GetOrigin()) != origins->end()); |
| 412 } | 410 } |
| 413 | 411 |
| 414 } // namespace | 412 } // namespace |
| OLD | NEW |