summaryrefslogtreecommitdiffstats
path: root/components/content_settings
diff options
context:
space:
mode:
authorraymes <raymes@chromium.org>2015-09-14 10:37:15 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-14 17:37:48 +0000
commiteed14bf7961d7a5c8a04ec1e04cfad16270a0617 (patch)
treec5e941cca46df1ffd19f1ee9a6c27a6a7fc3c48e /components/content_settings
parent59a1ddc1dd3af5e4f30e50a8c959da5e9ce5efa2 (diff)
downloadchromium_src-eed14bf7961d7a5c8a04ec1e04cfad16270a0617.zip
chromium_src-eed14bf7961d7a5c8a04ec1e04cfad16270a0617.tar.gz
chromium_src-eed14bf7961d7a5c8a04ec1e04cfad16270a0617.tar.bz2
Remove CONTENT_SETTINGS_NUM_TYPES (part 4)
This CL removes two more occurences of CONTENT_SETTINGS_NUM_TYPES by replacing arrays keyed off ContentSettingsType with maps. BUG=526932 Review URL: https://codereview.chromium.org/1325423002 Cr-Commit-Position: refs/heads/master@{#348647}
Diffstat (limited to 'components/content_settings')
-rw-r--r--components/content_settings/core/browser/content_settings_binary_value_map.cc13
-rw-r--r--components/content_settings/core/browser/content_settings_binary_value_map.h5
2 files changed, 11 insertions, 7 deletions
diff --git a/components/content_settings/core/browser/content_settings_binary_value_map.cc b/components/content_settings/core/browser/content_settings_binary_value_map.cc
index 136d3874..48f2412 100644
--- a/components/content_settings/core/browser/content_settings_binary_value_map.cc
+++ b/components/content_settings/core/browser/content_settings_binary_value_map.cc
@@ -35,11 +35,9 @@ class RuleIteratorBinary : public RuleIterator {
} // namespace
-BinaryValueMap::BinaryValueMap() {
- for (bool& enabled : is_enabled_) {
- enabled = true;
- }
-}
+BinaryValueMap::BinaryValueMap() {}
+
+BinaryValueMap::~BinaryValueMap() {}
RuleIterator* BinaryValueMap::GetRuleIterator(
ContentSettingsType content_type,
@@ -59,7 +57,10 @@ void BinaryValueMap::SetContentSettingDisabled(ContentSettingsType content_type,
bool BinaryValueMap::IsContentSettingEnabled(
ContentSettingsType content_type) const {
- return is_enabled_[content_type];
+ auto it = is_enabled_.find(content_type);
+ if (it == is_enabled_.end())
+ return true;
+ return it->second;
}
} // namespace content_settings
diff --git a/components/content_settings/core/browser/content_settings_binary_value_map.h b/components/content_settings/core/browser/content_settings_binary_value_map.h
index 3416a13..17c1e55 100644
--- a/components/content_settings/core/browser/content_settings_binary_value_map.h
+++ b/components/content_settings/core/browser/content_settings_binary_value_map.h
@@ -5,6 +5,8 @@
#ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_BINARY_VALUE_MAP_H_
#define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_BINARY_VALUE_MAP_H_
+#include <map>
+
#include "components/content_settings/core/browser/content_settings_provider.h"
#include "components/content_settings/core/common/content_settings_types.h"
@@ -22,6 +24,7 @@ class RuleIterator;
class BinaryValueMap {
public:
BinaryValueMap();
+ ~BinaryValueMap();
RuleIterator* GetRuleIterator(ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
@@ -31,7 +34,7 @@ class BinaryValueMap {
bool IsContentSettingEnabled(ContentSettingsType content_type) const;
private:
- bool is_enabled_[CONTENT_SETTINGS_NUM_TYPES];
+ std::map<ContentSettingsType, bool> is_enabled_;
};
} // namespace content_settings