Commit d4e68c5f authored by avi's avatar avi Committed by Commit bot

Remove stl_util's deletion function use from components/content_settings/.

BUG=555865

Review-Url: https://codereview.chromium.org/2444703002
Cr-Commit-Position: refs/heads/master@{#427012}
parent 4020282e
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/clock.h" #include "base/time/clock.h"
...@@ -170,12 +169,13 @@ HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs, ...@@ -170,12 +169,13 @@ HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs,
content_settings::PolicyProvider* policy_provider = content_settings::PolicyProvider* policy_provider =
new content_settings::PolicyProvider(prefs_); new content_settings::PolicyProvider(prefs_);
content_settings_providers_[POLICY_PROVIDER] = policy_provider; content_settings_providers_[POLICY_PROVIDER] =
base::WrapUnique(policy_provider);
policy_provider->AddObserver(this); policy_provider->AddObserver(this);
pref_provider_ = pref_provider_ =
new content_settings::PrefProvider(prefs_, is_off_the_record_); new content_settings::PrefProvider(prefs_, is_off_the_record_);
content_settings_providers_[PREF_PROVIDER] = pref_provider_; content_settings_providers_[PREF_PROVIDER] = base::WrapUnique(pref_provider_);
pref_provider_->AddObserver(this); pref_provider_->AddObserver(this);
// This ensures that content settings are cleared for the guest profile. This // This ensures that content settings are cleared for the guest profile. This
...@@ -184,10 +184,10 @@ HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs, ...@@ -184,10 +184,10 @@ HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs,
if (is_guest_profile) if (is_guest_profile)
pref_provider_->ClearPrefs(); pref_provider_->ClearPrefs();
content_settings::ObservableProvider* default_provider = auto default_provider = base::MakeUnique<content_settings::DefaultProvider>(
new content_settings::DefaultProvider(prefs_, is_off_the_record_); prefs_, is_off_the_record_);
default_provider->AddObserver(this); default_provider->AddObserver(this);
content_settings_providers_[DEFAULT_PROVIDER] = default_provider; content_settings_providers_[DEFAULT_PROVIDER] = std::move(default_provider);
MigrateKeygenSettings(); MigrateKeygenSettings();
MigrateDomainScopedSettings(false); MigrateDomainScopedSettings(false);
...@@ -215,7 +215,7 @@ void HostContentSettingsMap::RegisterProvider( ...@@ -215,7 +215,7 @@ void HostContentSettingsMap::RegisterProvider(
std::unique_ptr<content_settings::ObservableProvider> provider) { std::unique_ptr<content_settings::ObservableProvider> provider) {
DCHECK(!content_settings_providers_[type]); DCHECK(!content_settings_providers_[type]);
provider->AddObserver(this); provider->AddObserver(this);
content_settings_providers_[type] = provider.release(); content_settings_providers_[type] = std::move(provider);
#ifndef NDEBUG #ifndef NDEBUG
DCHECK_NE(used_from_thread_id_, base::kInvalidThreadId) DCHECK_NE(used_from_thread_id_, base::kInvalidThreadId)
...@@ -255,13 +255,11 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSettingInternal( ...@@ -255,13 +255,11 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSettingInternal(
// Iterate through the list of providers and return the first non-NULL value // Iterate through the list of providers and return the first non-NULL value
// that matches |primary_url| and |secondary_url|. // that matches |primary_url| and |secondary_url|.
for (ConstProviderIterator provider = content_settings_providers_.begin(); for (const auto& provider_pair : content_settings_providers_) {
provider != content_settings_providers_.end(); if (provider_pair.first == PREF_PROVIDER)
++provider) {
if (provider->first == PREF_PROVIDER)
continue; continue;
ContentSetting default_setting = ContentSetting default_setting = GetDefaultContentSettingFromProvider(
GetDefaultContentSettingFromProvider(content_type, provider->second); content_type, provider_pair.second.get());
if (is_off_the_record_) { if (is_off_the_record_) {
default_setting = content_settings::ValueToContentSetting( default_setting = content_settings::ValueToContentSetting(
ProcessIncognitoInheritanceBehavior( ProcessIncognitoInheritanceBehavior(
...@@ -270,7 +268,7 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSettingInternal( ...@@ -270,7 +268,7 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSettingInternal(
.get()); .get());
} }
if (default_setting != CONTENT_SETTING_DEFAULT) { if (default_setting != CONTENT_SETTING_DEFAULT) {
*provider_type = provider->first; *provider_type = provider_pair.first;
return default_setting; return default_setting;
} }
} }
...@@ -311,25 +309,15 @@ void HostContentSettingsMap::GetSettingsForOneType( ...@@ -311,25 +309,15 @@ void HostContentSettingsMap::GetSettingsForOneType(
UsedContentSettingsProviders(); UsedContentSettingsProviders();
settings->clear(); settings->clear();
for (ConstProviderIterator provider = content_settings_providers_.begin(); for (const auto& provider_pair : content_settings_providers_) {
provider != content_settings_providers_.end();
++provider) {
// For each provider, iterate first the incognito-specific rules, then the // For each provider, iterate first the incognito-specific rules, then the
// normal rules. // normal rules.
if (is_off_the_record_) { if (is_off_the_record_) {
AddSettingsForOneType(provider->second, AddSettingsForOneType(provider_pair.second.get(), provider_pair.first,
provider->first, content_type, resource_identifier, settings, true);
content_type,
resource_identifier,
settings,
true);
} }
AddSettingsForOneType(provider->second, AddSettingsForOneType(provider_pair.second.get(), provider_pair.first,
provider->first, content_type, resource_identifier, settings, false);
content_type,
resource_identifier,
settings,
false);
} }
} }
...@@ -377,11 +365,11 @@ void HostContentSettingsMap::SetWebsiteSettingCustomScope( ...@@ -377,11 +365,11 @@ void HostContentSettingsMap::SetWebsiteSettingCustomScope(
resource_identifier.empty()); resource_identifier.empty());
UsedContentSettingsProviders(); UsedContentSettingsProviders();
for (auto& provider_pair : content_settings_providers_) { for (const auto& provider_pair : content_settings_providers_) {
if (provider_pair.second->SetWebsiteSetting( if (provider_pair.second->SetWebsiteSetting(
primary_pattern, secondary_pattern, content_type, primary_pattern, secondary_pattern, content_type,
resource_identifier, value.get())) { resource_identifier, value.get())) {
// If succesful then ownership is passed to the provider. // If successful then ownership is passed to the provider.
ignore_result(value.release()); ignore_result(value.release());
return; return;
} }
...@@ -739,11 +727,8 @@ void HostContentSettingsMap::SetPrefClockForTesting( ...@@ -739,11 +727,8 @@ void HostContentSettingsMap::SetPrefClockForTesting(
void HostContentSettingsMap::ClearSettingsForOneType( void HostContentSettingsMap::ClearSettingsForOneType(
ContentSettingsType content_type) { ContentSettingsType content_type) {
UsedContentSettingsProviders(); UsedContentSettingsProviders();
for (ProviderIterator provider = content_settings_providers_.begin(); for (const auto& provider_pair : content_settings_providers_)
provider != content_settings_providers_.end(); provider_pair.second->ClearAllContentSettingsRules(content_type);
++provider) {
provider->second->ClearAllContentSettingsRules(content_type);
}
FlushLossyWebsiteSettings(); FlushLossyWebsiteSettings();
} }
...@@ -813,18 +798,14 @@ void HostContentSettingsMap::OnContentSettingChanged( ...@@ -813,18 +798,14 @@ void HostContentSettingsMap::OnContentSettingChanged(
HostContentSettingsMap::~HostContentSettingsMap() { HostContentSettingsMap::~HostContentSettingsMap() {
DCHECK(!prefs_); DCHECK(!prefs_);
base::STLDeleteValues(&content_settings_providers_);
} }
void HostContentSettingsMap::ShutdownOnUIThread() { void HostContentSettingsMap::ShutdownOnUIThread() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(prefs_); DCHECK(prefs_);
prefs_ = NULL; prefs_ = NULL;
for (ProviderIterator it = content_settings_providers_.begin(); for (const auto& provider_pair : content_settings_providers_)
it != content_settings_providers_.end(); provider_pair.second->ShutdownOnUIThread();
++it) {
it->second->ShutdownOnUIThread();
}
} }
void HostContentSettingsMap::AddSettingsForOneType( void HostContentSettingsMap::AddSettingsForOneType(
...@@ -937,16 +918,15 @@ std::unique_ptr<base::Value> HostContentSettingsMap::GetWebsiteSettingInternal( ...@@ -937,16 +918,15 @@ std::unique_ptr<base::Value> HostContentSettingsMap::GetWebsiteSettingInternal(
// The list of |content_settings_providers_| is ordered according to their // The list of |content_settings_providers_| is ordered according to their
// precedence. // precedence.
for (ConstProviderIterator provider = content_settings_providers_.begin(); for (const auto& provider_pair : content_settings_providers_) {
provider != content_settings_providers_.end();
++provider) {
std::unique_ptr<base::Value> value = GetContentSettingValueAndPatterns( std::unique_ptr<base::Value> value = GetContentSettingValueAndPatterns(
provider->second, primary_url, secondary_url, content_type, provider_pair.second.get(), primary_url, secondary_url, content_type,
resource_identifier, is_off_the_record_, primary_pattern, resource_identifier, is_off_the_record_, primary_pattern,
secondary_pattern); secondary_pattern);
if (value) { if (value) {
if (info) if (info)
info->source = kProviderNamesSourceMap[provider->first].provider_source; info->source =
kProviderNamesSourceMap[provider_pair.first].provider_source;
return value; return value;
} }
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_
#include <map> #include <map>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -310,11 +311,6 @@ class HostContentSettingsMap : public content_settings::Observer, ...@@ -310,11 +311,6 @@ class HostContentSettingsMap : public content_settings::Observer,
friend class content_settings::TestUtils; friend class content_settings::TestUtils;
typedef std::map<ProviderType, content_settings::ProviderInterface*>
ProviderMap;
typedef ProviderMap::iterator ProviderIterator;
typedef ProviderMap::const_iterator ConstProviderIterator;
~HostContentSettingsMap() override; ~HostContentSettingsMap() override;
ContentSetting GetDefaultContentSettingFromProvider( ContentSetting GetDefaultContentSettingFromProvider(
...@@ -404,7 +400,8 @@ class HostContentSettingsMap : public content_settings::Observer, ...@@ -404,7 +400,8 @@ class HostContentSettingsMap : public content_settings::Observer,
// Content setting providers. This is only modified at construction // Content setting providers. This is only modified at construction
// time and by RegisterExtensionService, both of which should happen // time and by RegisterExtensionService, both of which should happen
// before any other uses of it. // before any other uses of it.
ProviderMap content_settings_providers_; std::map<ProviderType, std::unique_ptr<content_settings::ProviderInterface>>
content_settings_providers_;
// content_settings_providers_[PREF_PROVIDER] but specialized. // content_settings_providers_[PREF_PROVIDER] but specialized.
content_settings::PrefProvider* pref_provider_ = nullptr; content_settings::PrefProvider* pref_provider_ = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment