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" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 } | 133 } |
134 | 134 |
135 void ExtensionManagement::RemoveObserver(Observer* observer) { | 135 void ExtensionManagement::RemoveObserver(Observer* observer) { |
136 observer_list_.RemoveObserver(observer); | 136 observer_list_.RemoveObserver(observer); |
137 } | 137 } |
138 | 138 |
139 ManagementPolicy::Provider* ExtensionManagement::GetProvider() { | 139 ManagementPolicy::Provider* ExtensionManagement::GetProvider() { |
140 return provider_.get(); | 140 return provider_.get(); |
141 } | 141 } |
142 | 142 |
143 bool ExtensionManagement::BlacklistedByDefault() { | 143 bool ExtensionManagement::BlacklistedByDefault() const { |
144 return default_settings_.installation_mode == INSTALLATION_BLOCKED; | 144 return default_settings_.installation_mode == INSTALLATION_BLOCKED; |
145 } | 145 } |
146 | 146 |
147 scoped_ptr<base::DictionaryValue> ExtensionManagement::GetForceInstallList() | 147 scoped_ptr<base::DictionaryValue> ExtensionManagement::GetForceInstallList() |
148 const { | 148 const { |
149 scoped_ptr<base::DictionaryValue> forcelist(new base::DictionaryValue()); | 149 scoped_ptr<base::DictionaryValue> install_list(new base::DictionaryValue()); |
150 for (SettingsIdMap::const_iterator it = settings_by_id_.begin(); | 150 for (SettingsIdMap::const_iterator it = settings_by_id_.begin(); |
151 it != settings_by_id_.end(); | 151 it != settings_by_id_.end(); |
152 ++it) { | 152 ++it) { |
153 if (it->second.installation_mode == INSTALLATION_FORCED) { | 153 if (it->second.installation_mode == INSTALLATION_FORCED) { |
154 ExternalPolicyLoader::AddExtension( | 154 ExternalPolicyLoader::AddExtension( |
155 forcelist.get(), it->first, it->second.update_url); | 155 install_list.get(), it->first, it->second.update_url); |
156 } | 156 } |
157 } | 157 } |
158 return forcelist.Pass(); | 158 return install_list.Pass(); |
159 } | |
160 | |
161 scoped_ptr<base::DictionaryValue> | |
162 ExtensionManagement::GetRecommendedInstallList() const { | |
163 scoped_ptr<base::DictionaryValue> install_list(new base::DictionaryValue()); | |
164 for (SettingsIdMap::const_iterator it = settings_by_id_.begin(); | |
165 it != settings_by_id_.end(); | |
166 ++it) { | |
167 if (it->second.installation_mode == INSTALLATION_RECOMMENDED) { | |
168 ExternalPolicyLoader::AddExtension( | |
169 install_list.get(), it->first, it->second.update_url); | |
170 } | |
171 } | |
172 return install_list.Pass(); | |
159 } | 173 } |
160 | 174 |
161 bool ExtensionManagement::IsInstallationAllowed(const ExtensionId& id) const { | 175 bool ExtensionManagement::IsInstallationAllowed(const ExtensionId& id) const { |
162 return ReadById(id).installation_mode != INSTALLATION_BLOCKED; | 176 return ReadById(id).installation_mode != INSTALLATION_BLOCKED; |
163 } | 177 } |
164 | 178 |
165 bool ExtensionManagement::IsOffstoreInstallAllowed(const GURL& url, | 179 bool ExtensionManagement::IsOffstoreInstallAllowed(const GURL& url, |
166 const GURL& referrer_url) { | 180 const GURL& referrer_url) { |
167 // No allowed install sites specified, disallow by default. | 181 // No allowed install sites specified, disallow by default. |
168 if (!global_settings_.has_restricted_install_sources) | 182 if (!global_settings_.has_restricted_install_sources) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 std::string update_url; | 283 std::string update_url; |
270 for (base::DictionaryValue::Iterator it(*forced_list_pref); !it.IsAtEnd(); | 284 for (base::DictionaryValue::Iterator it(*forced_list_pref); !it.IsAtEnd(); |
271 it.Advance()) { | 285 it.Advance()) { |
272 if (!crx_file::id_util::IdIsValid(it.key())) | 286 if (!crx_file::id_util::IdIsValid(it.key())) |
273 continue; | 287 continue; |
274 const base::DictionaryValue* dict_value = NULL; | 288 const base::DictionaryValue* dict_value = NULL; |
275 if (it.value().GetAsDictionary(&dict_value) && | 289 if (it.value().GetAsDictionary(&dict_value) && |
276 dict_value->GetStringWithoutPathExpansion( | 290 dict_value->GetStringWithoutPathExpansion( |
277 ExternalProviderImpl::kExternalUpdateUrl, &update_url)) { | 291 ExternalProviderImpl::kExternalUpdateUrl, &update_url)) { |
278 IndividualSettings* by_id = AccessById(it.key()); | 292 IndividualSettings* by_id = AccessById(it.key()); |
279 by_id->installation_mode = INSTALLATION_FORCED; | 293 by_id->installation_mode = INSTALLATION_RECOMMENDED; |
Joao da Silva
2014/09/19 07:55:52
Why? This is the force list, so should be FORCED h
binjin
2014/09/19 09:25:28
it's added by mistake, it's for manual testing.
Joao da Silva
2014/09/19 09:27:48
Ok. Please remove it and send an updated CL when r
binjin
2014/09/19 10:09:56
Done.
| |
280 by_id->update_url = update_url; | 294 by_id->update_url = update_url; |
281 } | 295 } |
282 } | 296 } |
283 } | 297 } |
284 | 298 |
285 if (install_sources_pref) { | 299 if (install_sources_pref) { |
286 global_settings_.has_restricted_install_sources = true; | 300 global_settings_.has_restricted_install_sources = true; |
287 for (base::ListValue::const_iterator it = install_sources_pref->begin(); | 301 for (base::ListValue::const_iterator it = install_sources_pref->begin(); |
288 it != install_sources_pref->end(); ++it) { | 302 it != install_sources_pref->end(); ++it) { |
289 std::string url_pattern; | 303 std::string url_pattern; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 } | 428 } |
415 | 429 |
416 void ExtensionManagementFactory::RegisterProfilePrefs( | 430 void ExtensionManagementFactory::RegisterProfilePrefs( |
417 user_prefs::PrefRegistrySyncable* user_prefs) { | 431 user_prefs::PrefRegistrySyncable* user_prefs) { |
418 user_prefs->RegisterDictionaryPref( | 432 user_prefs->RegisterDictionaryPref( |
419 pref_names::kExtensionManagement, | 433 pref_names::kExtensionManagement, |
420 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 434 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
421 } | 435 } |
422 | 436 |
423 } // namespace extensions | 437 } // namespace extensions |
OLD | NEW |