Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1856)

Unified Diff: chrome/browser/extensions/extension_management.cc

Issue 536573003: Add ExtensionManagement based ExternalLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ext-2
Patch Set: fix broken browser tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_management.cc
diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc
index abb4d90d6542f941df4e04b00cee67a25fb26390..32790363cb3a6233b5876d01c22864ddb33b2bb8 100644
--- a/chrome/browser/extensions/extension_management.cc
+++ b/chrome/browser/extensions/extension_management.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/prefs/pref_service.h"
+#include "chrome/browser/extensions/external_policy_loader.h"
#include "chrome/browser/extensions/external_provider_impl.h"
#include "chrome/browser/extensions/standard_management_policy_provider.h"
#include "chrome/browser/profiles/profile.h"
@@ -38,7 +39,7 @@ void ExtensionManagement::GlobalSettings::Reset() {
}
ExtensionManagement::ExtensionManagement(PrefService* pref_service)
- : pref_service_(pref_service) {
+ : allow_user_preference_(false), pref_service_(pref_service) {
pref_change_registrar_.Init(pref_service_);
base::Closure pref_change_callback = base::Bind(
&ExtensionManagement::OnExtensionPrefChanged, base::Unretained(this));
@@ -74,6 +75,24 @@ bool ExtensionManagement::BlacklistedByDefault() {
return default_settings_.installation_mode == INSTALLATION_BLOCKED;
}
+scoped_ptr<base::DictionaryValue> ExtensionManagement::GetForceInstallList()
+ const {
+ scoped_ptr<base::DictionaryValue> forcelist(new base::DictionaryValue());
+ for (SettingsIdMap::const_iterator it = settings_by_id_.begin();
+ it != settings_by_id_.end();
+ ++it) {
+ if (it->second.installation_mode == INSTALLATION_FORCED) {
+ ExternalPolicyLoader::AddExtension(
+ forcelist.get(), it->first, it->second.update_url);
+ }
+ }
+ return forcelist.Pass();
+}
+
+bool ExtensionManagement::IsInstallationAllowed(const ExtensionId& id) const {
+ return ReadById(id).installation_mode != INSTALLATION_BLOCKED;
+}
+
const ExtensionManagement::IndividualSettings& ExtensionManagement::ReadById(
const ExtensionId& id) const {
DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id;
@@ -88,6 +107,10 @@ ExtensionManagement::ReadGlobalSettings() const {
return global_settings_;
}
+void ExtensionManagement::AllowUserPreferenceForTesting() const {
+ allow_user_preference_ = true;
+}
+
void ExtensionManagement::Refresh() {
// Load all extension management settings preferences.
const base::ListValue* allowed_list_pref =
@@ -198,7 +221,7 @@ const base::Value* ExtensionManagement::LoadPreference(
const PrefService::Preference* pref =
pref_service_->FindPreference(pref_name);
if (pref && !pref->IsDefaultValue() &&
- (!force_managed || pref->IsManaged())) {
+ (!force_managed || allow_user_preference_ || pref->IsManaged())) {
const base::Value* value = pref->GetValue();
if (value && value->IsType(expected_type))
return value;

Powered by Google App Engine
This is Rietveld 408576698