| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 ready_(false), | 360 ready_(false), |
| 361 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 361 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 362 menu_manager_(profile), | 362 menu_manager_(profile), |
| 363 app_notification_manager_( | 363 app_notification_manager_( |
| 364 new extensions::AppNotificationManager(profile)), | 364 new extensions::AppNotificationManager(profile)), |
| 365 event_routers_initialized_(false), | 365 event_routers_initialized_(false), |
| 366 update_once_all_providers_are_ready_(false), | 366 update_once_all_providers_are_ready_(false), |
| 367 browser_terminating_(false), | 367 browser_terminating_(false), |
| 368 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 368 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 369 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 369 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 370 extension_warnings_(profile), | |
| 371 app_shortcut_manager_(profile) { | 370 app_shortcut_manager_(profile) { |
| 372 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 371 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 373 | 372 |
| 374 // Figure out if extension installation should be enabled. | 373 // Figure out if extension installation should be enabled. |
| 375 if (command_line->HasSwitch(switches::kDisableExtensions) || | 374 if (command_line->HasSwitch(switches::kDisableExtensions) || |
| 376 profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 375 profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 377 extensions_enabled_ = false; | 376 extensions_enabled_ = false; |
| 378 } | 377 } |
| 379 | 378 |
| 380 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 379 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 } else if (extension_sync_bundle_.HasExtensionId(extension_id) && | 861 } else if (extension_sync_bundle_.HasExtensionId(extension_id) && |
| 863 sync_change.sync_data().GetDataType() == syncer::EXTENSIONS) { | 862 sync_change.sync_data().GetDataType() == syncer::EXTENSIONS) { |
| 864 extension_sync_bundle_.ProcessDeletion(extension_id, sync_change); | 863 extension_sync_bundle_.ProcessDeletion(extension_id, sync_change); |
| 865 } | 864 } |
| 866 | 865 |
| 867 pending_extension_updates_.Remove(extension_id); | 866 pending_extension_updates_.Remove(extension_id); |
| 868 | 867 |
| 869 // Track the uninstallation. | 868 // Track the uninstallation. |
| 870 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); | 869 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); |
| 871 | 870 |
| 872 // Uninstalling one extension might have solved the problems of others. | |
| 873 // Therefore, we clear warnings of this type for all extensions. | |
| 874 std::set<ExtensionWarningSet::WarningType> warnings; | |
| 875 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); | |
| 876 extension_warnings_.ClearWarnings(warnings); | |
| 877 | |
| 878 return true; | 871 return true; |
| 879 } | 872 } |
| 880 | 873 |
| 881 bool ExtensionService::IsExtensionEnabled( | 874 bool ExtensionService::IsExtensionEnabled( |
| 882 const std::string& extension_id) const { | 875 const std::string& extension_id) const { |
| 883 if (extensions_.Contains(extension_id) || | 876 if (extensions_.Contains(extension_id) || |
| 884 terminated_extensions_.Contains(extension_id)) { | 877 terminated_extensions_.Contains(extension_id)) { |
| 885 return true; | 878 return true; |
| 886 } | 879 } |
| 887 | 880 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 // for terminated extensions being disabled. | 959 // for terminated extensions being disabled. |
| 967 disabled_extensions_.Insert(make_scoped_refptr(extension)); | 960 disabled_extensions_.Insert(make_scoped_refptr(extension)); |
| 968 if (extensions_.Contains(extension->id())) { | 961 if (extensions_.Contains(extension->id())) { |
| 969 extensions_.Remove(extension->id()); | 962 extensions_.Remove(extension->id()); |
| 970 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); | 963 NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE); |
| 971 } else { | 964 } else { |
| 972 terminated_extensions_.Remove(extension->id()); | 965 terminated_extensions_.Remove(extension->id()); |
| 973 } | 966 } |
| 974 | 967 |
| 975 SyncExtensionChangeIfNeeded(*extension); | 968 SyncExtensionChangeIfNeeded(*extension); |
| 976 | |
| 977 // Deactivating one extension might have solved the problems of others. | |
| 978 // Therefore, we clear warnings of this type for all extensions. | |
| 979 std::set<ExtensionWarningSet::WarningType> warnings; | |
| 980 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); | |
| 981 extension_warnings_.ClearWarnings(warnings); | |
| 982 } | 969 } |
| 983 | 970 |
| 984 void ExtensionService::GrantPermissionsAndEnableExtension( | 971 void ExtensionService::GrantPermissionsAndEnableExtension( |
| 985 const Extension* extension, bool record_oauth2_grant) { | 972 const Extension* extension, bool record_oauth2_grant) { |
| 986 GrantPermissions(extension, record_oauth2_grant); | 973 GrantPermissions(extension, record_oauth2_grant); |
| 987 RecordPermissionMessagesHistogram( | 974 RecordPermissionMessagesHistogram( |
| 988 extension, "Extensions.Permissions_ReEnable"); | 975 extension, "Extensions.Permissions_ReEnable"); |
| 989 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); | 976 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); |
| 990 EnableExtension(extension->id()); | 977 EnableExtension(extension->id()); |
| 991 } | 978 } |
| (...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2952 | 2939 |
| 2953 return true; | 2940 return true; |
| 2954 } | 2941 } |
| 2955 | 2942 |
| 2956 bool ExtensionService::IsExtensionIdle(const std::string& extension_id) const { | 2943 bool ExtensionService::IsExtensionIdle(const std::string& extension_id) const { |
| 2957 ExtensionProcessManager* pm = system_->process_manager(); | 2944 ExtensionProcessManager* pm = system_->process_manager(); |
| 2958 extensions::ExtensionHost* host = | 2945 extensions::ExtensionHost* host = |
| 2959 pm->GetBackgroundHostForExtension(extension_id); | 2946 pm->GetBackgroundHostForExtension(extension_id); |
| 2960 return !host; | 2947 return !host; |
| 2961 } | 2948 } |
| OLD | NEW |