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

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

Issue 16295003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 creation_flags |= Extension::WAS_INSTALLED_BY_DEFAULT; 659 creation_flags |= Extension::WAS_INSTALLED_BY_DEFAULT;
660 660
661 installer->set_creation_flags(creation_flags); 661 installer->set_creation_flags(creation_flags);
662 662
663 installer->set_delete_source(true); 663 installer->set_delete_source(true);
664 installer->set_download_url(download_url); 664 installer->set_download_url(download_url);
665 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); 665 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE);
666 installer->InstallCrx(extension_path); 666 installer->InstallCrx(extension_path);
667 667
668 if (out_crx_installer) 668 if (out_crx_installer)
669 *out_crx_installer = installer; 669 *out_crx_installer = installer.get();
670 670
671 return true; 671 return true;
672 } 672 }
673 673
674 void ExtensionService::ReloadExtension(const std::string& extension_id) { 674 void ExtensionService::ReloadExtension(const std::string& extension_id) {
675 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 675 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
676 676
677 // If the extension is already reloading, don't reload again. 677 // If the extension is already reloading, don't reload again.
678 if (extension_prefs_->GetDisableReasons(extension_id) & 678 if (extension_prefs_->GetDisableReasons(extension_id) &
679 Extension::DISABLE_RELOAD) { 679 Extension::DISABLE_RELOAD) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 737
738 bool ExtensionService::UninstallExtension( 738 bool ExtensionService::UninstallExtension(
739 std::string extension_id, 739 std::string extension_id,
740 bool external_uninstall, 740 bool external_uninstall,
741 string16* error) { 741 string16* error) {
742 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 742 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
743 743
744 scoped_refptr<const Extension> extension(GetInstalledExtension(extension_id)); 744 scoped_refptr<const Extension> extension(GetInstalledExtension(extension_id));
745 745
746 // Callers should not send us nonexistent extensions. 746 // Callers should not send us nonexistent extensions.
747 CHECK(extension); 747 CHECK(extension.get());
748 748
749 // Policy change which triggers an uninstall will always set 749 // Policy change which triggers an uninstall will always set
750 // |external_uninstall| to true so this is the only way to uninstall 750 // |external_uninstall| to true so this is the only way to uninstall
751 // managed extensions. 751 // managed extensions.
752 if (!external_uninstall && 752 if (!external_uninstall &&
753 !system_->management_policy()->UserMayModifySettings( 753 !system_->management_policy()->UserMayModifySettings(
754 extension.get(), error)) { 754 extension.get(), error)) {
755 content::NotificationService::current()->Notify( 755 content::NotificationService::current()->Notify(
756 chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, 756 chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED,
757 content::Source<Profile>(profile_), 757 content::Source<Profile>(profile_),
758 content::Details<const Extension>(extension)); 758 content::Details<const Extension>(extension.get()));
759 return false; 759 return false;
760 } 760 }
761 761
762 // Extract the data we need for sync now, but don't actually sync until we've 762 // Extract the data we need for sync now, but don't actually sync until we've
763 // completed the uninstallation. 763 // completed the uninstallation.
764 syncer::SyncChange sync_change; 764 syncer::SyncChange sync_change;
765 if (app_sync_bundle_.HandlesApp(*extension)) { 765 if (app_sync_bundle_.HandlesApp(*extension.get())) {
766 sync_change = app_sync_bundle_.CreateSyncChangeToDelete(extension); 766 sync_change = app_sync_bundle_.CreateSyncChangeToDelete(extension.get());
767 } else if (extension_sync_bundle_.HandlesExtension(*extension)) { 767 } else if (extension_sync_bundle_.HandlesExtension(*extension.get())) {
768 sync_change = extension_sync_bundle_.CreateSyncChangeToDelete(extension); 768 sync_change =
769 extension_sync_bundle_.CreateSyncChangeToDelete(extension.get());
769 } 770 }
770 771
771 if (IsUnacknowledgedExternalExtension(extension)) { 772 if (IsUnacknowledgedExternalExtension(extension.get())) {
772 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", 773 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent",
773 EXTERNAL_EXTENSION_UNINSTALLED, 774 EXTERNAL_EXTENSION_UNINSTALLED,
774 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); 775 EXTERNAL_EXTENSION_BUCKET_BOUNDARY);
775 } 776 }
776 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", 777 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType",
777 extension->GetType(), 100); 778 extension->GetType(), 100);
778 RecordPermissionMessagesHistogram( 779 RecordPermissionMessagesHistogram(extension.get(),
779 extension, "Extensions.Permissions_Uninstall"); 780 "Extensions.Permissions_Uninstall");
780 781
781 // Unload before doing more cleanup to ensure that nothing is hanging on to 782 // Unload before doing more cleanup to ensure that nothing is hanging on to
782 // any of these resources. 783 // any of these resources.
783 UnloadExtension(extension_id, extension_misc::UNLOAD_REASON_UNINSTALL); 784 UnloadExtension(extension_id, extension_misc::UNLOAD_REASON_UNINSTALL);
784 785
785 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), 786 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(),
786 external_uninstall); 787 external_uninstall);
787 788
788 // Tell the backend to start deleting installed extensions on the file thread. 789 // Tell the backend to start deleting installed extensions on the file thread.
789 if (!Manifest::IsUnpackedLocation(extension->location())) { 790 if (!Manifest::IsUnpackedLocation(extension->location())) {
790 if (!GetFileTaskRunner()->PostTask( 791 if (!GetFileTaskRunner()->PostTask(
791 FROM_HERE, 792 FROM_HERE,
792 base::Bind( 793 base::Bind(
793 &extension_file_util::UninstallExtension, 794 &extension_file_util::UninstallExtension,
794 install_directory_, 795 install_directory_,
795 extension_id))) 796 extension_id)))
796 NOTREACHED(); 797 NOTREACHED();
797 } 798 }
798 799
799 GURL launch_web_url_origin(extension->launch_web_url()); 800 GURL launch_web_url_origin(extension->launch_web_url());
800 launch_web_url_origin = launch_web_url_origin.GetOrigin(); 801 launch_web_url_origin = launch_web_url_origin.GetOrigin();
801 bool is_storage_isolated = 802 bool is_storage_isolated =
802 extensions::AppIsolationInfo::HasIsolatedStorage(extension); 803 extensions::AppIsolationInfo::HasIsolatedStorage(extension.get());
803 804
804 if (is_storage_isolated) { 805 if (is_storage_isolated) {
805 BrowserContext::AsyncObliterateStoragePartition( 806 BrowserContext::AsyncObliterateStoragePartition(
806 profile_, 807 profile_,
807 GetSiteForExtensionId(extension_id), 808 GetSiteForExtensionId(extension_id),
808 base::Bind(&ExtensionService::OnNeedsToGarbageCollectIsolatedStorage, 809 base::Bind(&ExtensionService::OnNeedsToGarbageCollectIsolatedStorage,
809 AsWeakPtr())); 810 AsWeakPtr()));
810 } else { 811 } else {
811 if (extension->is_hosted_app() && 812 if (extension->is_hosted_app() &&
812 !profile_->GetExtensionSpecialStoragePolicy()-> 813 !profile_->GetExtensionSpecialStoragePolicy()->
813 IsStorageProtected(launch_web_url_origin)) { 814 IsStorageProtected(launch_web_url_origin)) {
814 extensions::DataDeleter::StartDeleting( 815 extensions::DataDeleter::StartDeleting(
815 profile_, extension_id, launch_web_url_origin); 816 profile_, extension_id, launch_web_url_origin);
816 } 817 }
817 extensions::DataDeleter::StartDeleting(profile_, extension_id, 818 extensions::DataDeleter::StartDeleting(profile_, extension_id,
818 extension->url()); 819 extension->url());
819 } 820 }
820 821
821 UntrackTerminatedExtension(extension_id); 822 UntrackTerminatedExtension(extension_id);
822 823
823 // Notify interested parties that we've uninstalled this extension. 824 // Notify interested parties that we've uninstalled this extension.
824 content::NotificationService::current()->Notify( 825 content::NotificationService::current()->Notify(
825 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 826 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
826 content::Source<Profile>(profile_), 827 content::Source<Profile>(profile_),
827 content::Details<const Extension>(extension)); 828 content::Details<const Extension>(extension.get()));
828 829
829 if (app_sync_bundle_.HasExtensionId(extension_id) && 830 if (app_sync_bundle_.HasExtensionId(extension_id) &&
830 sync_change.sync_data().GetDataType() == syncer::APPS) { 831 sync_change.sync_data().GetDataType() == syncer::APPS) {
831 app_sync_bundle_.ProcessDeletion(extension_id, sync_change); 832 app_sync_bundle_.ProcessDeletion(extension_id, sync_change);
832 } else if (extension_sync_bundle_.HasExtensionId(extension_id) && 833 } else if (extension_sync_bundle_.HasExtensionId(extension_id) &&
833 sync_change.sync_data().GetDataType() == syncer::EXTENSIONS) { 834 sync_change.sync_data().GetDataType() == syncer::EXTENSIONS) {
834 extension_sync_bundle_.ProcessDeletion(extension_id, sync_change); 835 extension_sync_bundle_.ProcessDeletion(extension_id, sync_change);
835 } 836 }
836 837
837 delayed_updates_for_idle_.Remove(extension_id); 838 delayed_updates_for_idle_.Remove(extension_id);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 1130
1130 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { 1131 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() {
1131 return extension_prefs()->content_settings_store(); 1132 return extension_prefs()->content_settings_store();
1132 } 1133 }
1133 1134
1134 bool ExtensionService::is_ready() { 1135 bool ExtensionService::is_ready() {
1135 return ready_->is_signaled(); 1136 return ready_->is_signaled();
1136 } 1137 }
1137 1138
1138 base::SequencedTaskRunner* ExtensionService::GetFileTaskRunner() { 1139 base::SequencedTaskRunner* ExtensionService::GetFileTaskRunner() {
1139 if (file_task_runner_) 1140 if (file_task_runner_.get())
1140 return file_task_runner_; 1141 return file_task_runner_.get();
1141 1142
1142 // We should be able to interrupt any part of extension install process during 1143 // We should be able to interrupt any part of extension install process during
1143 // shutdown. SKIP_ON_SHUTDOWN ensures that not started extension install tasks 1144 // shutdown. SKIP_ON_SHUTDOWN ensures that not started extension install tasks
1144 // will be ignored/deleted while we will block on started tasks. 1145 // will be ignored/deleted while we will block on started tasks.
1145 std::string token("ext_install-"); 1146 std::string token("ext_install-");
1146 token.append(profile_->GetPath().AsUTF8Unsafe()); 1147 token.append(profile_->GetPath().AsUTF8Unsafe());
1147 file_task_runner_ = BrowserThread::GetBlockingPool()-> 1148 file_task_runner_ = BrowserThread::GetBlockingPool()->
1148 GetSequencedTaskRunnerWithShutdownBehavior( 1149 GetSequencedTaskRunnerWithShutdownBehavior(
1149 BrowserThread::GetBlockingPool()->GetNamedSequenceToken(token), 1150 BrowserThread::GetBlockingPool()->GetNamedSequenceToken(token),
1150 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 1151 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
1151 return file_task_runner_; 1152 return file_task_runner_.get();
1152 } 1153 }
1153 1154
1154 extensions::ExtensionUpdater* ExtensionService::updater() { 1155 extensions::ExtensionUpdater* ExtensionService::updater() {
1155 return updater_.get(); 1156 return updater_.get();
1156 } 1157 }
1157 1158
1158 void ExtensionService::CheckManagementPolicy() { 1159 void ExtensionService::CheckManagementPolicy() {
1159 std::vector<std::string> to_be_removed; 1160 std::vector<std::string> to_be_removed;
1160 1161
1161 // Loop through extensions list, unload installed extensions. 1162 // Loop through extensions list, unload installed extensions.
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 void ExtensionService::UnloadExtension( 1795 void ExtensionService::UnloadExtension(
1795 const std::string& extension_id, 1796 const std::string& extension_id,
1796 extension_misc::UnloadedExtensionReason reason) { 1797 extension_misc::UnloadedExtensionReason reason) {
1797 // Make sure the extension gets deleted after we return from this function. 1798 // Make sure the extension gets deleted after we return from this function.
1798 int include_mask = INCLUDE_EVERYTHING & ~INCLUDE_TERMINATED; 1799 int include_mask = INCLUDE_EVERYTHING & ~INCLUDE_TERMINATED;
1799 scoped_refptr<const Extension> extension( 1800 scoped_refptr<const Extension> extension(
1800 GetExtensionById(extension_id, include_mask)); 1801 GetExtensionById(extension_id, include_mask));
1801 1802
1802 // This method can be called via PostTask, so the extension may have been 1803 // This method can be called via PostTask, so the extension may have been
1803 // unloaded by the time this runs. 1804 // unloaded by the time this runs.
1804 if (!extension) { 1805 if (!extension.get()) {
1805 // In case the extension may have crashed/uninstalled. Allow the profile to 1806 // In case the extension may have crashed/uninstalled. Allow the profile to
1806 // clean up its RequestContexts. 1807 // clean up its RequestContexts.
1807 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); 1808 system_->UnregisterExtensionWithRequestContexts(extension_id, reason);
1808 return; 1809 return;
1809 } 1810 }
1810 1811
1811 // If uninstalling let RuntimeEventRouter know. 1812 // If uninstalling let RuntimeEventRouter know.
1812 if (reason == extension_misc::UNLOAD_REASON_UNINSTALL) 1813 if (reason == extension_misc::UNLOAD_REASON_UNINSTALL)
1813 extensions::RuntimeEventRouter::OnExtensionUninstalled( 1814 extensions::RuntimeEventRouter::OnExtensionUninstalled(
1814 profile_, extension_id); 1815 profile_, extension_id);
1815 1816
1816 // Keep information about the extension so that we can reload it later 1817 // Keep information about the extension so that we can reload it later
1817 // even if it's not permanently installed. 1818 // even if it's not permanently installed.
1818 unloaded_extension_paths_[extension->id()] = extension->path(); 1819 unloaded_extension_paths_[extension->id()] = extension->path();
1819 1820
1820 // Clean up if the extension is meant to be enabled after a reload. 1821 // Clean up if the extension is meant to be enabled after a reload.
1821 reloading_extensions_.erase(extension->id()); 1822 reloading_extensions_.erase(extension->id());
1822 1823
1823 // Clean up runtime data. 1824 // Clean up runtime data.
1824 extension_runtime_data_.erase(extension_id); 1825 extension_runtime_data_.erase(extension_id);
1825 1826
1826 if (disabled_extensions_.Contains(extension->id())) { 1827 if (disabled_extensions_.Contains(extension->id())) {
1827 UnloadedExtensionInfo details(extension, reason); 1828 UnloadedExtensionInfo details(extension.get(), reason);
1828 details.already_disabled = true; 1829 details.already_disabled = true;
1829 disabled_extensions_.Remove(extension->id()); 1830 disabled_extensions_.Remove(extension->id());
1830 content::NotificationService::current()->Notify( 1831 content::NotificationService::current()->Notify(
1831 chrome::NOTIFICATION_EXTENSION_UNLOADED, 1832 chrome::NOTIFICATION_EXTENSION_UNLOADED,
1832 content::Source<Profile>(profile_), 1833 content::Source<Profile>(profile_),
1833 content::Details<UnloadedExtensionInfo>(&details)); 1834 content::Details<UnloadedExtensionInfo>(&details));
1834 // Make sure the profile cleans up its RequestContexts when an already 1835 // Make sure the profile cleans up its RequestContexts when an already
1835 // disabled extension is unloaded (since they are also tracking the disabled 1836 // disabled extension is unloaded (since they are also tracking the disabled
1836 // extensions). 1837 // extensions).
1837 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); 1838 system_->UnregisterExtensionWithRequestContexts(extension_id, reason);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 AddExtension(extension); 2039 AddExtension(extension);
2039 } 2040 }
2040 2041
2041 void ExtensionService::UpdateActivePermissions(const Extension* extension) { 2042 void ExtensionService::UpdateActivePermissions(const Extension* extension) {
2042 // If the extension has used the optional permissions API, it will have a 2043 // If the extension has used the optional permissions API, it will have a
2043 // custom set of active permissions defined in the extension prefs. Here, 2044 // custom set of active permissions defined in the extension prefs. Here,
2044 // we update the extension's active permissions based on the prefs. 2045 // we update the extension's active permissions based on the prefs.
2045 scoped_refptr<PermissionSet> active_permissions = 2046 scoped_refptr<PermissionSet> active_permissions =
2046 extension_prefs()->GetActivePermissions(extension->id()); 2047 extension_prefs()->GetActivePermissions(extension->id());
2047 2048
2048 if (active_permissions) { 2049 if (active_permissions.get()) {
2049 // We restrict the active permissions to be within the bounds defined in the 2050 // We restrict the active permissions to be within the bounds defined in the
2050 // extension's manifest. 2051 // extension's manifest.
2051 // a) active permissions must be a subset of optional + default permissions 2052 // a) active permissions must be a subset of optional + default permissions
2052 // b) active permissions must contains all default permissions 2053 // b) active permissions must contains all default permissions
2053 scoped_refptr<PermissionSet> total_permissions = 2054 scoped_refptr<PermissionSet> total_permissions =
2054 PermissionSet::CreateUnion( 2055 PermissionSet::CreateUnion(
2055 extensions::PermissionsData::GetRequiredPermissions(extension), 2056 extensions::PermissionsData::GetRequiredPermissions(extension),
2056 extensions::PermissionsData::GetOptionalPermissions(extension)); 2057 extensions::PermissionsData::GetOptionalPermissions(extension));
2057 2058
2058 // Make sure the active permissions contain no more than optional + default. 2059 // Make sure the active permissions contain no more than optional + default.
2059 scoped_refptr<PermissionSet> adjusted_active = 2060 scoped_refptr<PermissionSet> adjusted_active =
2060 PermissionSet::CreateIntersection( 2061 PermissionSet::CreateIntersection(
2061 total_permissions.get(), active_permissions.get()); 2062 total_permissions.get(), active_permissions.get());
2062 2063
2063 // Make sure the active permissions contain the default permissions. 2064 // Make sure the active permissions contain the default permissions.
2064 adjusted_active = PermissionSet::CreateUnion( 2065 adjusted_active = PermissionSet::CreateUnion(
2065 extensions::PermissionsData::GetRequiredPermissions(extension), 2066 extensions::PermissionsData::GetRequiredPermissions(extension),
2066 adjusted_active.get()); 2067 adjusted_active.get());
2067 2068
2068 extensions::PermissionsUpdater perms_updater(profile()); 2069 extensions::PermissionsUpdater perms_updater(profile());
2069 perms_updater.UpdateActivePermissions(extension, adjusted_active); 2070 perms_updater.UpdateActivePermissions(extension, adjusted_active.get());
2070 } 2071 }
2071 } 2072 }
2072 2073
2073 void ExtensionService::CheckPermissionsIncrease(const Extension* extension, 2074 void ExtensionService::CheckPermissionsIncrease(const Extension* extension,
2074 bool is_extension_upgrade) { 2075 bool is_extension_upgrade) {
2075 UpdateActivePermissions(extension); 2076 UpdateActivePermissions(extension);
2076 2077
2077 // We keep track of all permissions the user has granted each extension. 2078 // We keep track of all permissions the user has granted each extension.
2078 // This allows extensions to gracefully support backwards compatibility 2079 // This allows extensions to gracefully support backwards compatibility
2079 // by including unknown permissions in their manifests. When the user 2080 // by including unknown permissions in their manifests. When the user
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 if (!IsExtensionIdle(extension_id)) 2310 if (!IsExtensionIdle(extension_id))
2310 return; 2311 return;
2311 2312
2312 FinishDelayedInstallation(extension_id); 2313 FinishDelayedInstallation(extension_id);
2313 } 2314 }
2314 2315
2315 void ExtensionService::FinishDelayedInstallation( 2316 void ExtensionService::FinishDelayedInstallation(
2316 const std::string& extension_id) { 2317 const std::string& extension_id) {
2317 scoped_refptr<const Extension> extension( 2318 scoped_refptr<const Extension> extension(
2318 GetPendingExtensionUpdate(extension_id)); 2319 GetPendingExtensionUpdate(extension_id));
2319 CHECK(extension); 2320 CHECK(extension.get());
2320 delayed_updates_for_idle_.Remove(extension_id); 2321 delayed_updates_for_idle_.Remove(extension_id);
2321 2322
2322 if (!extension_prefs_->FinishDelayedInstallInfo(extension_id)) 2323 if (!extension_prefs_->FinishDelayedInstallInfo(extension_id))
2323 NOTREACHED(); 2324 NOTREACHED();
2324 2325
2325 FinishInstallation(extension); 2326 FinishInstallation(extension.get());
2326 } 2327 }
2327 2328
2328 void ExtensionService::FinishInstallation(const Extension* extension) { 2329 void ExtensionService::FinishInstallation(const Extension* extension) {
2329 const extensions::Extension* existing_extension = 2330 const extensions::Extension* existing_extension =
2330 GetInstalledExtension(extension->id()); 2331 GetInstalledExtension(extension->id());
2331 bool is_update = false; 2332 bool is_update = false;
2332 std::string old_name; 2333 std::string old_name;
2333 if (existing_extension) { 2334 if (existing_extension) {
2334 is_update = true; 2335 is_update = true;
2335 old_name = existing_extension->name(); 2336 old_name = existing_extension->name();
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
2850 std::set<std::string> not_yet_blacklisted; 2851 std::set<std::string> not_yet_blacklisted;
2851 std::set_difference(new_blacklisted_ids.begin(), new_blacklisted_ids.end(), 2852 std::set_difference(new_blacklisted_ids.begin(), new_blacklisted_ids.end(),
2852 old_blacklisted_ids.begin(), old_blacklisted_ids.end(), 2853 old_blacklisted_ids.begin(), old_blacklisted_ids.end(),
2853 std::inserter(not_yet_blacklisted, 2854 std::inserter(not_yet_blacklisted,
2854 not_yet_blacklisted.begin())); 2855 not_yet_blacklisted.begin()));
2855 2856
2856 for (std::set<std::string>::iterator it = no_longer_blacklisted.begin(); 2857 for (std::set<std::string>::iterator it = no_longer_blacklisted.begin();
2857 it != no_longer_blacklisted.end(); ++it) { 2858 it != no_longer_blacklisted.end(); ++it) {
2858 scoped_refptr<const Extension> extension = 2859 scoped_refptr<const Extension> extension =
2859 blacklisted_extensions_.GetByID(*it); 2860 blacklisted_extensions_.GetByID(*it);
2860 DCHECK(extension); 2861 DCHECK(extension.get());
2861 if (!extension) 2862 if (!extension.get())
2862 continue; 2863 continue;
2863 blacklisted_extensions_.Remove(*it); 2864 blacklisted_extensions_.Remove(*it);
2864 AddExtension(extension); 2865 AddExtension(extension.get());
2865 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.UnblacklistInstalled", 2866 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.UnblacklistInstalled",
2866 extension->location(), Manifest::NUM_LOCATIONS); 2867 extension->location(),
2868 Manifest::NUM_LOCATIONS);
2867 } 2869 }
2868 2870
2869 for (std::set<std::string>::iterator it = not_yet_blacklisted.begin(); 2871 for (std::set<std::string>::iterator it = not_yet_blacklisted.begin();
2870 it != not_yet_blacklisted.end(); ++it) { 2872 it != not_yet_blacklisted.end(); ++it) {
2871 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); 2873 scoped_refptr<const Extension> extension = GetInstalledExtension(*it);
2872 DCHECK(extension); 2874 DCHECK(extension.get());
2873 if (!extension) 2875 if (!extension.get())
2874 continue; 2876 continue;
2875 blacklisted_extensions_.Insert(extension); 2877 blacklisted_extensions_.Insert(extension);
2876 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); 2878 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST);
2877 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", 2879 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled",
2878 extension->location(), Manifest::NUM_LOCATIONS); 2880 extension->location(), Manifest::NUM_LOCATIONS);
2879 } 2881 }
2880 2882
2881 IdentifyAlertableExtensions(); 2883 IdentifyAlertableExtensions();
2882 } 2884 }
2883 2885
2884 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 2886 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
2885 update_observers_.AddObserver(observer); 2887 update_observers_.AddObserver(observer);
2886 } 2888 }
2887 2889
2888 void ExtensionService::RemoveUpdateObserver( 2890 void ExtensionService::RemoveUpdateObserver(
2889 extensions::UpdateObserver* observer) { 2891 extensions::UpdateObserver* observer) {
2890 update_observers_.RemoveObserver(observer); 2892 update_observers_.RemoveObserver(observer);
2891 } 2893 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_protocols_unittest.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698