Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/json/json_file_value_serializer.h" | 16 #include "base/json/json_file_value_serializer.h" |
| 17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
| 18 #include "base/json/json_string_value_serializer.h" | 18 #include "base/json/json_string_value_serializer.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
| 22 #include "base/prefs/scoped_user_pref_update.h" | 22 #include "base/prefs/scoped_user_pref_update.h" |
| 23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
| 24 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
| 25 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 26 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/test/thread_test_helper.h" | |
| 28 #include "base/version.h" | 29 #include "base/version.h" |
| 29 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.h" |
| 31 #include "chrome/browser/extensions/app_sync_data.h" | 32 #include "chrome/browser/extensions/app_sync_data.h" |
| 32 #include "chrome/browser/extensions/blacklist.h" | 33 #include "chrome/browser/extensions/blacklist.h" |
| 33 #include "chrome/browser/extensions/chrome_app_sorting.h" | 34 #include "chrome/browser/extensions/chrome_app_sorting.h" |
| 34 #include "chrome/browser/extensions/component_loader.h" | 35 #include "chrome/browser/extensions/component_loader.h" |
| 35 #include "chrome/browser/extensions/crx_installer.h" | 36 #include "chrome/browser/extensions/crx_installer.h" |
| 36 #include "chrome/browser/extensions/default_apps.h" | 37 #include "chrome/browser/extensions/default_apps.h" |
| 37 #include "chrome/browser/extensions/extension_creator.h" | 38 #include "chrome/browser/extensions/extension_creator.h" |
| (...skipping 4217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4255 base::MessageLoop::current()->PostTask(FROM_HERE, | 4256 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 4256 base::Bind(&base::MessageLoop::Quit, weak_factory_.GetWeakPtr())); | 4257 base::Bind(&base::MessageLoop::Quit, weak_factory_.GetWeakPtr())); |
| 4257 list_ = list; | 4258 list_ = list; |
| 4258 } | 4259 } |
| 4259 net::CookieList list_; | 4260 net::CookieList list_; |
| 4260 bool result_; | 4261 bool result_; |
| 4261 base::WeakPtrFactory<base::MessageLoop> weak_factory_; | 4262 base::WeakPtrFactory<base::MessageLoop> weak_factory_; |
| 4262 }; | 4263 }; |
| 4263 | 4264 |
| 4264 // Verifies extension state is removed upon uninstall. | 4265 // Verifies extension state is removed upon uninstall. |
| 4265 #if defined(OS_CHROMEOS) | 4266 TEST_F(ExtensionServiceTest, ClearExtensionData) { |
| 4266 // http://crbug.com/396504 | |
| 4267 #define MAYBE_ClearExtensionData DISABLED_ClearExtensionData | |
| 4268 #else | |
| 4269 #define MAYBE_ClearExtensionData ClearExtensionData | |
| 4270 #endif | |
| 4271 TEST_F(ExtensionServiceTest, MAYBE_ClearExtensionData) { | |
| 4272 InitializeEmptyExtensionService(); | 4267 InitializeEmptyExtensionService(); |
| 4273 ExtensionCookieCallback callback; | 4268 ExtensionCookieCallback callback; |
| 4274 | 4269 |
| 4275 // Load a test extension. | 4270 // Load a test extension. |
| 4276 base::FilePath path = data_dir(); | 4271 base::FilePath path = data_dir(); |
| 4277 path = path.AppendASCII("good.crx"); | 4272 path = path.AppendASCII("good.crx"); |
| 4278 const Extension* extension = InstallCRX(path, INSTALL_NEW); | 4273 const Extension* extension = InstallCRX(path, INSTALL_NEW); |
| 4279 ASSERT_TRUE(extension); | 4274 ASSERT_TRUE(extension); |
| 4280 GURL ext_url(extension->url()); | 4275 GURL ext_url(extension->url()); |
| 4281 std::string origin_id = webkit_database::GetIdentifierFromOrigin(ext_url); | 4276 std::string origin_id = webkit_database::GetIdentifierFromOrigin(ext_url); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4333 profile())->GetIndexedDBContext(); | 4328 profile())->GetIndexedDBContext(); |
| 4334 idb_context->SetTaskRunnerForTesting( | 4329 idb_context->SetTaskRunnerForTesting( |
| 4335 base::MessageLoop::current()->message_loop_proxy().get()); | 4330 base::MessageLoop::current()->message_loop_proxy().get()); |
| 4336 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); | 4331 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); |
| 4337 EXPECT_TRUE(base::CreateDirectory(idb_path)); | 4332 EXPECT_TRUE(base::CreateDirectory(idb_path)); |
| 4338 EXPECT_TRUE(base::DirectoryExists(idb_path)); | 4333 EXPECT_TRUE(base::DirectoryExists(idb_path)); |
| 4339 | 4334 |
| 4340 // Uninstall the extension. | 4335 // Uninstall the extension. |
| 4341 service()->UninstallExtension( | 4336 service()->UninstallExtension( |
| 4342 good_crx, extensions::UNINSTALL_REASON_FOR_TESTING, NULL); | 4337 good_crx, extensions::UNINSTALL_REASON_FOR_TESTING, NULL); |
| 4338 // The data deletion happens on the IO thread. | |
| 4339 scoped_refptr<base::ThreadTestHelper> wait_for_io_thread( | |
|
awong
2014/07/28 15:05:25
unrelated: Why is ThreadTestHelper refcounted? :-/
| |
| 4340 new base::ThreadTestHelper( | |
| 4341 content::BrowserThread::GetMessageLoopProxyForThread( | |
| 4342 content::BrowserThread::IO))); | |
| 4343 EXPECT_TRUE(wait_for_io_thread->Run()); | |
| 4343 base::RunLoop().RunUntilIdle(); | 4344 base::RunLoop().RunUntilIdle(); |
| 4344 | 4345 |
| 4345 // Check that the cookie is gone. | 4346 // Check that the cookie is gone. |
| 4346 cookie_monster->GetAllCookiesForURLAsync( | 4347 cookie_monster->GetAllCookiesForURLAsync( |
| 4347 ext_url, | 4348 ext_url, |
| 4348 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, | 4349 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, |
| 4349 base::Unretained(&callback))); | 4350 base::Unretained(&callback))); |
| 4350 base::RunLoop().RunUntilIdle(); | 4351 base::RunLoop().RunUntilIdle(); |
| 4351 EXPECT_EQ(0U, callback.list_.size()); | 4352 EXPECT_EQ(0U, callback.list_.size()); |
| 4352 | 4353 |
| (...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7022 | 7023 |
| 7023 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 7024 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
| 7024 content::Source<Profile>(profile()), | 7025 content::Source<Profile>(profile()), |
| 7025 content::NotificationService::NoDetails()); | 7026 content::NotificationService::NoDetails()); |
| 7026 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 7027 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
| 7027 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 7028 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
| 7028 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 7029 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
| 7029 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 7030 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
| 7030 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 7031 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
| 7031 } | 7032 } |
| OLD | NEW |