Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 282103003: Moved IS_EPHEMERAL flag to extension prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor refactoring. Added comments. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 // details. 568 // details.
569 if (extension && extension->from_bookmark()) 569 if (extension && extension->from_bookmark())
570 creation_flags |= Extension::FROM_BOOKMARK; 570 creation_flags |= Extension::FROM_BOOKMARK;
571 571
572 if (extension && extension->was_installed_by_default()) 572 if (extension && extension->was_installed_by_default())
573 creation_flags |= Extension::WAS_INSTALLED_BY_DEFAULT; 573 creation_flags |= Extension::WAS_INSTALLED_BY_DEFAULT;
574 574
575 if (extension && extension->was_installed_by_oem()) 575 if (extension && extension->was_installed_by_oem())
576 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; 576 creation_flags |= Extension::WAS_INSTALLED_BY_OEM;
577 577
578 if (extension && extension->is_ephemeral()) 578 if (extension)
579 creation_flags |= Extension::IS_EPHEMERAL; 579 installer->set_is_ephemeral(extension_prefs_->IsEphemeralApp(id));
580 580
581 installer->set_creation_flags(creation_flags); 581 installer->set_creation_flags(creation_flags);
582 582
583 installer->set_delete_source(file_ownership_passed); 583 installer->set_delete_source(file_ownership_passed);
584 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); 584 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE);
585 installer->InstallCrx(extension_path); 585 installer->InstallCrx(extension_path);
586 586
587 if (out_crx_installer) 587 if (out_crx_installer)
588 *out_crx_installer = installer.get(); 588 *out_crx_installer = installer.get();
589 589
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 if (!GetFileTaskRunner()->PostTask( 726 if (!GetFileTaskRunner()->PostTask(
727 FROM_HERE, 727 FROM_HERE,
728 base::Bind(&extensions::file_util::UninstallExtension, 728 base::Bind(&extensions::file_util::UninstallExtension,
729 install_directory_, 729 install_directory_,
730 extension_id))) 730 extension_id)))
731 NOTREACHED(); 731 NOTREACHED();
732 } 732 }
733 733
734 // Do not remove the data of ephemeral apps. They will be garbage collected by 734 // Do not remove the data of ephemeral apps. They will be garbage collected by
735 // EphemeralAppService. 735 // EphemeralAppService.
736 if (!extension->is_ephemeral()) 736 if (!extension_prefs_->IsEphemeralApp(extension_id))
737 extensions::DataDeleter::StartDeleting(profile_, extension.get()); 737 extensions::DataDeleter::StartDeleting(profile_, extension.get());
738 738
739 UntrackTerminatedExtension(extension_id); 739 UntrackTerminatedExtension(extension_id);
740 740
741 // Notify interested parties that we've uninstalled this extension. 741 // Notify interested parties that we've uninstalled this extension.
742 content::NotificationService::current()->Notify( 742 content::NotificationService::current()->Notify(
743 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 743 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
744 content::Source<Profile>(profile_), 744 content::Source<Profile>(profile_),
745 content::Details<const Extension>(extension.get())); 745 content::Details<const Extension>(extension.get()));
746 746
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 1528
1529 VLOG(1) << "AddComponentExtension " << extension->name(); 1529 VLOG(1) << "AddComponentExtension " << extension->name();
1530 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { 1530 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) {
1531 VLOG(1) << "Component extension " << extension->name() << " (" 1531 VLOG(1) << "Component extension " << extension->name() << " ("
1532 << extension->id() << ") installing/upgrading from '" 1532 << extension->id() << ") installing/upgrading from '"
1533 << old_version_string << "' to " << extension->version()->GetString(); 1533 << old_version_string << "' to " << extension->version()->GetString();
1534 1534
1535 AddNewOrUpdatedExtension(extension, 1535 AddNewOrUpdatedExtension(extension,
1536 Extension::ENABLED_COMPONENT, 1536 Extension::ENABLED_COMPONENT,
1537 extensions::NOT_BLACKLISTED, 1537 extensions::NOT_BLACKLISTED,
1538 false,
1538 syncer::StringOrdinal(), 1539 syncer::StringOrdinal(),
1539 std::string()); 1540 std::string());
1540 return; 1541 return;
1541 } 1542 }
1542 1543
1543 AddExtension(extension); 1544 AddExtension(extension);
1544 } 1545 }
1545 1546
1546 void ExtensionService::UpdateActivePermissions(const Extension* extension) { 1547 void ExtensionService::UpdateActivePermissions(const Extension* extension) {
1547 // If the extension has used the optional permissions API, it will have a 1548 // If the extension has used the optional permissions API, it will have a
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 // crash_keys::SetActiveExtensions is per-process. See 1690 // crash_keys::SetActiveExtensions is per-process. See
1690 // http://crbug.com/355029. 1691 // http://crbug.com/355029.
1691 crash_keys::SetActiveExtensions(extension_ids); 1692 crash_keys::SetActiveExtensions(extension_ids);
1692 } 1693 }
1693 1694
1694 void ExtensionService::OnExtensionInstalled( 1695 void ExtensionService::OnExtensionInstalled(
1695 const Extension* extension, 1696 const Extension* extension,
1696 const syncer::StringOrdinal& page_ordinal, 1697 const syncer::StringOrdinal& page_ordinal,
1697 bool has_requirement_errors, 1698 bool has_requirement_errors,
1698 extensions::BlacklistState blacklist_state, 1699 extensions::BlacklistState blacklist_state,
1700 bool is_ephemeral,
benwells 2014/05/19 02:06:53 Could we make ephemerality less central? Do you h
tmdiep 2014/05/19 02:51:16 That would be quite nice actually. One problem is
1699 bool wait_for_idle) { 1701 bool wait_for_idle) {
1700 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1702 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1701 1703
1702 const std::string& id = extension->id(); 1704 const std::string& id = extension->id();
1703 bool initial_enable = ShouldEnableOnInstall(extension); 1705 bool initial_enable = ShouldEnableOnInstall(extension);
1704 std::string install_parameter; 1706 std::string install_parameter;
1705 const extensions::PendingExtensionInfo* pending_extension_info = NULL; 1707 const extensions::PendingExtensionInfo* pending_extension_info = NULL;
1706 if ((pending_extension_info = pending_extension_manager()->GetById(id))) { 1708 if ((pending_extension_info = pending_extension_manager()->GetById(id))) {
1707 if (!pending_extension_info->ShouldAllowInstall(extension)) { 1709 if (!pending_extension_info->ShouldAllowInstall(extension)) {
1708 pending_extension_manager()->Remove(id); 1710 pending_extension_manager()->Remove(id);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 AcknowledgeExternalExtension(extension->id()); 1785 AcknowledgeExternalExtension(extension->id());
1784 const Extension::State initial_state = 1786 const Extension::State initial_state =
1785 initial_enable ? Extension::ENABLED : Extension::DISABLED; 1787 initial_enable ? Extension::ENABLED : Extension::DISABLED;
1786 const bool blacklisted_for_malware = 1788 const bool blacklisted_for_malware =
1787 blacklist_state == extensions::BLACKLISTED_MALWARE; 1789 blacklist_state == extensions::BLACKLISTED_MALWARE;
1788 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { 1790 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) {
1789 extension_prefs_->SetDelayedInstallInfo( 1791 extension_prefs_->SetDelayedInstallInfo(
1790 extension, 1792 extension,
1791 initial_state, 1793 initial_state,
1792 blacklisted_for_malware, 1794 blacklisted_for_malware,
1795 is_ephemeral,
1793 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, 1796 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE,
1794 page_ordinal, 1797 page_ordinal,
1795 install_parameter); 1798 install_parameter);
1796 1799
1797 // Transfer ownership of |extension|. 1800 // Transfer ownership of |extension|.
1798 delayed_installs_.Insert(extension); 1801 delayed_installs_.Insert(extension);
1799 1802
1800 // Notify observers that app update is available. 1803 // Notify observers that app update is available.
1801 FOR_EACH_OBSERVER(extensions::UpdateObserver, update_observers_, 1804 FOR_EACH_OBSERVER(extensions::UpdateObserver, update_observers_,
1802 OnAppUpdateAvailable(extension)); 1805 OnAppUpdateAvailable(extension));
1803 return; 1806 return;
1804 } 1807 }
1805 1808
1806 extensions::SharedModuleService::ImportStatus status = 1809 extensions::SharedModuleService::ImportStatus status =
1807 shared_module_service_->SatisfyImports(extension); 1810 shared_module_service_->SatisfyImports(extension);
1808 if (installs_delayed_for_gc_) { 1811 if (installs_delayed_for_gc_) {
1809 extension_prefs_->SetDelayedInstallInfo( 1812 extension_prefs_->SetDelayedInstallInfo(
1810 extension, 1813 extension,
1811 initial_state, 1814 initial_state,
1812 blacklisted_for_malware, 1815 blacklisted_for_malware,
1816 is_ephemeral,
1813 extensions::ExtensionPrefs::DELAY_REASON_GC, 1817 extensions::ExtensionPrefs::DELAY_REASON_GC,
1814 page_ordinal, 1818 page_ordinal,
1815 install_parameter); 1819 install_parameter);
1816 delayed_installs_.Insert(extension); 1820 delayed_installs_.Insert(extension);
1817 } else if (status != SharedModuleService::IMPORT_STATUS_OK) { 1821 } else if (status != SharedModuleService::IMPORT_STATUS_OK) {
1818 if (status == SharedModuleService::IMPORT_STATUS_UNSATISFIED) { 1822 if (status == SharedModuleService::IMPORT_STATUS_UNSATISFIED) {
1819 extension_prefs_->SetDelayedInstallInfo( 1823 extension_prefs_->SetDelayedInstallInfo(
1820 extension, 1824 extension,
1821 initial_state, 1825 initial_state,
1822 blacklisted_for_malware, 1826 blacklisted_for_malware,
1827 is_ephemeral,
1823 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS, 1828 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS,
1824 page_ordinal, 1829 page_ordinal,
1825 install_parameter); 1830 install_parameter);
1826 delayed_installs_.Insert(extension); 1831 delayed_installs_.Insert(extension);
1827 } 1832 }
1828 } else { 1833 } else {
1829 AddNewOrUpdatedExtension(extension, 1834 AddNewOrUpdatedExtension(extension,
1830 initial_state, 1835 initial_state,
1831 blacklist_state, 1836 blacklist_state,
1837 is_ephemeral,
1832 page_ordinal, 1838 page_ordinal,
1833 install_parameter); 1839 install_parameter);
1834 } 1840 }
1835 } 1841 }
1836 1842
1837 void ExtensionService::AddNewOrUpdatedExtension( 1843 void ExtensionService::AddNewOrUpdatedExtension(
1838 const Extension* extension, 1844 const Extension* extension,
1839 Extension::State initial_state, 1845 Extension::State initial_state,
1840 extensions::BlacklistState blacklist_state, 1846 extensions::BlacklistState blacklist_state,
1847 bool is_ephemeral,
1841 const syncer::StringOrdinal& page_ordinal, 1848 const syncer::StringOrdinal& page_ordinal,
1842 const std::string& install_parameter) { 1849 const std::string& install_parameter) {
1843 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1850 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1844 const bool blacklisted_for_malware = 1851 const bool blacklisted_for_malware =
1845 blacklist_state == extensions::BLACKLISTED_MALWARE; 1852 blacklist_state == extensions::BLACKLISTED_MALWARE;
1846 extension_prefs_->OnExtensionInstalled(extension, 1853 extension_prefs_->OnExtensionInstalled(extension,
1847 initial_state, 1854 initial_state,
1848 blacklisted_for_malware, 1855 blacklisted_for_malware,
1856 is_ephemeral,
1849 page_ordinal, 1857 page_ordinal,
1850 install_parameter); 1858 install_parameter);
1851 delayed_installs_.Remove(extension->id()); 1859 delayed_installs_.Remove(extension->id());
1852 if (InstallVerifier::NeedsVerification(*extension)) 1860 if (InstallVerifier::NeedsVerification(*extension))
1853 system_->install_verifier()->VerifyExtension(extension->id()); 1861 system_->install_verifier()->VerifyExtension(extension->id());
1854 FinishInstallation(extension); 1862 FinishInstallation(extension);
1855 } 1863 }
1856 1864
1857 void ExtensionService::MaybeFinishDelayedInstallation( 1865 void ExtensionService::MaybeFinishDelayedInstallation(
1858 const std::string& extension_id) { 1866 const std::string& extension_id) {
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 void ExtensionService::UnloadAllExtensionsInternal() { 2416 void ExtensionService::UnloadAllExtensionsInternal() {
2409 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); 2417 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions();
2410 2418
2411 registry_->ClearAll(); 2419 registry_->ClearAll();
2412 system_->runtime_data()->ClearAll(); 2420 system_->runtime_data()->ClearAll();
2413 2421
2414 // TODO(erikkay) should there be a notification for this? We can't use 2422 // TODO(erikkay) should there be a notification for this? We can't use
2415 // EXTENSION_UNLOADED since that implies that the extension has been disabled 2423 // EXTENSION_UNLOADED since that implies that the extension has been disabled
2416 // or uninstalled. 2424 // or uninstalled.
2417 } 2425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698