OLD | NEW |
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 bool autoupdate_enabled, | 355 bool autoupdate_enabled, |
356 bool extensions_enabled, | 356 bool extensions_enabled, |
357 extensions::OneShotEvent* ready) | 357 extensions::OneShotEvent* ready) |
358 : extensions::Blacklist::Observer(blacklist), | 358 : extensions::Blacklist::Observer(blacklist), |
359 profile_(profile), | 359 profile_(profile), |
360 system_(extensions::ExtensionSystem::Get(profile)), | 360 system_(extensions::ExtensionSystem::Get(profile)), |
361 extension_prefs_(extension_prefs), | 361 extension_prefs_(extension_prefs), |
362 blacklist_(blacklist), | 362 blacklist_(blacklist), |
363 extension_sync_service_(NULL), | 363 extension_sync_service_(NULL), |
364 registry_(extensions::ExtensionRegistry::Get(profile)), | 364 registry_(extensions::ExtensionRegistry::Get(profile)), |
365 pending_extension_manager_(*this), | 365 pending_extension_manager_(*this, profile), |
366 install_directory_(install_directory), | 366 install_directory_(install_directory), |
367 extensions_enabled_(extensions_enabled), | 367 extensions_enabled_(extensions_enabled), |
368 show_extensions_prompts_(true), | 368 show_extensions_prompts_(true), |
369 install_updates_when_idle_(true), | 369 install_updates_when_idle_(true), |
370 ready_(ready), | 370 ready_(ready), |
371 update_once_all_providers_are_ready_(false), | 371 update_once_all_providers_are_ready_(false), |
372 browser_terminating_(false), | 372 browser_terminating_(false), |
373 installs_delayed_for_gc_(false), | 373 installs_delayed_for_gc_(false), |
374 is_first_run_(false) { | 374 is_first_run_(false) { |
375 #if defined(OS_CHROMEOS) | 375 #if defined(OS_CHROMEOS) |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 registry_->blacklisted_extensions().Contains(extension_id)) { | 944 registry_->blacklisted_extensions().Contains(extension_id)) { |
945 return false; | 945 return false; |
946 } | 946 } |
947 | 947 |
948 // If the extension hasn't been loaded yet, check the prefs for it. Assume | 948 // If the extension hasn't been loaded yet, check the prefs for it. Assume |
949 // enabled unless otherwise noted. | 949 // enabled unless otherwise noted. |
950 return !extension_prefs_->IsExtensionDisabled(extension_id) && | 950 return !extension_prefs_->IsExtensionDisabled(extension_id) && |
951 !extension_prefs_->IsExternalExtensionUninstalled(extension_id); | 951 !extension_prefs_->IsExternalExtensionUninstalled(extension_id); |
952 } | 952 } |
953 | 953 |
954 bool ExtensionService::IsExternalExtensionUninstalled( | |
955 const std::string& extension_id) const { | |
956 return extension_prefs_->IsExternalExtensionUninstalled(extension_id); | |
957 } | |
958 | |
959 void ExtensionService::EnableExtension(const std::string& extension_id) { | 954 void ExtensionService::EnableExtension(const std::string& extension_id) { |
960 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 955 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
961 | 956 |
962 if (IsExtensionEnabled(extension_id)) | 957 if (IsExtensionEnabled(extension_id)) |
963 return; | 958 return; |
964 const Extension* extension = | 959 const Extension* extension = |
965 registry_->disabled_extensions().GetByID(extension_id); | 960 registry_->disabled_extensions().GetByID(extension_id); |
966 | 961 |
967 ManagementPolicy* policy = system_->management_policy(); | 962 ManagementPolicy* policy = system_->management_policy(); |
968 if (extension && policy->MustRemainDisabled(extension, NULL, NULL)) { | 963 if (extension && policy->MustRemainDisabled(extension, NULL, NULL)) { |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 } | 2110 } |
2116 return; | 2111 return; |
2117 } | 2112 } |
2118 | 2113 |
2119 install_parameter = pending_extension_info->install_parameter(); | 2114 install_parameter = pending_extension_info->install_parameter(); |
2120 pending_extension_manager()->Remove(id); | 2115 pending_extension_manager()->Remove(id); |
2121 } else { | 2116 } else { |
2122 // We explicitly want to re-enable an uninstalled external | 2117 // We explicitly want to re-enable an uninstalled external |
2123 // extension; if we're here, that means the user is manually | 2118 // extension; if we're here, that means the user is manually |
2124 // installing the extension. | 2119 // installing the extension. |
2125 if (IsExternalExtensionUninstalled(id)) { | 2120 if (extension_prefs_->IsExternalExtensionUninstalled(id)) { |
2126 initial_enable = true; | 2121 initial_enable = true; |
2127 } | 2122 } |
2128 } | 2123 } |
2129 | 2124 |
2130 // Unsupported requirements overrides the management policy. | 2125 // Unsupported requirements overrides the management policy. |
2131 if (has_requirement_errors) { | 2126 if (has_requirement_errors) { |
2132 initial_enable = false; | 2127 initial_enable = false; |
2133 extension_prefs_->AddDisableReason( | 2128 extension_prefs_->AddDisableReason( |
2134 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); | 2129 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); |
2135 // If the extension was disabled because of unsupported requirements but | 2130 // If the extension was disabled because of unsupported requirements but |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2865 void ExtensionService::UnloadAllExtensionsInternal() { | 2860 void ExtensionService::UnloadAllExtensionsInternal() { |
2866 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2861 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
2867 | 2862 |
2868 registry_->ClearAll(); | 2863 registry_->ClearAll(); |
2869 system_->runtime_data()->ClearAll(); | 2864 system_->runtime_data()->ClearAll(); |
2870 | 2865 |
2871 // TODO(erikkay) should there be a notification for this? We can't use | 2866 // TODO(erikkay) should there be a notification for this? We can't use |
2872 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2867 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
2873 // or uninstalled. | 2868 // or uninstalled. |
2874 } | 2869 } |
OLD | NEW |