| 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 "chrome/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/files/file_enumerator.h" |
| 16 #include "base/files/scoped_temp_dir.h" | 17 #include "base/files/scoped_temp_dir.h" |
| 17 #include "base/json/json_file_value_serializer.h" | 18 #include "base/json/json_file_value_serializer.h" |
| 18 #include "base/json/json_reader.h" | 19 #include "base/json/json_reader.h" |
| 19 #include "base/json/json_string_value_serializer.h" | 20 #include "base/json/json_string_value_serializer.h" |
| 20 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 21 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
| 22 #include "base/message_loop.h" | 23 #include "base/message_loop.h" |
| 23 #include "base/path_service.h" | 24 #include "base/path_service.h" |
| 24 #include "base/stl_util.h" | 25 #include "base/stl_util.h" |
| 25 #include "base/string16.h" | 26 #include "base/string16.h" |
| (...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 DictionaryPrefUpdate update(profile_->GetPrefs(), "extensions.settings"); | 1311 DictionaryPrefUpdate update(profile_->GetPrefs(), "extensions.settings"); |
| 1311 DictionaryValue* dict = update.Get(); | 1312 DictionaryValue* dict = update.Get(); |
| 1312 ASSERT_TRUE(dict != NULL); | 1313 ASSERT_TRUE(dict != NULL); |
| 1313 dict->Remove("behllobkkfkfnphdnhnkndlbkcpglgmj", NULL); | 1314 dict->Remove("behllobkkfkfnphdnhnkndlbkcpglgmj", NULL); |
| 1314 } | 1315 } |
| 1315 | 1316 |
| 1316 service_->Init(); | 1317 service_->Init(); |
| 1317 // Wait for GarbageCollectExtensions task to complete. | 1318 // Wait for GarbageCollectExtensions task to complete. |
| 1318 loop_.RunUntilIdle(); | 1319 loop_.RunUntilIdle(); |
| 1319 | 1320 |
| 1320 file_util::FileEnumerator dirs(extensions_install_dir_, false, | 1321 base::FileEnumerator dirs(extensions_install_dir_, false, |
| 1321 file_util::FileEnumerator::DIRECTORIES); | 1322 base::FileEnumerator::DIRECTORIES); |
| 1322 size_t count = 0; | 1323 size_t count = 0; |
| 1323 while (!dirs.Next().empty()) | 1324 while (!dirs.Next().empty()) |
| 1324 count++; | 1325 count++; |
| 1325 | 1326 |
| 1326 // We should have only gotten two extensions now. | 1327 // We should have only gotten two extensions now. |
| 1327 EXPECT_EQ(2u, count); | 1328 EXPECT_EQ(2u, count); |
| 1328 | 1329 |
| 1329 // And extension1 dir should now be toast. | 1330 // And extension1 dir should now be toast. |
| 1330 base::FilePath extension_dir = extensions_install_dir_ | 1331 base::FilePath extension_dir = extensions_install_dir_ |
| 1331 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj"); | 1332 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj"); |
| (...skipping 4630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5962 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); | 5963 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); |
| 5963 AddMockExternalProvider(provider); | 5964 AddMockExternalProvider(provider); |
| 5964 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); | 5965 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); |
| 5965 | 5966 |
| 5966 service_->CheckForExternalUpdates(); | 5967 service_->CheckForExternalUpdates(); |
| 5967 loop_.RunUntilIdle(); | 5968 loop_.RunUntilIdle(); |
| 5968 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); | 5969 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); |
| 5969 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); | 5970 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); |
| 5970 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); | 5971 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); |
| 5971 } | 5972 } |
| OLD | NEW |