Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 4281 matching lines...) Expand 10 before | Expand all | Expand 10 after
4292 TEST_F(ExtensionServiceTest, ClearExtensionData) { 4292 TEST_F(ExtensionServiceTest, ClearExtensionData) {
4293 InitializeEmptyExtensionService(); 4293 InitializeEmptyExtensionService();
4294 ExtensionCookieCallback callback; 4294 ExtensionCookieCallback callback;
4295 4295
4296 // Load a test extension. 4296 // Load a test extension.
4297 base::FilePath path = data_dir(); 4297 base::FilePath path = data_dir();
4298 path = path.AppendASCII("good.crx"); 4298 path = path.AppendASCII("good.crx");
4299 const Extension* extension = InstallCRX(path, INSTALL_NEW); 4299 const Extension* extension = InstallCRX(path, INSTALL_NEW);
4300 ASSERT_TRUE(extension); 4300 ASSERT_TRUE(extension);
4301 GURL ext_url(extension->url()); 4301 GURL ext_url(extension->url());
4302 std::string origin_id = webkit_database::GetIdentifierFromOrigin(ext_url); 4302 std::string origin_id = storage::GetIdentifierFromOrigin(ext_url);
4303 4303
4304 // Set a cookie for the extension. 4304 // Set a cookie for the extension.
4305 net::CookieMonster* cookie_monster = profile() 4305 net::CookieMonster* cookie_monster = profile()
4306 ->GetRequestContextForExtensions() 4306 ->GetRequestContextForExtensions()
4307 ->GetURLRequestContext() 4307 ->GetURLRequestContext()
4308 ->cookie_store() 4308 ->cookie_store()
4309 ->GetCookieMonster(); 4309 ->GetCookieMonster();
4310 ASSERT_TRUE(cookie_monster); 4310 ASSERT_TRUE(cookie_monster);
4311 net::CookieOptions options; 4311 net::CookieOptions options;
4312 cookie_monster->SetCookieWithOptionsAsync( 4312 cookie_monster->SetCookieWithOptionsAsync(
4313 ext_url, "dummy=value", options, 4313 ext_url, "dummy=value", options,
4314 base::Bind(&ExtensionCookieCallback::SetCookieCallback, 4314 base::Bind(&ExtensionCookieCallback::SetCookieCallback,
4315 base::Unretained(&callback))); 4315 base::Unretained(&callback)));
4316 base::RunLoop().RunUntilIdle(); 4316 base::RunLoop().RunUntilIdle();
4317 EXPECT_TRUE(callback.result_); 4317 EXPECT_TRUE(callback.result_);
4318 4318
4319 cookie_monster->GetAllCookiesForURLAsync( 4319 cookie_monster->GetAllCookiesForURLAsync(
4320 ext_url, 4320 ext_url,
4321 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, 4321 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
4322 base::Unretained(&callback))); 4322 base::Unretained(&callback)));
4323 base::RunLoop().RunUntilIdle(); 4323 base::RunLoop().RunUntilIdle();
4324 EXPECT_EQ(1U, callback.list_.size()); 4324 EXPECT_EQ(1U, callback.list_.size());
4325 4325
4326 // Open a database. 4326 // Open a database.
4327 webkit_database::DatabaseTracker* db_tracker = 4327 storage::DatabaseTracker* db_tracker =
4328 BrowserContext::GetDefaultStoragePartition(profile()) 4328 BrowserContext::GetDefaultStoragePartition(profile())
4329 ->GetDatabaseTracker(); 4329 ->GetDatabaseTracker();
4330 base::string16 db_name = base::UTF8ToUTF16("db"); 4330 base::string16 db_name = base::UTF8ToUTF16("db");
4331 base::string16 description = base::UTF8ToUTF16("db_description"); 4331 base::string16 description = base::UTF8ToUTF16("db_description");
4332 int64 size; 4332 int64 size;
4333 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size); 4333 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size);
4334 db_tracker->DatabaseClosed(origin_id, db_name); 4334 db_tracker->DatabaseClosed(origin_id, db_name);
4335 std::vector<webkit_database::OriginInfo> origins; 4335 std::vector<storage::OriginInfo> origins;
4336 db_tracker->GetAllOriginsInfo(&origins); 4336 db_tracker->GetAllOriginsInfo(&origins);
4337 EXPECT_EQ(1U, origins.size()); 4337 EXPECT_EQ(1U, origins.size());
4338 EXPECT_EQ(origin_id, origins[0].GetOriginIdentifier()); 4338 EXPECT_EQ(origin_id, origins[0].GetOriginIdentifier());
4339 4339
4340 // Create local storage. We only simulate this by creating the backing files. 4340 // Create local storage. We only simulate this by creating the backing files.
4341 // Note: This test depends on details of how the dom_storage library 4341 // Note: This test depends on details of how the dom_storage library
4342 // stores data in the host file system. 4342 // stores data in the host file system.
4343 base::FilePath lso_dir_path = 4343 base::FilePath lso_dir_path =
4344 profile()->GetPath().AppendASCII("Local Storage"); 4344 profile()->GetPath().AppendASCII("Local Storage");
4345 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) 4345 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4400 PackAndInstallCRX(data_dir().AppendASCII("app1"), INSTALL_NEW); 4400 PackAndInstallCRX(data_dir().AppendASCII("app1"), INSTALL_NEW);
4401 ValidatePrefKeyCount(++pref_count); 4401 ValidatePrefKeyCount(++pref_count);
4402 ASSERT_EQ(1u, registry()->enabled_extensions().size()); 4402 ASSERT_EQ(1u, registry()->enabled_extensions().size());
4403 const std::string id1 = extension->id(); 4403 const std::string id1 = extension->id();
4404 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( 4404 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission(
4405 APIPermission::kUnlimitedStorage)); 4405 APIPermission::kUnlimitedStorage));
4406 const GURL origin1( 4406 const GURL origin1(
4407 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 4407 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
4408 EXPECT_TRUE(profile()->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( 4408 EXPECT_TRUE(profile()->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
4409 origin1)); 4409 origin1));
4410 std::string origin_id = webkit_database::GetIdentifierFromOrigin(origin1); 4410 std::string origin_id = storage::GetIdentifierFromOrigin(origin1);
4411 4411
4412 // Install app2 from the same origin with unlimited storage. 4412 // Install app2 from the same origin with unlimited storage.
4413 extension = PackAndInstallCRX(data_dir().AppendASCII("app2"), INSTALL_NEW); 4413 extension = PackAndInstallCRX(data_dir().AppendASCII("app2"), INSTALL_NEW);
4414 ValidatePrefKeyCount(++pref_count); 4414 ValidatePrefKeyCount(++pref_count);
4415 ASSERT_EQ(2u, registry()->enabled_extensions().size()); 4415 ASSERT_EQ(2u, registry()->enabled_extensions().size());
4416 const std::string id2 = extension->id(); 4416 const std::string id2 = extension->id();
4417 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( 4417 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission(
4418 APIPermission::kUnlimitedStorage)); 4418 APIPermission::kUnlimitedStorage));
4419 EXPECT_TRUE(extension->web_extent().MatchesURL( 4419 EXPECT_TRUE(extension->web_extent().MatchesURL(
4420 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); 4420 extensions::AppLaunchInfo::GetFullLaunchURL(extension)));
(...skipping 19 matching lines...) Expand all
4440 EXPECT_TRUE(callback.result_); 4440 EXPECT_TRUE(callback.result_);
4441 4441
4442 cookie_monster->GetAllCookiesForURLAsync( 4442 cookie_monster->GetAllCookiesForURLAsync(
4443 origin1, 4443 origin1,
4444 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, 4444 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
4445 base::Unretained(&callback))); 4445 base::Unretained(&callback)));
4446 base::RunLoop().RunUntilIdle(); 4446 base::RunLoop().RunUntilIdle();
4447 EXPECT_EQ(1U, callback.list_.size()); 4447 EXPECT_EQ(1U, callback.list_.size());
4448 4448
4449 // Open a database. 4449 // Open a database.
4450 webkit_database::DatabaseTracker* db_tracker = 4450 storage::DatabaseTracker* db_tracker =
4451 BrowserContext::GetDefaultStoragePartition(profile()) 4451 BrowserContext::GetDefaultStoragePartition(profile())
4452 ->GetDatabaseTracker(); 4452 ->GetDatabaseTracker();
4453 base::string16 db_name = base::UTF8ToUTF16("db"); 4453 base::string16 db_name = base::UTF8ToUTF16("db");
4454 base::string16 description = base::UTF8ToUTF16("db_description"); 4454 base::string16 description = base::UTF8ToUTF16("db_description");
4455 int64 size; 4455 int64 size;
4456 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size); 4456 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size);
4457 db_tracker->DatabaseClosed(origin_id, db_name); 4457 db_tracker->DatabaseClosed(origin_id, db_name);
4458 std::vector<webkit_database::OriginInfo> origins; 4458 std::vector<storage::OriginInfo> origins;
4459 db_tracker->GetAllOriginsInfo(&origins); 4459 db_tracker->GetAllOriginsInfo(&origins);
4460 EXPECT_EQ(1U, origins.size()); 4460 EXPECT_EQ(1U, origins.size());
4461 EXPECT_EQ(origin_id, origins[0].GetOriginIdentifier()); 4461 EXPECT_EQ(origin_id, origins[0].GetOriginIdentifier());
4462 4462
4463 // Create local storage. We only simulate this by creating the backing files. 4463 // Create local storage. We only simulate this by creating the backing files.
4464 // Note: This test depends on details of how the dom_storage library 4464 // Note: This test depends on details of how the dom_storage library
4465 // stores data in the host file system. 4465 // stores data in the host file system.
4466 base::FilePath lso_dir_path = 4466 base::FilePath lso_dir_path =
4467 profile()->GetPath().AppendASCII("Local Storage"); 4467 profile()->GetPath().AppendASCII("Local Storage");
4468 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) 4468 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id)
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after
7153 7153
7154 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 7154 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
7155 content::Source<Profile>(profile()), 7155 content::Source<Profile>(profile()),
7156 content::NotificationService::NoDetails()); 7156 content::NotificationService::NoDetails());
7157 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 7157 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
7158 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 7158 EXPECT_EQ(0u, registry()->enabled_extensions().size());
7159 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 7159 EXPECT_EQ(0u, registry()->disabled_extensions().size());
7160 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 7160 EXPECT_EQ(0u, registry()->terminated_extensions().size());
7161 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 7161 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
7162 } 7162 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_special_storage_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698