| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_management.h" | 5 #include "chrome/browser/extensions/extension_management.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "chrome/browser/extensions/external_policy_loader.h" |
| 11 #include "chrome/browser/extensions/external_provider_impl.h" | 12 #include "chrome/browser/extensions/external_provider_impl.h" |
| 12 #include "chrome/browser/extensions/standard_management_policy_provider.h" | 13 #include "chrome/browser/extensions/standard_management_policy_provider.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "components/crx_file/id_util.h" | 15 #include "components/crx_file/id_util.h" |
| 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 16 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 16 #include "extensions/browser/pref_names.h" | 17 #include "extensions/browser/pref_names.h" |
| 17 #include "extensions/common/url_pattern.h" | 18 #include "extensions/common/url_pattern.h" |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 | 21 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 68 } |
| 68 | 69 |
| 69 ManagementPolicy::Provider* ExtensionManagement::GetProvider() { | 70 ManagementPolicy::Provider* ExtensionManagement::GetProvider() { |
| 70 return provider_.get(); | 71 return provider_.get(); |
| 71 } | 72 } |
| 72 | 73 |
| 73 bool ExtensionManagement::BlacklistedByDefault() { | 74 bool ExtensionManagement::BlacklistedByDefault() { |
| 74 return default_settings_.installation_mode == INSTALLATION_BLOCKED; | 75 return default_settings_.installation_mode == INSTALLATION_BLOCKED; |
| 75 } | 76 } |
| 76 | 77 |
| 78 scoped_ptr<base::DictionaryValue> ExtensionManagement::GetForceInstallList() |
| 79 const { |
| 80 scoped_ptr<base::DictionaryValue> forcelist(new base::DictionaryValue()); |
| 81 for (SettingsIdMap::const_iterator it = settings_by_id_.begin(); |
| 82 it != settings_by_id_.end(); |
| 83 ++it) { |
| 84 if (it->second.installation_mode == INSTALLATION_FORCED) { |
| 85 ExternalPolicyLoader::AddExtension( |
| 86 forcelist.get(), it->first, it->second.update_url); |
| 87 } |
| 88 } |
| 89 return forcelist.Pass(); |
| 90 } |
| 91 |
| 92 bool ExtensionManagement::IsInstallationAllowed(const ExtensionId& id) const { |
| 93 return ReadById(id).installation_mode != INSTALLATION_BLOCKED; |
| 94 } |
| 95 |
| 77 const ExtensionManagement::IndividualSettings& ExtensionManagement::ReadById( | 96 const ExtensionManagement::IndividualSettings& ExtensionManagement::ReadById( |
| 78 const ExtensionId& id) const { | 97 const ExtensionId& id) const { |
| 79 DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id; | 98 DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id; |
| 80 SettingsIdMap::const_iterator it = settings_by_id_.find(id); | 99 SettingsIdMap::const_iterator it = settings_by_id_.find(id); |
| 81 if (it != settings_by_id_.end()) | 100 if (it != settings_by_id_.end()) |
| 82 return it->second; | 101 return it->second; |
| 83 return default_settings_; | 102 return default_settings_; |
| 84 } | 103 } |
| 85 | 104 |
| 86 const ExtensionManagement::GlobalSettings& | 105 const ExtensionManagement::GlobalSettings& |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 ExtensionManagementFactory::~ExtensionManagementFactory() { | 263 ExtensionManagementFactory::~ExtensionManagementFactory() { |
| 245 } | 264 } |
| 246 | 265 |
| 247 KeyedService* ExtensionManagementFactory::BuildServiceInstanceFor( | 266 KeyedService* ExtensionManagementFactory::BuildServiceInstanceFor( |
| 248 content::BrowserContext* context) const { | 267 content::BrowserContext* context) const { |
| 249 return new ExtensionManagement( | 268 return new ExtensionManagement( |
| 250 Profile::FromBrowserContext(context)->GetPrefs()); | 269 Profile::FromBrowserContext(context)->GetPrefs()); |
| 251 } | 270 } |
| 252 | 271 |
| 253 } // namespace extensions | 272 } // namespace extensions |
| OLD | NEW |