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

Side by Side Diff: chrome/browser/extensions/extension_management.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (extension->manifest()->GetString(manifest_keys::kUpdateURL, 98 if (extension->manifest()->GetString(manifest_keys::kUpdateURL,
99 &update_url)) { 99 &update_url)) {
100 auto iter_update_url = settings_by_update_url_.find(update_url); 100 auto iter_update_url = settings_by_update_url_.find(update_url);
101 if (iter_update_url != settings_by_update_url_.end()) 101 if (iter_update_url != settings_by_update_url_.end())
102 return iter_update_url->second->installation_mode; 102 return iter_update_url->second->installation_mode;
103 } 103 }
104 // Fall back to default installation mode setting. 104 // Fall back to default installation mode setting.
105 return default_settings_->installation_mode; 105 return default_settings_->installation_mode;
106 } 106 }
107 107
108 scoped_ptr<base::DictionaryValue> ExtensionManagement::GetForceInstallList() 108 std::unique_ptr<base::DictionaryValue>
109 const { 109 ExtensionManagement::GetForceInstallList() const {
110 scoped_ptr<base::DictionaryValue> install_list(new base::DictionaryValue()); 110 std::unique_ptr<base::DictionaryValue> install_list(
111 new base::DictionaryValue());
111 for (SettingsIdMap::const_iterator it = settings_by_id_.begin(); 112 for (SettingsIdMap::const_iterator it = settings_by_id_.begin();
112 it != settings_by_id_.end(); 113 it != settings_by_id_.end();
113 ++it) { 114 ++it) {
114 if (it->second->installation_mode == INSTALLATION_FORCED) { 115 if (it->second->installation_mode == INSTALLATION_FORCED) {
115 ExternalPolicyLoader::AddExtension( 116 ExternalPolicyLoader::AddExtension(
116 install_list.get(), it->first, it->second->update_url); 117 install_list.get(), it->first, it->second->update_url);
117 } 118 }
118 } 119 }
119 return install_list; 120 return install_list;
120 } 121 }
121 122
122 scoped_ptr<base::DictionaryValue> 123 std::unique_ptr<base::DictionaryValue>
123 ExtensionManagement::GetRecommendedInstallList() const { 124 ExtensionManagement::GetRecommendedInstallList() const {
124 scoped_ptr<base::DictionaryValue> install_list(new base::DictionaryValue()); 125 std::unique_ptr<base::DictionaryValue> install_list(
126 new base::DictionaryValue());
125 for (SettingsIdMap::const_iterator it = settings_by_id_.begin(); 127 for (SettingsIdMap::const_iterator it = settings_by_id_.begin();
126 it != settings_by_id_.end(); 128 it != settings_by_id_.end();
127 ++it) { 129 ++it) {
128 if (it->second->installation_mode == INSTALLATION_RECOMMENDED) { 130 if (it->second->installation_mode == INSTALLATION_RECOMMENDED) {
129 ExternalPolicyLoader::AddExtension( 131 ExternalPolicyLoader::AddExtension(
130 install_list.get(), it->first, it->second->update_url); 132 install_list.get(), it->first, it->second->update_url);
131 } 133 }
132 } 134 }
133 return install_list; 135 return install_list;
134 } 136 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 200 }
199 // Check whether if in one of them, setting is specified. 201 // Check whether if in one of them, setting is specified.
200 if (iter_id != settings_by_id_.end()) 202 if (iter_id != settings_by_id_.end())
201 return iter_id->second->blocked_permissions; 203 return iter_id->second->blocked_permissions;
202 if (iter_update_url != settings_by_update_url_.end()) 204 if (iter_update_url != settings_by_update_url_.end())
203 return iter_update_url->second->blocked_permissions; 205 return iter_update_url->second->blocked_permissions;
204 // Fall back to the default blocked permissions setting. 206 // Fall back to the default blocked permissions setting.
205 return default_settings_->blocked_permissions; 207 return default_settings_->blocked_permissions;
206 } 208 }
207 209
208 scoped_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions( 210 std::unique_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions(
209 const Extension* extension) const { 211 const Extension* extension) const {
210 // Only api permissions are supported currently. 212 // Only api permissions are supported currently.
211 return scoped_ptr<const PermissionSet>(new PermissionSet( 213 return std::unique_ptr<const PermissionSet>(new PermissionSet(
212 GetBlockedAPIPermissions(extension), ManifestPermissionSet(), 214 GetBlockedAPIPermissions(extension), ManifestPermissionSet(),
213 URLPatternSet(), URLPatternSet())); 215 URLPatternSet(), URLPatternSet()));
214 } 216 }
215 217
216 bool ExtensionManagement::IsPermissionSetAllowed( 218 bool ExtensionManagement::IsPermissionSetAllowed(
217 const Extension* extension, 219 const Extension* extension,
218 const PermissionSet& perms) const { 220 const PermissionSet& perms) const {
219 for (const auto& blocked_api : GetBlockedAPIPermissions(extension)) { 221 for (const auto& blocked_api : GetBlockedAPIPermissions(extension)) {
220 if (perms.HasAPIPermission(blocked_api->id())) 222 if (perms.HasAPIPermission(blocked_api->id()))
221 return false; 223 return false;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 void ExtensionManagement::NotifyExtensionManagementPrefChanged() { 436 void ExtensionManagement::NotifyExtensionManagementPrefChanged() {
435 FOR_EACH_OBSERVER( 437 FOR_EACH_OBSERVER(
436 Observer, observer_list_, OnExtensionManagementSettingsChanged()); 438 Observer, observer_list_, OnExtensionManagementSettingsChanged());
437 } 439 }
438 440
439 internal::IndividualSettings* ExtensionManagement::AccessById( 441 internal::IndividualSettings* ExtensionManagement::AccessById(
440 const ExtensionId& id) { 442 const ExtensionId& id) {
441 DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id; 443 DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id;
442 SettingsIdMap::iterator it = settings_by_id_.find(id); 444 SettingsIdMap::iterator it = settings_by_id_.find(id);
443 if (it == settings_by_id_.end()) { 445 if (it == settings_by_id_.end()) {
444 scoped_ptr<internal::IndividualSettings> settings( 446 std::unique_ptr<internal::IndividualSettings> settings(
445 new internal::IndividualSettings(default_settings_.get())); 447 new internal::IndividualSettings(default_settings_.get()));
446 it = settings_by_id_.add(id, std::move(settings)).first; 448 it = settings_by_id_.add(id, std::move(settings)).first;
447 } 449 }
448 return it->second; 450 return it->second;
449 } 451 }
450 452
451 internal::IndividualSettings* ExtensionManagement::AccessByUpdateUrl( 453 internal::IndividualSettings* ExtensionManagement::AccessByUpdateUrl(
452 const std::string& update_url) { 454 const std::string& update_url) {
453 DCHECK(GURL(update_url).is_valid()) << "Invalid update URL: " << update_url; 455 DCHECK(GURL(update_url).is_valid()) << "Invalid update URL: " << update_url;
454 SettingsUpdateUrlMap::iterator it = settings_by_update_url_.find(update_url); 456 SettingsUpdateUrlMap::iterator it = settings_by_update_url_.find(update_url);
455 if (it == settings_by_update_url_.end()) { 457 if (it == settings_by_update_url_.end()) {
456 scoped_ptr<internal::IndividualSettings> settings( 458 std::unique_ptr<internal::IndividualSettings> settings(
457 new internal::IndividualSettings(default_settings_.get())); 459 new internal::IndividualSettings(default_settings_.get()));
458 it = settings_by_update_url_.add(update_url, std::move(settings)).first; 460 it = settings_by_update_url_.add(update_url, std::move(settings)).first;
459 } 461 }
460 return it->second; 462 return it->second;
461 } 463 }
462 464
463 ExtensionManagement* ExtensionManagementFactory::GetForBrowserContext( 465 ExtensionManagement* ExtensionManagementFactory::GetForBrowserContext(
464 content::BrowserContext* context) { 466 content::BrowserContext* context) {
465 return static_cast<ExtensionManagement*>( 467 return static_cast<ExtensionManagement*>(
466 GetInstance()->GetServiceForBrowserContext(context, true)); 468 GetInstance()->GetServiceForBrowserContext(context, true));
(...skipping 24 matching lines...) Expand all
491 content::BrowserContext* context) const { 493 content::BrowserContext* context) const {
492 return chrome::GetBrowserContextRedirectedInIncognito(context); 494 return chrome::GetBrowserContextRedirectedInIncognito(context);
493 } 495 }
494 496
495 void ExtensionManagementFactory::RegisterProfilePrefs( 497 void ExtensionManagementFactory::RegisterProfilePrefs(
496 user_prefs::PrefRegistrySyncable* user_prefs) { 498 user_prefs::PrefRegistrySyncable* user_prefs) {
497 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); 499 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement);
498 } 500 }
499 501
500 } // namespace extensions 502 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_management.h ('k') | chrome/browser/extensions/extension_management_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698