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/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 omnibox_popup_icon_manager_.set_monochrome(true); | 437 omnibox_popup_icon_manager_.set_monochrome(true); |
438 omnibox_icon_manager_.set_monochrome(true); | 438 omnibox_icon_manager_.set_monochrome(true); |
439 omnibox_icon_manager_.set_padding(gfx::Insets(0, kOmniboxIconPaddingLeft, | 439 omnibox_icon_manager_.set_padding(gfx::Insets(0, kOmniboxIconPaddingLeft, |
440 0, kOmniboxIconPaddingRight)); | 440 0, kOmniboxIconPaddingRight)); |
441 | 441 |
442 // How long is the path to the Extensions directory? | 442 // How long is the path to the Extensions directory? |
443 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength", | 443 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength", |
444 install_directory_.value().length(), 0, 500, 100); | 444 install_directory_.value().length(), 0, 500, 100); |
445 } | 445 } |
446 | 446 |
447 const ExtensionList* ExtensionService::extensions() const { | 447 const ExtensionSet* ExtensionService::extensions() const { |
448 return &extensions_; | 448 return &extensions_; |
449 } | 449 } |
450 | 450 |
451 const ExtensionList* ExtensionService::disabled_extensions() const { | 451 const ExtensionSet* ExtensionService::disabled_extensions() const { |
452 return &disabled_extensions_; | 452 return &disabled_extensions_; |
453 } | 453 } |
454 | 454 |
455 const ExtensionList* ExtensionService::terminated_extensions() const { | 455 const ExtensionSet* ExtensionService::terminated_extensions() const { |
456 return &terminated_extensions_; | 456 return &terminated_extensions_; |
457 } | 457 } |
458 | 458 |
459 PendingExtensionManager* ExtensionService::pending_extension_manager() { | 459 PendingExtensionManager* ExtensionService::pending_extension_manager() { |
460 return &pending_extension_manager_; | 460 return &pending_extension_manager_; |
461 } | 461 } |
462 | 462 |
463 ExtensionService::~ExtensionService() { | 463 ExtensionService::~ExtensionService() { |
464 // No need to unload extensions here because they are profile-scoped, and the | 464 // No need to unload extensions here because they are profile-scoped, and the |
465 // profile is in the process of being deleted. | 465 // profile is in the process of being deleted. |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 // Therefore, we clear warnings of this type for all extensions. | 759 // Therefore, we clear warnings of this type for all extensions. |
760 std::set<ExtensionWarningSet::WarningType> warnings; | 760 std::set<ExtensionWarningSet::WarningType> warnings; |
761 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); | 761 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); |
762 extension_warnings_.ClearWarnings(warnings); | 762 extension_warnings_.ClearWarnings(warnings); |
763 | 763 |
764 return true; | 764 return true; |
765 } | 765 } |
766 | 766 |
767 bool ExtensionService::IsExtensionEnabled( | 767 bool ExtensionService::IsExtensionEnabled( |
768 const std::string& extension_id) const { | 768 const std::string& extension_id) const { |
769 const Extension* extension = | 769 if (extensions_.Contains(extension_id) || |
770 GetExtensionByIdInternal(extension_id, true, false, true); | 770 terminated_extensions_.Contains(extension_id)) |
771 if (extension) | |
772 return true; | 771 return true; |
773 | 772 |
774 extension = | 773 if (disabled_extensions_.Contains(extension_id)) |
775 GetExtensionByIdInternal(extension_id, false, true, false); | |
776 if (extension) | |
777 return false; | 774 return false; |
778 | 775 |
779 // If the extension hasn't been loaded yet, check the prefs for it. Assume | 776 // If the extension hasn't been loaded yet, check the prefs for it. Assume |
780 // enabled unless otherwise noted. | 777 // enabled unless otherwise noted. |
781 return !extension_prefs_->IsExtensionDisabled(extension_id) && | 778 return !extension_prefs_->IsExtensionDisabled(extension_id) && |
782 !extension_prefs_->IsExternalExtensionUninstalled(extension_id); | 779 !extension_prefs_->IsExternalExtensionUninstalled(extension_id); |
783 } | 780 } |
784 | 781 |
785 bool ExtensionService::IsExternalExtensionUninstalled( | 782 bool ExtensionService::IsExternalExtensionUninstalled( |
786 const std::string& extension_id) const { | 783 const std::string& extension_id) const { |
787 return extension_prefs_->IsExternalExtensionUninstalled(extension_id); | 784 return extension_prefs_->IsExternalExtensionUninstalled(extension_id); |
788 } | 785 } |
789 | 786 |
790 void ExtensionService::EnableExtension(const std::string& extension_id) { | 787 void ExtensionService::EnableExtension(const std::string& extension_id) { |
791 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 788 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
792 | 789 |
793 if (IsExtensionEnabled(extension_id)) | 790 if (IsExtensionEnabled(extension_id)) |
794 return; | 791 return; |
795 | 792 |
796 extension_prefs_->SetExtensionState(extension_id, Extension::ENABLED); | 793 extension_prefs_->SetExtensionState(extension_id, Extension::ENABLED); |
797 | 794 |
798 const Extension* extension = | 795 const Extension* extension = |
799 GetExtensionByIdInternal(extension_id, false, true, false); | 796 GetExtensionByIdInternal(extension_id, false, true, false); |
800 // This can happen if sync enables an extension that is not | 797 // This can happen if sync enables an extension that is not |
801 // installed yet. | 798 // installed yet. |
802 if (!extension) | 799 if (!extension) |
803 return; | 800 return; |
804 | 801 |
805 // Move it over to the enabled list. | 802 // Move it over to the enabled list. |
806 extensions_.push_back(make_scoped_refptr(extension)); | 803 extensions_.Insert(make_scoped_refptr(extension)); |
807 ExtensionList::iterator iter = std::find(disabled_extensions_.begin(), | 804 disabled_extensions_.Remove(extension->id()); |
808 disabled_extensions_.end(), | |
809 extension); | |
810 disabled_extensions_.erase(iter); | |
811 | 805 |
812 // Make sure any browser action contained within it is not hidden. | 806 // Make sure any browser action contained within it is not hidden. |
813 extension_prefs_->SetBrowserActionVisibility(extension, true); | 807 extension_prefs_->SetBrowserActionVisibility(extension, true); |
814 | 808 |
815 NotifyExtensionLoaded(extension); | 809 NotifyExtensionLoaded(extension); |
816 | 810 |
817 SyncExtensionChangeIfNeeded(*extension); | 811 SyncExtensionChangeIfNeeded(*extension); |
818 } | 812 } |
819 | 813 |
820 void ExtensionService::DisableExtension(const std::string& extension_id) { | 814 void ExtensionService::DisableExtension(const std::string& extension_id) { |
821 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 815 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
822 | 816 |
823 // The extension may have been disabled already. | 817 // The extension may have been disabled already. |
824 if (!IsExtensionEnabled(extension_id)) | 818 if (!IsExtensionEnabled(extension_id)) |
825 return; | 819 return; |
826 | 820 |
827 const Extension* extension = GetInstalledExtension(extension_id); | 821 const Extension* extension = GetInstalledExtension(extension_id); |
828 // |extension| can be NULL if sync disables an extension that is not | 822 // |extension| can be NULL if sync disables an extension that is not |
829 // installed yet. | 823 // installed yet. |
830 if (extension && !Extension::UserMayDisable(extension->location())) | 824 if (extension && !Extension::UserMayDisable(extension->location())) |
831 return; | 825 return; |
832 | 826 |
833 extension_prefs_->SetExtensionState(extension_id, Extension::DISABLED); | 827 extension_prefs_->SetExtensionState(extension_id, Extension::DISABLED); |
834 | 828 |
835 extension = GetExtensionByIdInternal(extension_id, true, false, true); | 829 extension = GetExtensionByIdInternal(extension_id, true, false, true); |
836 if (!extension) | 830 if (!extension) |
837 return; | 831 return; |
838 | 832 |
839 // Move it over to the disabled list. | 833 // Move it over to the disabled list. |
840 disabled_extensions_.push_back(make_scoped_refptr(extension)); | 834 disabled_extensions_.Insert(make_scoped_refptr(extension)); |
841 ExtensionList::iterator iter = std::find(extensions_.begin(), | 835 if (extensions_.Contains(extension->id())) |
842 extensions_.end(), | 836 extensions_.Remove(extension->id()); |
843 extension); | 837 else |
844 if (iter != extensions_.end()) { | 838 terminated_extensions_.Remove(extension->id()); |
845 extensions_.erase(iter); | |
846 } else { | |
847 iter = std::find(terminated_extensions_.begin(), | |
848 terminated_extensions_.end(), | |
849 extension); | |
850 terminated_extensions_.erase(iter); | |
851 } | |
852 | 839 |
853 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); | 840 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); |
854 | 841 |
855 SyncExtensionChangeIfNeeded(*extension); | 842 SyncExtensionChangeIfNeeded(*extension); |
856 | 843 |
857 // Deactivating one extension might have solved the problems of others. | 844 // Deactivating one extension might have solved the problems of others. |
858 // Therefore, we clear warnings of this type for all extensions. | 845 // Therefore, we clear warnings of this type for all extensions. |
859 std::set<ExtensionWarningSet::WarningType> warnings; | 846 std::set<ExtensionWarningSet::WarningType> warnings; |
860 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); | 847 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); |
861 extension_warnings_.ClearWarnings(warnings); | 848 extension_warnings_.ClearWarnings(warnings); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 // Use this set to indicate if an extension in the blacklist has been used. | 1095 // Use this set to indicate if an extension in the blacklist has been used. |
1109 std::set<std::string> blacklist_set; | 1096 std::set<std::string> blacklist_set; |
1110 for (unsigned int i = 0; i < blacklist.size(); ++i) { | 1097 for (unsigned int i = 0; i < blacklist.size(); ++i) { |
1111 if (Extension::IdIsValid(blacklist[i])) { | 1098 if (Extension::IdIsValid(blacklist[i])) { |
1112 blacklist_set.insert(blacklist[i]); | 1099 blacklist_set.insert(blacklist[i]); |
1113 } | 1100 } |
1114 } | 1101 } |
1115 extension_prefs_->UpdateBlacklist(blacklist_set); | 1102 extension_prefs_->UpdateBlacklist(blacklist_set); |
1116 std::vector<std::string> to_be_removed; | 1103 std::vector<std::string> to_be_removed; |
1117 // Loop current extensions, unload installed extensions. | 1104 // Loop current extensions, unload installed extensions. |
1118 for (ExtensionList::const_iterator iter = extensions_.begin(); | 1105 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
1119 iter != extensions_.end(); ++iter) { | 1106 iter != extensions_.end(); ++iter) { |
1120 const Extension* extension = (*iter); | 1107 const Extension* extension = (*iter); |
1121 if (blacklist_set.find(extension->id()) != blacklist_set.end()) { | 1108 if (blacklist_set.find(extension->id()) != blacklist_set.end()) { |
1122 to_be_removed.push_back(extension->id()); | 1109 to_be_removed.push_back(extension->id()); |
1123 } | 1110 } |
1124 } | 1111 } |
1125 | 1112 |
1126 // UnloadExtension will change the extensions_ list. So, we should | 1113 // UnloadExtension will change the extensions_ list. So, we should |
1127 // call it outside the iterator loop. | 1114 // call it outside the iterator loop. |
1128 for (unsigned int i = 0; i < to_be_removed.size(); ++i) { | 1115 for (unsigned int i = 0; i < to_be_removed.size(); ++i) { |
(...skipping 22 matching lines...) Expand all Loading... |
1151 return ready_; | 1138 return ready_; |
1152 } | 1139 } |
1153 | 1140 |
1154 ExtensionUpdater* ExtensionService::updater() { | 1141 ExtensionUpdater* ExtensionService::updater() { |
1155 return updater_.get(); | 1142 return updater_.get(); |
1156 } | 1143 } |
1157 | 1144 |
1158 void ExtensionService::CheckAdminBlacklist() { | 1145 void ExtensionService::CheckAdminBlacklist() { |
1159 std::vector<std::string> to_be_removed; | 1146 std::vector<std::string> to_be_removed; |
1160 // Loop through extensions list, unload installed extensions. | 1147 // Loop through extensions list, unload installed extensions. |
1161 for (ExtensionList::const_iterator iter = extensions_.begin(); | 1148 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
1162 iter != extensions_.end(); ++iter) { | 1149 iter != extensions_.end(); ++iter) { |
1163 const Extension* extension = (*iter); | 1150 const Extension* extension = (*iter); |
1164 if (!extension_prefs_->IsExtensionAllowedByPolicy(extension->id(), | 1151 if (!extension_prefs_->IsExtensionAllowedByPolicy(extension->id(), |
1165 extension->location())) { | 1152 extension->location())) { |
1166 to_be_removed.push_back(extension->id()); | 1153 to_be_removed.push_back(extension->id()); |
1167 } | 1154 } |
1168 } | 1155 } |
1169 | 1156 |
1170 // UnloadExtension will change the extensions_ list. So, we should | 1157 // UnloadExtension will change the extensions_ list. So, we should |
1171 // call it outside the iterator loop. | 1158 // call it outside the iterator loop. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 bundle->synced_extensions.erase(extension_sync_data.id()); | 1339 bundle->synced_extensions.erase(extension_sync_data.id()); |
1353 else | 1340 else |
1354 bundle->synced_extensions.insert(extension_sync_data.id()); | 1341 bundle->synced_extensions.insert(extension_sync_data.id()); |
1355 ProcessExtensionSyncData(extension_sync_data, *bundle); | 1342 ProcessExtensionSyncData(extension_sync_data, *bundle); |
1356 } | 1343 } |
1357 | 1344 |
1358 return SyncError(); | 1345 return SyncError(); |
1359 } | 1346 } |
1360 | 1347 |
1361 void ExtensionService::GetSyncDataListHelper( | 1348 void ExtensionService::GetSyncDataListHelper( |
1362 const ExtensionList& extensions, | 1349 const ExtensionSet& extensions, |
1363 const SyncBundle& bundle, | 1350 const SyncBundle& bundle, |
1364 std::vector<ExtensionSyncData>* sync_data_list) const { | 1351 std::vector<ExtensionSyncData>* sync_data_list) const { |
1365 for (ExtensionList::const_iterator it = extensions.begin(); | 1352 for (ExtensionSet::const_iterator it = extensions.begin(); |
1366 it != extensions.end(); ++it) { | 1353 it != extensions.end(); ++it) { |
1367 const Extension& extension = **it; | 1354 const Extension& extension = **it; |
1368 if (bundle.filter(extension) && | 1355 if (bundle.filter(extension) && |
1369 // If we have pending extension data for this extension, then this | 1356 // If we have pending extension data for this extension, then this |
1370 // version is out of date. We'll sync back the version we got from | 1357 // version is out of date. We'll sync back the version we got from |
1371 // sync. | 1358 // sync. |
1372 !bundle.HasPendingExtensionId(extension.id())) { | 1359 !bundle.HasPendingExtensionId(extension.id())) { |
1373 sync_data_list->push_back(ExtensionSyncData( | 1360 sync_data_list->push_back(ExtensionSyncData( |
1374 extension, | 1361 extension, |
1375 IsExtensionEnabled(extension.id()), | 1362 IsExtensionEnabled(extension.id()), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 | 1473 |
1487 // Broadcast unloaded and loaded events to update browser state. Only bother | 1474 // Broadcast unloaded and loaded events to update browser state. Only bother |
1488 // if the value changed and the extension is actually enabled, since there is | 1475 // if the value changed and the extension is actually enabled, since there is |
1489 // no UI otherwise. | 1476 // no UI otherwise. |
1490 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); | 1477 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); |
1491 if (enabled == old_enabled) | 1478 if (enabled == old_enabled) |
1492 return; | 1479 return; |
1493 | 1480 |
1494 extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled); | 1481 extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled); |
1495 | 1482 |
1496 bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(), | 1483 bool extension_is_enabled = extensions_.Contains(extension->id()); |
1497 extension) != extensions_.end(); | |
1498 | 1484 |
1499 // When we reload the extension the ID may be invalidated if we've passed it | 1485 // When we reload the extension the ID may be invalidated if we've passed it |
1500 // by const ref everywhere. Make a copy to be safe. | 1486 // by const ref everywhere. Make a copy to be safe. |
1501 std::string id = extension_id; | 1487 std::string id = extension_id; |
1502 if (extension_is_enabled) | 1488 if (extension_is_enabled) |
1503 ReloadExtension(extension->id()); | 1489 ReloadExtension(extension->id()); |
1504 | 1490 |
1505 // Reloading the extension invalidates the |extension| pointer. | 1491 // Reloading the extension invalidates the |extension| pointer. |
1506 extension = GetInstalledExtension(id); | 1492 extension = GetInstalledExtension(id); |
1507 if (extension) | 1493 if (extension) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 void ExtensionService::SetAllowFileAccess(const Extension* extension, | 1550 void ExtensionService::SetAllowFileAccess(const Extension* extension, |
1565 bool allow) { | 1551 bool allow) { |
1566 // Reload to update browser state. Only bother if the value changed and the | 1552 // Reload to update browser state. Only bother if the value changed and the |
1567 // extension is actually enabled, since there is no UI otherwise. | 1553 // extension is actually enabled, since there is no UI otherwise. |
1568 bool old_allow = AllowFileAccess(extension); | 1554 bool old_allow = AllowFileAccess(extension); |
1569 if (allow == old_allow) | 1555 if (allow == old_allow) |
1570 return; | 1556 return; |
1571 | 1557 |
1572 extension_prefs_->SetAllowFileAccess(extension->id(), allow); | 1558 extension_prefs_->SetAllowFileAccess(extension->id(), allow); |
1573 | 1559 |
1574 bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(), | 1560 bool extension_is_enabled = extensions_.Contains(extension->id()); |
1575 extension) != extensions_.end(); | |
1576 if (extension_is_enabled) | 1561 if (extension_is_enabled) |
1577 ReloadExtension(extension->id()); | 1562 ReloadExtension(extension->id()); |
1578 } | 1563 } |
1579 | 1564 |
1580 bool ExtensionService::GetBrowserActionVisibility(const Extension* extension) { | 1565 bool ExtensionService::GetBrowserActionVisibility(const Extension* extension) { |
1581 return extension_prefs_->GetBrowserActionVisibility(extension); | 1566 return extension_prefs_->GetBrowserActionVisibility(extension); |
1582 } | 1567 } |
1583 | 1568 |
1584 void ExtensionService::SetBrowserActionVisibility(const Extension* extension, | 1569 void ExtensionService::SetBrowserActionVisibility(const Extension* extension, |
1585 bool visible) { | 1570 bool visible) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 switches::kEnableExtensionAlerts)) { | 1654 switches::kEnableExtensionAlerts)) { |
1670 return; // TODO(miket): enable unconditionally when done. | 1655 return; // TODO(miket): enable unconditionally when done. |
1671 } | 1656 } |
1672 | 1657 |
1673 // Build up the lists of extensions that require acknowledgment. | 1658 // Build up the lists of extensions that require acknowledgment. |
1674 // If this is the first time, grandfather extensions that would have | 1659 // If this is the first time, grandfather extensions that would have |
1675 // caused notification. | 1660 // caused notification. |
1676 scoped_ptr<ExtensionGlobalError> global_error( | 1661 scoped_ptr<ExtensionGlobalError> global_error( |
1677 new ExtensionGlobalError(AsWeakPtr())); | 1662 new ExtensionGlobalError(AsWeakPtr())); |
1678 bool needs_alert = false; | 1663 bool needs_alert = false; |
1679 for (ExtensionList::const_iterator iter = extensions_.begin(); | 1664 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
1680 iter != extensions_.end(); ++iter) { | 1665 iter != extensions_.end(); ++iter) { |
1681 const Extension* e = *iter; | 1666 const Extension* e = *iter; |
1682 if (!IsExtensionEnabled(e->id())) { | |
1683 continue; | |
1684 } | |
1685 if (Extension::IsExternalLocation(e->location())) { | 1667 if (Extension::IsExternalLocation(e->location())) { |
1686 if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) { | 1668 if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) { |
1687 global_error->AddExternalExtension(e->id()); | 1669 global_error->AddExternalExtension(e->id()); |
1688 needs_alert = true; | 1670 needs_alert = true; |
1689 } | 1671 } |
1690 } | 1672 } |
1691 if (extension_prefs_->IsExtensionBlacklisted(e->id())) { | 1673 if (extension_prefs_->IsExtensionBlacklisted(e->id())) { |
1692 if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) { | 1674 if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) { |
1693 global_error->AddBlacklistedExtension(e->id()); | 1675 global_error->AddBlacklistedExtension(e->id()); |
1694 needs_alert = true; | 1676 needs_alert = true; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 // Keep information about the extension so that we can reload it later | 1756 // Keep information about the extension so that we can reload it later |
1775 // even if it's not permanently installed. | 1757 // even if it's not permanently installed. |
1776 unloaded_extension_paths_[extension->id()] = extension->path(); | 1758 unloaded_extension_paths_[extension->id()] = extension->path(); |
1777 | 1759 |
1778 // Clean up if the extension is meant to be enabled after a reload. | 1760 // Clean up if the extension is meant to be enabled after a reload. |
1779 disabled_extension_paths_.erase(extension->id()); | 1761 disabled_extension_paths_.erase(extension->id()); |
1780 | 1762 |
1781 // Clean up runtime data. | 1763 // Clean up runtime data. |
1782 extension_runtime_data_.erase(extension_id); | 1764 extension_runtime_data_.erase(extension_id); |
1783 | 1765 |
1784 ExtensionList::iterator iter = std::find(disabled_extensions_.begin(), | 1766 if (disabled_extensions_.Contains(extension->id())) { |
1785 disabled_extensions_.end(), | |
1786 extension.get()); | |
1787 if (iter != disabled_extensions_.end()) { | |
1788 UnloadedExtensionInfo details(extension, reason); | 1767 UnloadedExtensionInfo details(extension, reason); |
1789 details.already_disabled = true; | 1768 details.already_disabled = true; |
1790 disabled_extensions_.erase(iter); | 1769 disabled_extensions_.Remove(extension->id()); |
1791 content::NotificationService::current()->Notify( | 1770 content::NotificationService::current()->Notify( |
1792 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 1771 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
1793 content::Source<Profile>(profile_), | 1772 content::Source<Profile>(profile_), |
1794 content::Details<UnloadedExtensionInfo>(&details)); | 1773 content::Details<UnloadedExtensionInfo>(&details)); |
1795 // Make sure the profile cleans up its RequestContexts when an already | 1774 // Make sure the profile cleans up its RequestContexts when an already |
1796 // disabled extension is unloaded (since they are also tracking the disabled | 1775 // disabled extension is unloaded (since they are also tracking the disabled |
1797 // extensions). | 1776 // extensions). |
1798 profile_->UnregisterExtensionWithRequestContexts(extension_id, reason); | 1777 profile_->UnregisterExtensionWithRequestContexts(extension_id, reason); |
1799 return; | 1778 return; |
1800 } | 1779 } |
1801 | 1780 |
1802 iter = std::find(extensions_.begin(), extensions_.end(), extension.get()); | 1781 // Remove the extension from our list. |
1803 | 1782 extensions_.Remove(extension->id()); |
1804 // Remove the extension from our list. | |
1805 extensions_.erase(iter); | |
1806 | 1783 |
1807 NotifyExtensionUnloaded(extension.get(), reason); | 1784 NotifyExtensionUnloaded(extension.get(), reason); |
1808 } | 1785 } |
1809 | 1786 |
1810 void ExtensionService::UnloadAllExtensions() { | 1787 void ExtensionService::UnloadAllExtensions() { |
1811 profile_->GetExtensionSpecialStoragePolicy()-> | 1788 profile_->GetExtensionSpecialStoragePolicy()-> |
1812 RevokeRightsForAllExtensions(); | 1789 RevokeRightsForAllExtensions(); |
1813 | 1790 |
1814 extensions_.clear(); | 1791 extensions_.Clear(); |
1815 disabled_extensions_.clear(); | 1792 disabled_extensions_.Clear(); |
1816 terminated_extension_ids_.clear(); | 1793 terminated_extensions_.Clear(); |
1817 terminated_extensions_.clear(); | |
1818 extension_runtime_data_.clear(); | 1794 extension_runtime_data_.clear(); |
1819 | 1795 |
1820 // TODO(erikkay) should there be a notification for this? We can't use | 1796 // TODO(erikkay) should there be a notification for this? We can't use |
1821 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 1797 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
1822 // or uninstalled, and UnloadAll is just part of shutdown. | 1798 // or uninstalled, and UnloadAll is just part of shutdown. |
1823 } | 1799 } |
1824 | 1800 |
1825 void ExtensionService::ReloadExtensions() { | 1801 void ExtensionService::ReloadExtensions() { |
1826 UnloadAllExtensions(); | 1802 UnloadAllExtensions(); |
1827 component_loader_->LoadAll(); | 1803 component_loader_->LoadAll(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 // If the extension was disabled for a reload, then enable it. | 1867 // If the extension was disabled for a reload, then enable it. |
1892 if (disabled_extension_paths_.erase(extension->id()) > 0) | 1868 if (disabled_extension_paths_.erase(extension->id()) > 0) |
1893 EnableExtension(extension->id()); | 1869 EnableExtension(extension->id()); |
1894 | 1870 |
1895 // Check if the extension's privileges have changed and disable the | 1871 // Check if the extension's privileges have changed and disable the |
1896 // extension if necessary. | 1872 // extension if necessary. |
1897 InitializePermissions(extension); | 1873 InitializePermissions(extension); |
1898 | 1874 |
1899 bool disabled = extension_prefs_->IsExtensionDisabled(extension->id()); | 1875 bool disabled = extension_prefs_->IsExtensionDisabled(extension->id()); |
1900 if (disabled) { | 1876 if (disabled) { |
1901 disabled_extensions_.push_back(scoped_extension); | 1877 disabled_extensions_.Insert(scoped_extension); |
1902 // TODO(aa): This seems dodgy. It seems that AddExtension() could get called | 1878 // TODO(aa): This seems dodgy. AddExtension() could get called with a |
1903 // with a disabled extension for other reasons other than that an update was | 1879 // disabled extension for other reasons other than that an update was |
1904 // disabled. | 1880 // disabled, e.g. as in ExtensionManagementTest.InstallRequiresConfirm. |
1905 content::NotificationService::current()->Notify( | 1881 content::NotificationService::current()->Notify( |
1906 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 1882 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
1907 content::Source<Profile>(profile_), | 1883 content::Source<Profile>(profile_), |
1908 content::Details<const Extension>(extension)); | 1884 content::Details<const Extension>(extension)); |
1909 SyncExtensionChangeIfNeeded(*extension); | 1885 SyncExtensionChangeIfNeeded(*extension); |
1910 return; | 1886 return; |
1911 } | 1887 } |
1912 | 1888 |
1913 extensions_.push_back(scoped_extension); | 1889 extensions_.Insert(scoped_extension); |
1914 SyncExtensionChangeIfNeeded(*extension); | 1890 SyncExtensionChangeIfNeeded(*extension); |
1915 NotifyExtensionLoaded(extension); | 1891 NotifyExtensionLoaded(extension); |
1916 IdentifyAlertableExtensions(); | 1892 IdentifyAlertableExtensions(); |
1917 } | 1893 } |
1918 | 1894 |
1919 void ExtensionService::InitializePermissions(const Extension* extension) { | 1895 void ExtensionService::InitializePermissions(const Extension* extension) { |
1920 // If the extension has used the optional permissions API, it will have a | 1896 // If the extension has used the optional permissions API, it will have a |
1921 // custom set of active permissions defined in the extension prefs. Here, | 1897 // custom set of active permissions defined in the extension prefs. Here, |
1922 // we update the extension's active permissions based on the prefs. | 1898 // we update the extension's active permissions based on the prefs. |
1923 scoped_refptr<ExtensionPermissionSet> active_permissions = | 1899 scoped_refptr<ExtensionPermissionSet> active_permissions = |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 RecordPermissionMessagesHistogram( | 1991 RecordPermissionMessagesHistogram( |
2016 extension, "Extensions.Permissions_AutoDisable"); | 1992 extension, "Extensions.Permissions_AutoDisable"); |
2017 } | 1993 } |
2018 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); | 1994 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); |
2019 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); | 1995 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); |
2020 } | 1996 } |
2021 } | 1997 } |
2022 | 1998 |
2023 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { | 1999 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { |
2024 std::set<std::string> extension_ids; | 2000 std::set<std::string> extension_ids; |
2025 for (size_t i = 0; i < extensions_.size(); ++i) { | 2001 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
2026 if (!extensions_[i]->is_theme() && | 2002 iter != extensions_.end(); ++iter) { |
2027 extensions_[i]->location() != Extension::COMPONENT) | 2003 const Extension* extension = *iter; |
2028 extension_ids.insert(extensions_[i]->id()); | 2004 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) |
| 2005 extension_ids.insert(extension->id()); |
2029 } | 2006 } |
2030 | 2007 |
2031 child_process_logging::SetActiveExtensions(extension_ids); | 2008 child_process_logging::SetActiveExtensions(extension_ids); |
2032 } | 2009 } |
2033 | 2010 |
2034 void ExtensionService::OnExtensionInstalled( | 2011 void ExtensionService::OnExtensionInstalled( |
2035 const Extension* extension, bool from_webstore, int page_index) { | 2012 const Extension* extension, bool from_webstore, int page_index) { |
2036 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2013 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2037 | 2014 |
2038 // Ensure extension is deleted unless we transfer ownership. | 2015 // Ensure extension is deleted unless we transfer ownership. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 | 2088 |
2112 // Transfer ownership of |extension| to AddExtension. | 2089 // Transfer ownership of |extension| to AddExtension. |
2113 AddExtension(scoped_extension); | 2090 AddExtension(scoped_extension); |
2114 } | 2091 } |
2115 | 2092 |
2116 const Extension* ExtensionService::GetExtensionByIdInternal( | 2093 const Extension* ExtensionService::GetExtensionByIdInternal( |
2117 const std::string& id, bool include_enabled, bool include_disabled, | 2094 const std::string& id, bool include_enabled, bool include_disabled, |
2118 bool include_terminated) const { | 2095 bool include_terminated) const { |
2119 std::string lowercase_id = StringToLowerASCII(id); | 2096 std::string lowercase_id = StringToLowerASCII(id); |
2120 if (include_enabled) { | 2097 if (include_enabled) { |
2121 for (ExtensionList::const_iterator iter = extensions_.begin(); | 2098 const Extension* extension = extensions_.GetByID(lowercase_id); |
2122 iter != extensions_.end(); ++iter) { | 2099 if (extension) |
2123 if ((*iter)->id() == lowercase_id) | 2100 return extension; |
2124 return *iter; | |
2125 } | |
2126 } | 2101 } |
2127 if (include_disabled) { | 2102 if (include_disabled) { |
2128 for (ExtensionList::const_iterator iter = disabled_extensions_.begin(); | 2103 const Extension* extension = disabled_extensions_.GetByID(lowercase_id); |
2129 iter != disabled_extensions_.end(); ++iter) { | 2104 if (extension) |
2130 if ((*iter)->id() == lowercase_id) | 2105 return extension; |
2131 return *iter; | |
2132 } | |
2133 } | 2106 } |
2134 if (include_terminated) { | 2107 if (include_terminated) { |
2135 for (ExtensionList::const_iterator iter = terminated_extensions_.begin(); | 2108 const Extension* extension = terminated_extensions_.GetByID(lowercase_id); |
2136 iter != terminated_extensions_.end(); ++iter) { | 2109 if (extension) |
2137 if ((*iter)->id() == lowercase_id) | 2110 return extension; |
2138 return *iter; | |
2139 } | |
2140 } | 2111 } |
2141 return NULL; | 2112 return NULL; |
2142 } | 2113 } |
2143 | 2114 |
2144 void ExtensionService::TrackTerminatedExtension(const Extension* extension) { | 2115 void ExtensionService::TrackTerminatedExtension(const Extension* extension) { |
2145 if (terminated_extension_ids_.insert(extension->id()).second) | 2116 if (!terminated_extensions_.Contains(extension->id())) |
2146 terminated_extensions_.push_back(make_scoped_refptr(extension)); | 2117 terminated_extensions_.Insert(make_scoped_refptr(extension)); |
2147 | 2118 |
2148 // TODO(yoz): Listen to navcontrollers for that extension. Is this a todo? | |
2149 | |
2150 // TODO(yoz): make sure this is okay in *ALL* the listeners! | |
2151 UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE); | 2119 UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE); |
2152 } | 2120 } |
2153 | 2121 |
2154 void ExtensionService::UntrackTerminatedExtension(const std::string& id) { | 2122 void ExtensionService::UntrackTerminatedExtension(const std::string& id) { |
2155 std::string lowercase_id = StringToLowerASCII(id); | 2123 std::string lowercase_id = StringToLowerASCII(id); |
2156 if (terminated_extension_ids_.erase(lowercase_id) <= 0) | 2124 terminated_extensions_.Remove(lowercase_id); |
2157 return; | |
2158 | |
2159 for (ExtensionList::iterator iter = terminated_extensions_.begin(); | |
2160 iter != terminated_extensions_.end(); ++iter) { | |
2161 if ((*iter)->id() == lowercase_id) { | |
2162 terminated_extensions_.erase(iter); | |
2163 return; | |
2164 } | |
2165 } | |
2166 } | 2125 } |
2167 | 2126 |
2168 const Extension* ExtensionService::GetTerminatedExtension( | 2127 const Extension* ExtensionService::GetTerminatedExtension( |
2169 const std::string& id) const { | 2128 const std::string& id) const { |
2170 return GetExtensionByIdInternal(id, false, false, true); | 2129 return GetExtensionByIdInternal(id, false, false, true); |
2171 } | 2130 } |
2172 | 2131 |
2173 const Extension* ExtensionService::GetInstalledExtension( | 2132 const Extension* ExtensionService::GetInstalledExtension( |
2174 const std::string& id) const { | 2133 const std::string& id) const { |
2175 return GetExtensionByIdInternal(id, true, true, true); | 2134 return GetExtensionByIdInternal(id, true, true, true); |
2176 } | 2135 } |
2177 | 2136 |
2178 const Extension* ExtensionService::GetWebStoreApp() { | 2137 const Extension* ExtensionService::GetWebStoreApp() { |
2179 return GetExtensionById(extension_misc::kWebStoreAppId, false); | 2138 return GetExtensionById(extension_misc::kWebStoreAppId, false); |
2180 } | 2139 } |
2181 | 2140 |
2182 const Extension* ExtensionService::GetExtensionByURL(const GURL& url) { | 2141 const Extension* ExtensionService::GetExtensionByURL(const GURL& url) { |
2183 return url.scheme() != chrome::kExtensionScheme ? NULL : | 2142 return url.scheme() != chrome::kExtensionScheme ? NULL : |
2184 GetExtensionById(url.host(), false); | 2143 GetExtensionById(url.host(), false); |
2185 } | 2144 } |
2186 | 2145 |
2187 const Extension* ExtensionService::GetExtensionByWebExtent(const GURL& url) { | 2146 const Extension* ExtensionService::GetExtensionByWebExtent(const GURL& url) { |
2188 for (size_t i = 0; i < extensions_.size(); ++i) { | 2147 // TODO(yoz): Should be ExtensionSet::GetByURL. |
2189 if (extensions_[i]->web_extent().MatchesURL(url)) | 2148 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
2190 return extensions_[i]; | 2149 iter != extensions_.end(); ++iter) { |
| 2150 if ((*iter)->web_extent().MatchesURL(url)) |
| 2151 return *iter; |
2191 } | 2152 } |
2192 return NULL; | 2153 return NULL; |
2193 } | 2154 } |
2194 | 2155 |
2195 const Extension* ExtensionService::GetDisabledExtensionByWebExtent( | 2156 const Extension* ExtensionService::GetDisabledExtensionByWebExtent( |
2196 const GURL& url) { | 2157 const GURL& url) { |
2197 for (size_t i = 0; i < disabled_extensions_.size(); ++i) { | 2158 // TODO(yoz): Should be ExtensionSet::GetByURL. |
2198 if (disabled_extensions_[i]->web_extent().MatchesURL(url)) | 2159 for (ExtensionSet::const_iterator iter = disabled_extensions_.begin(); |
2199 return disabled_extensions_[i]; | 2160 iter != disabled_extensions_.end(); ++iter) { |
| 2161 if ((*iter)->web_extent().MatchesURL(url)) |
| 2162 return *iter; |
2200 } | 2163 } |
2201 return NULL; | 2164 return NULL; |
2202 } | 2165 } |
2203 | 2166 |
2204 bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) { | 2167 bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) { |
2205 // Allow bindings for all packaged extensions. | 2168 // Allow bindings for all packaged extensions. |
2206 // Note that GetExtensionByURL may return an Extension for hosted apps | 2169 // Note that GetExtensionByURL may return an Extension for hosted apps |
2207 // (excluding bookmark apps) if the URL came from GetEffectiveURL. | 2170 // (excluding bookmark apps) if the URL came from GetEffectiveURL. |
2208 const Extension* extension = GetExtensionByURL(url); | 2171 const Extension* extension = GetExtensionByURL(url); |
2209 if (extension && extension->GetType() != Extension::TYPE_HOSTED_APP) | 2172 if (extension && extension->GetType() != Extension::TYPE_HOSTED_APP) |
2210 return true; | 2173 return true; |
2211 | 2174 |
2212 // Allow bindings for all component, hosted apps. | 2175 // Allow bindings for all component, hosted apps. |
2213 if (!extension) | 2176 if (!extension) |
2214 extension = GetExtensionByWebExtent(url); | 2177 extension = GetExtensionByWebExtent(url); |
2215 return (extension && extension->location() == Extension::COMPONENT); | 2178 return (extension && extension->location() == Extension::COMPONENT); |
2216 } | 2179 } |
2217 | 2180 |
2218 const Extension* ExtensionService::GetExtensionByOverlappingWebExtent( | 2181 const Extension* ExtensionService::GetExtensionByOverlappingWebExtent( |
2219 const URLPatternSet& extent) { | 2182 const URLPatternSet& extent) { |
2220 for (size_t i = 0; i < extensions_.size(); ++i) { | 2183 // TODO(yoz): Should be in ExtensionSet. |
2221 if (extensions_[i]->web_extent().OverlapsWith(extent)) | 2184 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
2222 return extensions_[i]; | 2185 iter != extensions_.end(); ++iter) { |
| 2186 if ((*iter)->web_extent().OverlapsWith(extent)) |
| 2187 return *iter; |
2223 } | 2188 } |
2224 | 2189 |
2225 return NULL; | 2190 return NULL; |
2226 } | 2191 } |
2227 | 2192 |
2228 const SkBitmap& ExtensionService::GetOmniboxIcon( | 2193 const SkBitmap& ExtensionService::GetOmniboxIcon( |
2229 const std::string& extension_id) { | 2194 const std::string& extension_id) { |
2230 return omnibox_icon_manager_.GetIcon(extension_id); | 2195 return omnibox_icon_manager_.GetIcon(extension_id); |
2231 } | 2196 } |
2232 | 2197 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); | 2312 ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); |
2348 process->Send(new ExtensionMsg_SetFunctionNames(function_names)); | 2313 process->Send(new ExtensionMsg_SetFunctionNames(function_names)); |
2349 | 2314 |
2350 // Scripting whitelist. This is modified by tests and must be communicated | 2315 // Scripting whitelist. This is modified by tests and must be communicated |
2351 // to renderers. | 2316 // to renderers. |
2352 process->Send(new ExtensionMsg_SetScriptingWhitelist( | 2317 process->Send(new ExtensionMsg_SetScriptingWhitelist( |
2353 *Extension::GetScriptingWhitelist())); | 2318 *Extension::GetScriptingWhitelist())); |
2354 | 2319 |
2355 // Loaded extensions. | 2320 // Loaded extensions. |
2356 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions; | 2321 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions; |
2357 for (size_t i = 0; i < extensions_.size(); ++i) { | 2322 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
2358 loaded_extensions.push_back( | 2323 iter != extensions_.end(); ++iter) { |
2359 ExtensionMsg_Loaded_Params(extensions_[i])); | 2324 loaded_extensions.push_back(ExtensionMsg_Loaded_Params(*iter)); |
2360 } | 2325 } |
2361 process->Send(new ExtensionMsg_Loaded(loaded_extensions)); | 2326 process->Send(new ExtensionMsg_Loaded(loaded_extensions)); |
2362 break; | 2327 break; |
2363 } | 2328 } |
2364 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { | 2329 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { |
2365 content::RenderProcessHost* process = | 2330 content::RenderProcessHost* process = |
2366 content::Source<content::RenderProcessHost>(source).ptr(); | 2331 content::Source<content::RenderProcessHost>(source).ptr(); |
2367 Profile* host_profile = | 2332 Profile* host_profile = |
2368 Profile::FromBrowserContext(process->GetBrowserContext()); | 2333 Profile::FromBrowserContext(process->GetBrowserContext()); |
2369 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) | 2334 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) |
(...skipping 30 matching lines...) Expand all Loading... |
2400 NOTREACHED() << "Unexpected notification type."; | 2365 NOTREACHED() << "Unexpected notification type."; |
2401 } | 2366 } |
2402 } | 2367 } |
2403 | 2368 |
2404 bool ExtensionService::HasApps() const { | 2369 bool ExtensionService::HasApps() const { |
2405 return !GetAppIds().empty(); | 2370 return !GetAppIds().empty(); |
2406 } | 2371 } |
2407 | 2372 |
2408 ExtensionIdSet ExtensionService::GetAppIds() const { | 2373 ExtensionIdSet ExtensionService::GetAppIds() const { |
2409 ExtensionIdSet result; | 2374 ExtensionIdSet result; |
2410 for (ExtensionList::const_iterator it = extensions_.begin(); | 2375 for (ExtensionSet::const_iterator it = extensions_.begin(); |
2411 it != extensions_.end(); ++it) { | 2376 it != extensions_.end(); ++it) { |
2412 if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT) | 2377 if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT) |
2413 result.insert((*it)->id()); | 2378 result.insert((*it)->id()); |
2414 } | 2379 } |
2415 | 2380 |
2416 return result; | 2381 return result; |
2417 } | 2382 } |
2418 | 2383 |
2419 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) { | 2384 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) { |
2420 return (extension->background_url().is_empty() || | 2385 return (extension->background_url().is_empty() || |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 | 2484 |
2520 ExtensionService::NaClModuleInfoList::iterator | 2485 ExtensionService::NaClModuleInfoList::iterator |
2521 ExtensionService::FindNaClModule(const GURL& url) { | 2486 ExtensionService::FindNaClModule(const GURL& url) { |
2522 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2487 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
2523 iter != nacl_module_list_.end(); ++iter) { | 2488 iter != nacl_module_list_.end(); ++iter) { |
2524 if (iter->url == url) | 2489 if (iter->url == url) |
2525 return iter; | 2490 return iter; |
2526 } | 2491 } |
2527 return nacl_module_list_.end(); | 2492 return nacl_module_list_.end(); |
2528 } | 2493 } |
OLD | NEW |