| 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.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 // details. | 570 // details. |
| 571 if (extension && extension->from_bookmark()) | 571 if (extension && extension->from_bookmark()) |
| 572 creation_flags |= Extension::FROM_BOOKMARK; | 572 creation_flags |= Extension::FROM_BOOKMARK; |
| 573 | 573 |
| 574 if (extension && extension->was_installed_by_default()) | 574 if (extension && extension->was_installed_by_default()) |
| 575 creation_flags |= Extension::WAS_INSTALLED_BY_DEFAULT; | 575 creation_flags |= Extension::WAS_INSTALLED_BY_DEFAULT; |
| 576 | 576 |
| 577 if (extension && extension->was_installed_by_oem()) | 577 if (extension && extension->was_installed_by_oem()) |
| 578 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; | 578 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; |
| 579 | 579 |
| 580 if (extension && extension->is_ephemeral()) | 580 if (extension) |
| 581 creation_flags |= Extension::IS_EPHEMERAL; | 581 installer->set_is_ephemeral(extension_prefs_->IsEphemeralApp(id)); |
| 582 | 582 |
| 583 installer->set_creation_flags(creation_flags); | 583 installer->set_creation_flags(creation_flags); |
| 584 | 584 |
| 585 installer->set_delete_source(file_ownership_passed); | 585 installer->set_delete_source(file_ownership_passed); |
| 586 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); | 586 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
| 587 installer->InstallCrx(extension_path); | 587 installer->InstallCrx(extension_path); |
| 588 | 588 |
| 589 if (out_crx_installer) | 589 if (out_crx_installer) |
| 590 *out_crx_installer = installer.get(); | 590 *out_crx_installer = installer.get(); |
| 591 | 591 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 if (!GetFileTaskRunner()->PostTask( | 728 if (!GetFileTaskRunner()->PostTask( |
| 729 FROM_HERE, | 729 FROM_HERE, |
| 730 base::Bind(&extensions::file_util::UninstallExtension, | 730 base::Bind(&extensions::file_util::UninstallExtension, |
| 731 install_directory_, | 731 install_directory_, |
| 732 extension_id))) | 732 extension_id))) |
| 733 NOTREACHED(); | 733 NOTREACHED(); |
| 734 } | 734 } |
| 735 | 735 |
| 736 // Do not remove the data of ephemeral apps. They will be garbage collected by | 736 // Do not remove the data of ephemeral apps. They will be garbage collected by |
| 737 // EphemeralAppService. | 737 // EphemeralAppService. |
| 738 if (!extension->is_ephemeral()) | 738 if (!extension_prefs_->IsEphemeralApp(extension_id)) |
| 739 extensions::DataDeleter::StartDeleting(profile_, extension.get()); | 739 extensions::DataDeleter::StartDeleting(profile_, extension.get()); |
| 740 | 740 |
| 741 UntrackTerminatedExtension(extension_id); | 741 UntrackTerminatedExtension(extension_id); |
| 742 | 742 |
| 743 // Notify interested parties that we've uninstalled this extension. | 743 // Notify interested parties that we've uninstalled this extension. |
| 744 content::NotificationService::current()->Notify( | 744 content::NotificationService::current()->Notify( |
| 745 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 745 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 746 content::Source<Profile>(profile_), | 746 content::Source<Profile>(profile_), |
| 747 content::Details<const Extension>(extension.get())); | 747 content::Details<const Extension>(extension.get())); |
| 748 | 748 |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 | 1536 |
| 1537 VLOG(1) << "AddComponentExtension " << extension->name(); | 1537 VLOG(1) << "AddComponentExtension " << extension->name(); |
| 1538 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { | 1538 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { |
| 1539 VLOG(1) << "Component extension " << extension->name() << " (" | 1539 VLOG(1) << "Component extension " << extension->name() << " (" |
| 1540 << extension->id() << ") installing/upgrading from '" | 1540 << extension->id() << ") installing/upgrading from '" |
| 1541 << old_version_string << "' to " << extension->version()->GetString(); | 1541 << old_version_string << "' to " << extension->version()->GetString(); |
| 1542 | 1542 |
| 1543 AddNewOrUpdatedExtension(extension, | 1543 AddNewOrUpdatedExtension(extension, |
| 1544 Extension::ENABLED_COMPONENT, | 1544 Extension::ENABLED_COMPONENT, |
| 1545 extensions::NOT_BLACKLISTED, | 1545 extensions::NOT_BLACKLISTED, |
| 1546 false, |
| 1546 syncer::StringOrdinal(), | 1547 syncer::StringOrdinal(), |
| 1547 std::string()); | 1548 std::string()); |
| 1548 return; | 1549 return; |
| 1549 } | 1550 } |
| 1550 | 1551 |
| 1551 AddExtension(extension); | 1552 AddExtension(extension); |
| 1552 } | 1553 } |
| 1553 | 1554 |
| 1554 void ExtensionService::UpdateActivePermissions(const Extension* extension) { | 1555 void ExtensionService::UpdateActivePermissions(const Extension* extension) { |
| 1555 // If the extension has used the optional permissions API, it will have a | 1556 // If the extension has used the optional permissions API, it will have a |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 // crash_keys::SetActiveExtensions is per-process. See | 1703 // crash_keys::SetActiveExtensions is per-process. See |
| 1703 // http://crbug.com/355029. | 1704 // http://crbug.com/355029. |
| 1704 crash_keys::SetActiveExtensions(extension_ids); | 1705 crash_keys::SetActiveExtensions(extension_ids); |
| 1705 } | 1706 } |
| 1706 | 1707 |
| 1707 void ExtensionService::OnExtensionInstalled( | 1708 void ExtensionService::OnExtensionInstalled( |
| 1708 const Extension* extension, | 1709 const Extension* extension, |
| 1709 const syncer::StringOrdinal& page_ordinal, | 1710 const syncer::StringOrdinal& page_ordinal, |
| 1710 bool has_requirement_errors, | 1711 bool has_requirement_errors, |
| 1711 extensions::BlacklistState blacklist_state, | 1712 extensions::BlacklistState blacklist_state, |
| 1713 bool is_ephemeral, |
| 1712 bool wait_for_idle) { | 1714 bool wait_for_idle) { |
| 1713 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1715 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1714 | 1716 |
| 1715 const std::string& id = extension->id(); | 1717 const std::string& id = extension->id(); |
| 1716 bool initial_enable = ShouldEnableOnInstall(extension); | 1718 bool initial_enable = ShouldEnableOnInstall(extension); |
| 1717 std::string install_parameter; | 1719 std::string install_parameter; |
| 1718 const extensions::PendingExtensionInfo* pending_extension_info = NULL; | 1720 const extensions::PendingExtensionInfo* pending_extension_info = NULL; |
| 1719 if ((pending_extension_info = pending_extension_manager()->GetById(id))) { | 1721 if ((pending_extension_info = pending_extension_manager()->GetById(id))) { |
| 1720 if (!pending_extension_info->ShouldAllowInstall(extension)) { | 1722 if (!pending_extension_info->ShouldAllowInstall(extension)) { |
| 1721 pending_extension_manager()->Remove(id); | 1723 pending_extension_manager()->Remove(id); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 AcknowledgeExternalExtension(extension->id()); | 1798 AcknowledgeExternalExtension(extension->id()); |
| 1797 const Extension::State initial_state = | 1799 const Extension::State initial_state = |
| 1798 initial_enable ? Extension::ENABLED : Extension::DISABLED; | 1800 initial_enable ? Extension::ENABLED : Extension::DISABLED; |
| 1799 const bool blacklisted_for_malware = | 1801 const bool blacklisted_for_malware = |
| 1800 blacklist_state == extensions::BLACKLISTED_MALWARE; | 1802 blacklist_state == extensions::BLACKLISTED_MALWARE; |
| 1801 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { | 1803 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { |
| 1802 extension_prefs_->SetDelayedInstallInfo( | 1804 extension_prefs_->SetDelayedInstallInfo( |
| 1803 extension, | 1805 extension, |
| 1804 initial_state, | 1806 initial_state, |
| 1805 blacklisted_for_malware, | 1807 blacklisted_for_malware, |
| 1808 is_ephemeral, |
| 1806 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, | 1809 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, |
| 1807 page_ordinal, | 1810 page_ordinal, |
| 1808 install_parameter); | 1811 install_parameter); |
| 1809 | 1812 |
| 1810 // Transfer ownership of |extension|. | 1813 // Transfer ownership of |extension|. |
| 1811 delayed_installs_.Insert(extension); | 1814 delayed_installs_.Insert(extension); |
| 1812 | 1815 |
| 1813 // Notify observers that app update is available. | 1816 // Notify observers that app update is available. |
| 1814 FOR_EACH_OBSERVER(extensions::UpdateObserver, update_observers_, | 1817 FOR_EACH_OBSERVER(extensions::UpdateObserver, update_observers_, |
| 1815 OnAppUpdateAvailable(extension)); | 1818 OnAppUpdateAvailable(extension)); |
| 1816 return; | 1819 return; |
| 1817 } | 1820 } |
| 1818 | 1821 |
| 1819 extensions::SharedModuleService::ImportStatus status = | 1822 extensions::SharedModuleService::ImportStatus status = |
| 1820 shared_module_service_->SatisfyImports(extension); | 1823 shared_module_service_->SatisfyImports(extension); |
| 1821 if (installs_delayed_for_gc_) { | 1824 if (installs_delayed_for_gc_) { |
| 1822 extension_prefs_->SetDelayedInstallInfo( | 1825 extension_prefs_->SetDelayedInstallInfo( |
| 1823 extension, | 1826 extension, |
| 1824 initial_state, | 1827 initial_state, |
| 1825 blacklisted_for_malware, | 1828 blacklisted_for_malware, |
| 1829 is_ephemeral, |
| 1826 extensions::ExtensionPrefs::DELAY_REASON_GC, | 1830 extensions::ExtensionPrefs::DELAY_REASON_GC, |
| 1827 page_ordinal, | 1831 page_ordinal, |
| 1828 install_parameter); | 1832 install_parameter); |
| 1829 delayed_installs_.Insert(extension); | 1833 delayed_installs_.Insert(extension); |
| 1830 } else if (status != SharedModuleService::IMPORT_STATUS_OK) { | 1834 } else if (status != SharedModuleService::IMPORT_STATUS_OK) { |
| 1831 if (status == SharedModuleService::IMPORT_STATUS_UNSATISFIED) { | 1835 if (status == SharedModuleService::IMPORT_STATUS_UNSATISFIED) { |
| 1832 extension_prefs_->SetDelayedInstallInfo( | 1836 extension_prefs_->SetDelayedInstallInfo( |
| 1833 extension, | 1837 extension, |
| 1834 initial_state, | 1838 initial_state, |
| 1835 blacklisted_for_malware, | 1839 blacklisted_for_malware, |
| 1840 is_ephemeral, |
| 1836 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS, | 1841 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS, |
| 1837 page_ordinal, | 1842 page_ordinal, |
| 1838 install_parameter); | 1843 install_parameter); |
| 1839 delayed_installs_.Insert(extension); | 1844 delayed_installs_.Insert(extension); |
| 1840 } | 1845 } |
| 1841 } else { | 1846 } else { |
| 1842 AddNewOrUpdatedExtension(extension, | 1847 AddNewOrUpdatedExtension(extension, |
| 1843 initial_state, | 1848 initial_state, |
| 1844 blacklist_state, | 1849 blacklist_state, |
| 1850 is_ephemeral, |
| 1845 page_ordinal, | 1851 page_ordinal, |
| 1846 install_parameter); | 1852 install_parameter); |
| 1847 } | 1853 } |
| 1848 } | 1854 } |
| 1849 | 1855 |
| 1850 void ExtensionService::AddNewOrUpdatedExtension( | 1856 void ExtensionService::AddNewOrUpdatedExtension( |
| 1851 const Extension* extension, | 1857 const Extension* extension, |
| 1852 Extension::State initial_state, | 1858 Extension::State initial_state, |
| 1853 extensions::BlacklistState blacklist_state, | 1859 extensions::BlacklistState blacklist_state, |
| 1860 bool is_ephemeral, |
| 1854 const syncer::StringOrdinal& page_ordinal, | 1861 const syncer::StringOrdinal& page_ordinal, |
| 1855 const std::string& install_parameter) { | 1862 const std::string& install_parameter) { |
| 1856 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1863 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1857 const bool blacklisted_for_malware = | 1864 const bool blacklisted_for_malware = |
| 1858 blacklist_state == extensions::BLACKLISTED_MALWARE; | 1865 blacklist_state == extensions::BLACKLISTED_MALWARE; |
| 1859 extension_prefs_->OnExtensionInstalled(extension, | 1866 extension_prefs_->OnExtensionInstalled(extension, |
| 1860 initial_state, | 1867 initial_state, |
| 1861 blacklisted_for_malware, | 1868 blacklisted_for_malware, |
| 1869 is_ephemeral, |
| 1862 page_ordinal, | 1870 page_ordinal, |
| 1863 install_parameter); | 1871 install_parameter); |
| 1864 delayed_installs_.Remove(extension->id()); | 1872 delayed_installs_.Remove(extension->id()); |
| 1865 if (InstallVerifier::NeedsVerification(*extension)) | 1873 if (InstallVerifier::NeedsVerification(*extension)) |
| 1866 system_->install_verifier()->VerifyExtension(extension->id()); | 1874 system_->install_verifier()->VerifyExtension(extension->id()); |
| 1867 FinishInstallation(extension); | 1875 FinishInstallation(extension); |
| 1868 } | 1876 } |
| 1869 | 1877 |
| 1870 void ExtensionService::MaybeFinishDelayedInstallation( | 1878 void ExtensionService::MaybeFinishDelayedInstallation( |
| 1871 const std::string& extension_id) { | 1879 const std::string& extension_id) { |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2421 void ExtensionService::UnloadAllExtensionsInternal() { | 2429 void ExtensionService::UnloadAllExtensionsInternal() { |
| 2422 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2430 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
| 2423 | 2431 |
| 2424 registry_->ClearAll(); | 2432 registry_->ClearAll(); |
| 2425 system_->runtime_data()->ClearAll(); | 2433 system_->runtime_data()->ClearAll(); |
| 2426 | 2434 |
| 2427 // TODO(erikkay) should there be a notification for this? We can't use | 2435 // TODO(erikkay) should there be a notification for this? We can't use |
| 2428 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2436 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
| 2429 // or uninstalled. | 2437 // or uninstalled. |
| 2430 } | 2438 } |
| OLD | NEW |