| 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 profile->GetPath().AppendASCII(kSettingsDirectoryName)), | 591 profile->GetPath().AppendASCII(kSettingsDirectoryName)), |
| 592 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 592 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 593 install_directory_(install_directory), | 593 install_directory_(install_directory), |
| 594 extensions_enabled_(extensions_enabled), | 594 extensions_enabled_(extensions_enabled), |
| 595 show_extensions_prompts_(true), | 595 show_extensions_prompts_(true), |
| 596 ready_(false), | 596 ready_(false), |
| 597 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 597 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 598 app_notification_manager_(new AppNotificationManager(profile)), | 598 app_notification_manager_(new AppNotificationManager(profile)), |
| 599 permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 599 permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 600 apps_promo_(profile->GetPrefs()), | 600 apps_promo_(profile->GetPrefs()), |
| 601 event_routers_initialized_(false) { | 601 event_routers_initialized_(false), |
| 602 extension_warnings_(profile) { |
| 602 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 603 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 603 | 604 |
| 604 // Figure out if extension installation should be enabled. | 605 // Figure out if extension installation should be enabled. |
| 605 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 606 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
| 606 extensions_enabled_ = false; | 607 extensions_enabled_ = false; |
| 607 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 608 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 608 extensions_enabled_ = false; | 609 extensions_enabled_ = false; |
| 609 } | 610 } |
| 610 | 611 |
| 611 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 612 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 if (sync_bundle && sync_bundle->HasExtensionId(extension_id)) { | 962 if (sync_bundle && sync_bundle->HasExtensionId(extension_id)) { |
| 962 sync_bundle->sync_processor->ProcessSyncChanges( | 963 sync_bundle->sync_processor->ProcessSyncChanges( |
| 963 FROM_HERE, SyncChangeList(1, sync_change)); | 964 FROM_HERE, SyncChangeList(1, sync_change)); |
| 964 sync_bundle->synced_extensions.erase(extension_id); | 965 sync_bundle->synced_extensions.erase(extension_id); |
| 965 } | 966 } |
| 966 | 967 |
| 967 // Track the uninstallation. | 968 // Track the uninstallation. |
| 968 UserMetrics::RecordAction( | 969 UserMetrics::RecordAction( |
| 969 UserMetricsAction("Extensions.ExtensionUninstalled")); | 970 UserMetricsAction("Extensions.ExtensionUninstalled")); |
| 970 | 971 |
| 972 // Uninstalling one extension might have solved the problems of others. |
| 973 // Therefore, we clear warnings of this type for all extensions. |
| 974 std::set<ExtensionWarning::WarningType> warnings; |
| 975 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); |
| 976 extension_warnings_.ClearWarnings(warnings); |
| 977 |
| 971 return true; | 978 return true; |
| 972 } | 979 } |
| 973 | 980 |
| 974 void ExtensionService::ClearExtensionData(const std::string& extension_id, | 981 void ExtensionService::ClearExtensionData(const std::string& extension_id, |
| 975 const GURL& storage_url, | 982 const GURL& storage_url, |
| 976 bool is_storage_isolated) { | 983 bool is_storage_isolated) { |
| 977 scoped_refptr<ExtensionDataDeleter> deleter(new ExtensionDataDeleter( | 984 scoped_refptr<ExtensionDataDeleter> deleter(new ExtensionDataDeleter( |
| 978 profile_, extension_id, storage_url, is_storage_isolated)); | 985 profile_, extension_id, storage_url, is_storage_isolated)); |
| 979 deleter->StartDeleting(); | 986 deleter->StartDeleting(); |
| 980 } | 987 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 } else { | 1068 } else { |
| 1062 iter = std::find(terminated_extensions_.begin(), | 1069 iter = std::find(terminated_extensions_.begin(), |
| 1063 terminated_extensions_.end(), | 1070 terminated_extensions_.end(), |
| 1064 extension); | 1071 extension); |
| 1065 terminated_extensions_.erase(iter); | 1072 terminated_extensions_.erase(iter); |
| 1066 } | 1073 } |
| 1067 | 1074 |
| 1068 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); | 1075 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); |
| 1069 | 1076 |
| 1070 SyncExtensionChangeIfNeeded(*extension); | 1077 SyncExtensionChangeIfNeeded(*extension); |
| 1078 |
| 1079 // Deactivating one extension might have solved the problems of others. |
| 1080 // Therefore, we clear warnings of this type for all extensions. |
| 1081 std::set<ExtensionWarning::WarningType> warnings; |
| 1082 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); |
| 1083 extension_warnings_.ClearWarnings(warnings); |
| 1071 } | 1084 } |
| 1072 | 1085 |
| 1073 void ExtensionService::GrantPermissions(const Extension* extension) { | 1086 void ExtensionService::GrantPermissions(const Extension* extension) { |
| 1074 CHECK(extension); | 1087 CHECK(extension); |
| 1075 | 1088 |
| 1076 // We only maintain the granted permissions prefs for extensions that can't | 1089 // We only maintain the granted permissions prefs for extensions that can't |
| 1077 // silently increase their permissions. | 1090 // silently increase their permissions. |
| 1078 if (extension->CanSilentlyIncreasePermissions()) | 1091 if (extension->CanSilentlyIncreasePermissions()) |
| 1079 return; | 1092 return; |
| 1080 | 1093 |
| (...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2905 | 2918 |
| 2906 ExtensionService::NaClModuleInfoList::iterator | 2919 ExtensionService::NaClModuleInfoList::iterator |
| 2907 ExtensionService::FindNaClModule(const GURL& url) { | 2920 ExtensionService::FindNaClModule(const GURL& url) { |
| 2908 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2921 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2909 iter != nacl_module_list_.end(); ++iter) { | 2922 iter != nacl_module_list_.end(); ++iter) { |
| 2910 if (iter->url == url) | 2923 if (iter->url == url) |
| 2911 return iter; | 2924 return iter; |
| 2912 } | 2925 } |
| 2913 return nacl_module_list_.end(); | 2926 return nacl_module_list_.end(); |
| 2914 } | 2927 } |
| OLD | NEW |