Pull extension blacklist and policy logic out of ExtensionPrefs and into two
new classes: Blacklist for the blacklist logic, and
StandardManagementPolicyProvider for the management policy component.
This is a preliminary step to making the extension blacklist backed by safe
browsing. Dumb blacklisting code will still live in ExtensionPrefs until the
migration is complete.
BUG=154149
[email protected]
Review URL: https://chromiumcodereview.appspot.com/11410048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168020 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 4063742..b959e39 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -65,6 +65,7 @@
#include "chrome/browser/extensions/external_provider_interface.h"
#include "chrome/browser/extensions/installed_loader.h"
#include "chrome/browser/extensions/lazy_background_task_queue.h"
+#include "chrome/browser/extensions/management_policy.h"
#include "chrome/browser/extensions/pending_extension_manager.h"
#include "chrome/browser/extensions/permissions_updater.h"
#include "chrome/browser/extensions/platform_app_launcher.h"
@@ -352,9 +353,11 @@
const CommandLine* command_line,
const FilePath& install_directory,
extensions::ExtensionPrefs* extension_prefs,
+ extensions::Blacklist* blacklist,
bool autoupdate_enabled,
bool extensions_enabled)
- : profile_(profile),
+ : extensions::Blacklist::Observer(blacklist),
+ profile_(profile),
system_(extensions::ExtensionSystem::Get(profile)),
extension_prefs_(extension_prefs),
settings_frontend_(extensions::SettingsFrontend::Create(profile)),
@@ -411,6 +414,7 @@
extension_prefs,
profile->GetPrefs(),
profile,
+ blacklist,
update_frequency));
}
@@ -1212,18 +1216,6 @@
PluginService::GetInstance()->PurgePluginListCache(profile_, false);
}
-void ExtensionService::UpdateExtensionBlacklist(
- const std::vector<std::string>& blacklist) {
- // Use this set to indicate if an extension in the blacklist has been used.
- std::set<std::string> blacklist_set;
- for (unsigned int i = 0; i < blacklist.size(); ++i) {
- if (Extension::IdIsValid(blacklist[i]))
- blacklist_set.insert(blacklist[i]);
- }
- extension_prefs_->UpdateBlacklist(blacklist_set);
- CheckManagementPolicy();
-}
-
Profile* ExtensionService::profile() {
return profile_;
}
@@ -1832,7 +1824,7 @@
for (ExtensionSet::const_iterator iter = extensions_.begin();
iter != extensions_.end(); ++iter) {
const Extension* e = *iter;
- if (!extension_prefs_->UserMayLoad(e, NULL)) {
+ if (!system_->management_policy()->UserMayLoad(e, NULL)) {
if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) {
extension_error_ui->AddBlacklistedExtension(e->id());
needs_alert = true;
@@ -2764,10 +2756,9 @@
void ExtensionService::InspectBackgroundPage(const Extension* extension) {
DCHECK(extension);
- ExtensionProcessManager* pm =
- extensions::ExtensionSystem::Get(profile_)->process_manager();
+ ExtensionProcessManager* pm = system_->process_manager();
extensions::LazyBackgroundTaskQueue* queue =
- extensions::ExtensionSystem::Get(profile_)->lazy_background_task_queue();
+ system_->lazy_background_task_queue();
extensions::ExtensionHost* host =
pm->GetBackgroundHostForExtension(extension->id());
@@ -2966,3 +2957,7 @@
process_manager->GetBackgroundHostForExtension(extension_id);
return !host;
}
+
+void ExtensionService::OnBlacklistUpdated() {
+ CheckManagementPolicy();
+}