| 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 profile->GetPath().AppendASCII(kSettingsDirectoryName)), | 596 profile->GetPath().AppendASCII(kSettingsDirectoryName)), |
| 597 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 597 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 598 install_directory_(install_directory), | 598 install_directory_(install_directory), |
| 599 extensions_enabled_(extensions_enabled), | 599 extensions_enabled_(extensions_enabled), |
| 600 show_extensions_prompts_(true), | 600 show_extensions_prompts_(true), |
| 601 ready_(false), | 601 ready_(false), |
| 602 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 602 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 603 app_notification_manager_(new AppNotificationManager(profile)), | 603 app_notification_manager_(new AppNotificationManager(profile)), |
| 604 permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 604 permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 605 apps_promo_(profile->GetPrefs()), | 605 apps_promo_(profile->GetPrefs()), |
| 606 event_routers_initialized_(false) { | 606 event_routers_initialized_(false), |
| 607 extension_warnings_(profile) { |
| 607 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 608 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 608 | 609 |
| 609 // Figure out if extension installation should be enabled. | 610 // Figure out if extension installation should be enabled. |
| 610 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 611 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
| 611 extensions_enabled_ = false; | 612 extensions_enabled_ = false; |
| 612 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 613 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 613 extensions_enabled_ = false; | 614 extensions_enabled_ = false; |
| 614 } | 615 } |
| 615 | 616 |
| 616 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 617 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 if (sync_bundle && sync_bundle->HasExtensionId(extension_id)) { | 965 if (sync_bundle && sync_bundle->HasExtensionId(extension_id)) { |
| 965 sync_bundle->sync_processor->ProcessSyncChanges( | 966 sync_bundle->sync_processor->ProcessSyncChanges( |
| 966 FROM_HERE, SyncChangeList(1, sync_change)); | 967 FROM_HERE, SyncChangeList(1, sync_change)); |
| 967 sync_bundle->synced_extensions.erase(extension_id); | 968 sync_bundle->synced_extensions.erase(extension_id); |
| 968 } | 969 } |
| 969 | 970 |
| 970 // Track the uninstallation. | 971 // Track the uninstallation. |
| 971 UserMetrics::RecordAction( | 972 UserMetrics::RecordAction( |
| 972 UserMetricsAction("Extensions.ExtensionUninstalled")); | 973 UserMetricsAction("Extensions.ExtensionUninstalled")); |
| 973 | 974 |
| 975 // Uninstalling one extension might have solved the problems of others. |
| 976 // Therefore, we clear warnings of this type for all extensions. |
| 977 std::set<ExtensionWarningSet::WarningType> warnings; |
| 978 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); |
| 979 extension_warnings_.ClearWarnings(warnings); |
| 980 |
| 974 return true; | 981 return true; |
| 975 } | 982 } |
| 976 | 983 |
| 977 void ExtensionService::ClearExtensionData(const std::string& extension_id, | 984 void ExtensionService::ClearExtensionData(const std::string& extension_id, |
| 978 const GURL& storage_url, | 985 const GURL& storage_url, |
| 979 bool is_storage_isolated) { | 986 bool is_storage_isolated) { |
| 980 scoped_refptr<ExtensionDataDeleter> deleter(new ExtensionDataDeleter( | 987 scoped_refptr<ExtensionDataDeleter> deleter(new ExtensionDataDeleter( |
| 981 profile_, extension_id, storage_url, is_storage_isolated)); | 988 profile_, extension_id, storage_url, is_storage_isolated)); |
| 982 deleter->StartDeleting(); | 989 deleter->StartDeleting(); |
| 983 } | 990 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 } else { | 1071 } else { |
| 1065 iter = std::find(terminated_extensions_.begin(), | 1072 iter = std::find(terminated_extensions_.begin(), |
| 1066 terminated_extensions_.end(), | 1073 terminated_extensions_.end(), |
| 1067 extension); | 1074 extension); |
| 1068 terminated_extensions_.erase(iter); | 1075 terminated_extensions_.erase(iter); |
| 1069 } | 1076 } |
| 1070 | 1077 |
| 1071 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); | 1078 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); |
| 1072 | 1079 |
| 1073 SyncExtensionChangeIfNeeded(*extension); | 1080 SyncExtensionChangeIfNeeded(*extension); |
| 1081 |
| 1082 // Deactivating one extension might have solved the problems of others. |
| 1083 // Therefore, we clear warnings of this type for all extensions. |
| 1084 std::set<ExtensionWarningSet::WarningType> warnings; |
| 1085 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); |
| 1086 extension_warnings_.ClearWarnings(warnings); |
| 1074 } | 1087 } |
| 1075 | 1088 |
| 1076 void ExtensionService::GrantPermissions(const Extension* extension) { | 1089 void ExtensionService::GrantPermissions(const Extension* extension) { |
| 1077 CHECK(extension); | 1090 CHECK(extension); |
| 1078 | 1091 |
| 1079 // We only maintain the granted permissions prefs for extensions that can't | 1092 // We only maintain the granted permissions prefs for extensions that can't |
| 1080 // silently increase their permissions. | 1093 // silently increase their permissions. |
| 1081 if (extension->CanSilentlyIncreasePermissions()) | 1094 if (extension->CanSilentlyIncreasePermissions()) |
| 1082 return; | 1095 return; |
| 1083 | 1096 |
| (...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2983 | 2996 |
| 2984 ExtensionService::NaClModuleInfoList::iterator | 2997 ExtensionService::NaClModuleInfoList::iterator |
| 2985 ExtensionService::FindNaClModule(const GURL& url) { | 2998 ExtensionService::FindNaClModule(const GURL& url) { |
| 2986 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2999 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2987 iter != nacl_module_list_.end(); ++iter) { | 3000 iter != nacl_module_list_.end(); ++iter) { |
| 2988 if (iter->url == url) | 3001 if (iter->url == url) |
| 2989 return iter; | 3002 return iter; |
| 2990 } | 3003 } |
| 2991 return nacl_module_list_.end(); | 3004 return nacl_module_list_.end(); |
| 2992 } | 3005 } |
| OLD | NEW |