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

Side by Side Diff: components/content_settings/core/common/content_settings.cc

Issue 2938163002: Store base::Value in ContentSettingPatternSource instead of an enum (Closed)
Patch Set: rebased Created 3 years, 5 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "components/content_settings/core/common/content_settings.h" 5 #include "components/content_settings/core/common/content_settings.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "components/content_settings/core/common/content_settings_utils.h"
12 13
13 ContentSetting IntToContentSetting(int content_setting) { 14 ContentSetting IntToContentSetting(int content_setting) {
14 return ((content_setting < 0) || 15 return ((content_setting < 0) ||
15 (content_setting >= CONTENT_SETTING_NUM_SETTINGS)) ? 16 (content_setting >= CONTENT_SETTING_NUM_SETTINGS)) ?
16 CONTENT_SETTING_DEFAULT : static_cast<ContentSetting>(content_setting); 17 CONTENT_SETTING_DEFAULT : static_cast<ContentSetting>(content_setting);
17 } 18 }
18 19
19 struct HistogramValue { 20 struct HistogramValue {
20 ContentSettingsType type; 21 ContentSettingsType type;
21 int value; 22 int value;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 72 }
72 73
73 DCHECK(base::ContainsKey(kMap, content_setting)); 74 DCHECK(base::ContainsKey(kMap, content_setting));
74 *num_values = arraysize(kHistogramValue); 75 *num_values = arraysize(kHistogramValue);
75 return kMap[content_setting]; 76 return kMap[content_setting];
76 } 77 }
77 78
78 ContentSettingPatternSource::ContentSettingPatternSource( 79 ContentSettingPatternSource::ContentSettingPatternSource(
79 const ContentSettingsPattern& primary_pattern, 80 const ContentSettingsPattern& primary_pattern,
80 const ContentSettingsPattern& secondary_pattern, 81 const ContentSettingsPattern& secondary_pattern,
81 ContentSetting setting, 82 std::unique_ptr<base::Value> setting_value,
82 const std::string& source, 83 const std::string& source,
83 bool incognito) 84 bool incognito)
84 : primary_pattern(primary_pattern), 85 : primary_pattern(primary_pattern),
85 secondary_pattern(secondary_pattern), 86 secondary_pattern(secondary_pattern),
86 setting(setting), 87 setting_value(std::move(setting_value)),
87 source(source), 88 source(source),
88 incognito(incognito) {} 89 incognito(incognito) {}
89 90
90 ContentSettingPatternSource::ContentSettingPatternSource() 91 ContentSettingPatternSource::ContentSettingPatternSource() : incognito(false) {}
91 : setting(CONTENT_SETTING_DEFAULT), incognito(false) { 92
93 ContentSettingPatternSource::ContentSettingPatternSource(
94 const ContentSettingPatternSource& other) {
95 *this = other;
92 } 96 }
93 97
94 ContentSettingPatternSource::ContentSettingPatternSource( 98 ContentSettingPatternSource& ContentSettingPatternSource::operator=(
95 const ContentSettingPatternSource& other) = default; 99 const ContentSettingPatternSource& other) {
100 primary_pattern = other.primary_pattern;
101 secondary_pattern = other.secondary_pattern;
102 if (other.setting_value)
103 setting_value = base::MakeUnique<base::Value>(*(other.setting_value));
104 source = other.source;
105 incognito = other.incognito;
106 return *this;
107 }
108
109 ContentSettingPatternSource::~ContentSettingPatternSource() {}
110
111 ContentSetting ContentSettingPatternSource::GetContentSetting() const {
112 return content_settings::ValueToContentSetting(setting_value.get());
113 }
96 114
97 RendererContentSettingRules::RendererContentSettingRules() {} 115 RendererContentSettingRules::RendererContentSettingRules() {}
98 116
99 RendererContentSettingRules::~RendererContentSettingRules() {} 117 RendererContentSettingRules::~RendererContentSettingRules() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698