OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/crypto/signature_verifier.h" | 9 #include "base/crypto/signature_verifier.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 void ExtensionsService::GetExternalExtensions( | 433 void ExtensionsService::GetExternalExtensions( |
434 DictionaryValue* external_extensions, | 434 DictionaryValue* external_extensions, |
435 std::set<std::string>* killed_extensions) { | 435 std::set<std::string>* killed_extensions) { |
436 const DictionaryValue* dict = prefs_->GetDictionary(kExternalExtensionsPref); | 436 const DictionaryValue* dict = prefs_->GetDictionary(kExternalExtensionsPref); |
437 if (!dict || dict->GetSize() == 0) | 437 if (!dict || dict->GetSize() == 0) |
438 return; | 438 return; |
439 | 439 |
440 for (DictionaryValue::key_iterator i = dict->begin_keys(); | 440 for (DictionaryValue::key_iterator i = dict->begin_keys(); |
441 i != dict->end_keys(); ++i) { | 441 i != dict->end_keys(); ++i) { |
442 std::wstring key_name = *i; | 442 std::wstring key_name = *i; |
443 DCHECK(Extension::IdIsValid(WideToASCII(key_name))); | 443 if (!Extension::IdIsValid(WideToASCII(key_name))) { |
| 444 LOG(WARNING) << "Invalid external extension ID encountered: " |
| 445 << WideToASCII(key_name); |
| 446 continue; |
| 447 } |
| 448 |
444 DictionaryValue* extension = NULL; | 449 DictionaryValue* extension = NULL; |
445 if (!dict->GetDictionary(key_name, &extension)) { | 450 if (!dict->GetDictionary(key_name, &extension)) { |
446 NOTREACHED(); | 451 NOTREACHED(); |
447 continue; | 452 continue; |
448 } | 453 } |
449 | 454 |
450 // Check to see if the extension has been killed. | 455 // Check to see if the extension has been killed. |
451 int state; | 456 int state; |
452 if (extension->GetInteger(kState, &state) && | 457 if (extension->GetInteger(kState, &state) && |
453 state == static_cast<int>(Extension::KILLBIT)) { | 458 state == static_cast<int>(Extension::KILLBIT)) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 // Find all child directories in the install directory and load their | 572 // Find all child directories in the install directory and load their |
568 // manifests. Post errors and results to the frontend. | 573 // manifests. Post errors and results to the frontend. |
569 file_util::FileEnumerator enumerator(install_directory_, | 574 file_util::FileEnumerator enumerator(install_directory_, |
570 false, // Not recursive. | 575 false, // Not recursive. |
571 file_util::FileEnumerator::DIRECTORIES); | 576 file_util::FileEnumerator::DIRECTORIES); |
572 FilePath extension_path; | 577 FilePath extension_path; |
573 for (extension_path = enumerator.Next(); !extension_path.value().empty(); | 578 for (extension_path = enumerator.Next(); !extension_path.value().empty(); |
574 extension_path = enumerator.Next()) { | 579 extension_path = enumerator.Next()) { |
575 std::string extension_id = WideToASCII( | 580 std::string extension_id = WideToASCII( |
576 extension_path.BaseName().ToWStringHack()); | 581 extension_path.BaseName().ToWStringHack()); |
| 582 |
577 // The utility process might be in the middle of unpacking an extension, so | 583 // The utility process might be in the middle of unpacking an extension, so |
578 // ignore the temp unpacking directory. | 584 // ignore the temp unpacking directory. |
579 if (extension_id == kUnpackExtensionDir) | 585 if (extension_id == kUnpackExtensionDir) |
580 continue; | 586 continue; |
581 | 587 |
| 588 // Ignore directories that aren't valid IDs. |
| 589 if (!Extension::IdIsValid(extension_id)) { |
| 590 LOG(WARNING) << "Invalid extension ID encountered in extensions " |
| 591 "directory: " << extension_id; |
| 592 continue; |
| 593 } |
| 594 |
582 // If there is no Current Version file, just delete the directory and move | 595 // If there is no Current Version file, just delete the directory and move |
583 // on. This can legitimately happen when an uninstall does not complete, for | 596 // on. This can legitimately happen when an uninstall does not complete, for |
584 // example, when a plugin is in use at uninstall time. | 597 // example, when a plugin is in use at uninstall time. |
585 FilePath current_version_path = extension_path.AppendASCII( | 598 FilePath current_version_path = extension_path.AppendASCII( |
586 ExtensionsService::kCurrentVersionFileName); | 599 ExtensionsService::kCurrentVersionFileName); |
587 if (!file_util::PathExists(current_version_path)) { | 600 if (!file_util::PathExists(current_version_path)) { |
588 LOG(INFO) << "Deleting incomplete install for directory " | 601 LOG(INFO) << "Deleting incomplete install for directory " |
589 << WideToASCII(extension_path.ToWStringHack()) << "."; | 602 << WideToASCII(extension_path.ToWStringHack()) << "."; |
590 file_util::Delete(extension_path, true); // Recursive. | 603 file_util::Delete(extension_path, true); // Recursive. |
591 continue; | 604 continue; |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 Extension::InstallType install_type = | 1391 Extension::InstallType install_type = |
1379 CompareToInstalledVersion(id, version->GetString(), ¤t_version); | 1392 CompareToInstalledVersion(id, version->GetString(), ¤t_version); |
1380 | 1393 |
1381 if (install_type == Extension::DOWNGRADE) | 1394 if (install_type == Extension::DOWNGRADE) |
1382 return false; | 1395 return false; |
1383 | 1396 |
1384 return (install_type == Extension::UPGRADE || | 1397 return (install_type == Extension::UPGRADE || |
1385 install_type == Extension::NEW_INSTALL || | 1398 install_type == Extension::NEW_INSTALL || |
1386 NeedsReinstall(id, current_version)); | 1399 NeedsReinstall(id, current_version)); |
1387 } | 1400 } |
OLD | NEW |