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

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

Issue 2606553002: Remove base::ScopedPtrHashMap from chrome/browser/extensions. (Closed)
Patch Set: fixes Created 4 years 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
« no previous file with comments | « chrome/browser/extensions/extension_management.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_management.cc
diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc
index 7af13aff7c7652d262be7799d952b2029d221573..1e8904b00fe0916a33dc1cc589e455a6678c71cc 100644
--- a/chrome/browser/extensions/extension_management.cc
+++ b/chrome/browser/extensions/extension_management.cc
@@ -113,12 +113,10 @@ std::unique_ptr<base::DictionaryValue>
ExtensionManagement::GetForceInstallList() const {
std::unique_ptr<base::DictionaryValue> install_list(
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(
- install_list.get(), it->first, it->second->update_url);
+ for (const auto& entry : settings_by_id_) {
+ if (entry.second->installation_mode == INSTALLATION_FORCED) {
+ ExternalPolicyLoader::AddExtension(install_list.get(), entry.first,
+ entry.second->update_url);
}
}
return install_list;
@@ -128,12 +126,10 @@ std::unique_ptr<base::DictionaryValue>
ExtensionManagement::GetRecommendedInstallList() const {
std::unique_ptr<base::DictionaryValue> install_list(
new base::DictionaryValue());
- for (SettingsIdMap::const_iterator it = settings_by_id_.begin();
- it != settings_by_id_.end();
- ++it) {
- if (it->second->installation_mode == INSTALLATION_RECOMMENDED) {
- ExternalPolicyLoader::AddExtension(
- install_list.get(), it->first, it->second->update_url);
+ for (const auto& entry : settings_by_id_) {
+ if (entry.second->installation_mode == INSTALLATION_RECOMMENDED) {
+ ExternalPolicyLoader::AddExtension(install_list.get(), entry.first,
+ entry.second->update_url);
}
}
return install_list;
@@ -141,7 +137,7 @@ ExtensionManagement::GetRecommendedInstallList() const {
bool ExtensionManagement::IsInstallationExplicitlyAllowed(
const ExtensionId& id) const {
- SettingsIdMap::const_iterator it = settings_by_id_.find(id);
+ auto it = settings_by_id_.find(id);
// No settings explicitly specified for |id|.
if (it == settings_by_id_.end())
return false;
@@ -445,25 +441,24 @@ void ExtensionManagement::NotifyExtensionManagementPrefChanged() {
internal::IndividualSettings* ExtensionManagement::AccessById(
const ExtensionId& id) {
DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id;
- SettingsIdMap::iterator it = settings_by_id_.find(id);
- if (it == settings_by_id_.end()) {
- std::unique_ptr<internal::IndividualSettings> settings(
- new internal::IndividualSettings(default_settings_.get()));
- it = settings_by_id_.add(id, std::move(settings)).first;
+ std::unique_ptr<internal::IndividualSettings>& settings = settings_by_id_[id];
+ if (!settings) {
+ settings =
+ base::MakeUnique<internal::IndividualSettings>(default_settings_.get());
}
- return it->second;
+ return settings.get();
}
internal::IndividualSettings* ExtensionManagement::AccessByUpdateUrl(
const std::string& update_url) {
DCHECK(GURL(update_url).is_valid()) << "Invalid update URL: " << update_url;
- SettingsUpdateUrlMap::iterator it = settings_by_update_url_.find(update_url);
- if (it == settings_by_update_url_.end()) {
- std::unique_ptr<internal::IndividualSettings> settings(
- new internal::IndividualSettings(default_settings_.get()));
- it = settings_by_update_url_.add(update_url, std::move(settings)).first;
+ std::unique_ptr<internal::IndividualSettings>& settings =
+ settings_by_update_url_[update_url];
+ if (!settings) {
+ settings =
+ base::MakeUnique<internal::IndividualSettings>(default_settings_.get());
}
- return it->second;
+ return settings.get();
}
ExtensionManagement* ExtensionManagementFactory::GetForBrowserContext(
« no previous file with comments | « chrome/browser/extensions/extension_management.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698