Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/browser/content_settings_utils.h" | |
|
raymes
2017/06/22 03:41:26
Is this needed?
tbansal1
2017/06/22 21:46:15
Obviously not :P
| |
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 } | 71 } |
| 71 | 72 |
| 72 DCHECK(base::ContainsKey(kMap, content_setting)); | 73 DCHECK(base::ContainsKey(kMap, content_setting)); |
| 73 *num_values = arraysize(kHistogramValue); | 74 *num_values = arraysize(kHistogramValue); |
| 74 return kMap[content_setting]; | 75 return kMap[content_setting]; |
| 75 } | 76 } |
| 76 | 77 |
| 77 ContentSettingPatternSource::ContentSettingPatternSource( | 78 ContentSettingPatternSource::ContentSettingPatternSource( |
| 78 const ContentSettingsPattern& primary_pattern, | 79 const ContentSettingsPattern& primary_pattern, |
| 79 const ContentSettingsPattern& secondary_pattern, | 80 const ContentSettingsPattern& secondary_pattern, |
| 80 ContentSetting setting, | 81 const base::Value& setting_value, |
|
raymes
2017/06/22 03:41:26
To avoid additional copies, should we pass in a un
tbansal1
2017/06/22 21:46:15
Done.
| |
| 81 const std::string& source, | 82 const std::string& source, |
| 82 bool incognito) | 83 bool incognito) |
| 83 : primary_pattern(primary_pattern), | 84 : primary_pattern(primary_pattern), |
| 84 secondary_pattern(secondary_pattern), | 85 secondary_pattern(secondary_pattern), |
| 85 setting(setting), | 86 setting_value(base::MakeUnique<base::Value>(setting_value)), |
| 86 source(source), | 87 source(source), |
| 87 incognito(incognito) {} | 88 incognito(incognito) {} |
| 88 | 89 |
| 89 ContentSettingPatternSource::ContentSettingPatternSource() | 90 ContentSettingPatternSource::ContentSettingPatternSource() : incognito(false) {} |
| 90 : setting(CONTENT_SETTING_DEFAULT), incognito(false) { | 91 |
| 92 ContentSettingPatternSource::ContentSettingPatternSource( | |
| 93 const ContentSettingPatternSource& other) { | |
| 94 primary_pattern = other.primary_pattern; | |
| 95 secondary_pattern = other.secondary_pattern; | |
| 96 source = other.source; | |
| 97 if (other.setting_value) | |
| 98 setting_value = other.setting_value->CreateDeepCopy(); | |
|
raymes
2017/06/22 03:41:26
I think CreateDeepCopy is deprecated? I think the
tbansal1
2017/06/22 21:46:15
Done.
| |
| 99 incognito = other.incognito; | |
| 91 } | 100 } |
| 92 | 101 |
| 93 ContentSettingPatternSource::ContentSettingPatternSource( | 102 ContentSettingPatternSource& ContentSettingPatternSource::operator=( |
| 94 const ContentSettingPatternSource& other) = default; | 103 const ContentSettingPatternSource& other) { |
| 104 if (other.setting_value) | |
| 105 setting_value = other.setting_value->CreateDeepCopy(); | |
| 106 primary_pattern = other.primary_pattern; | |
| 107 secondary_pattern = other.secondary_pattern; | |
| 108 source = other.source; | |
| 109 incognito = other.incognito; | |
| 110 return *this; | |
|
raymes
2017/06/22 03:41:26
nit: please keep the order of assignments the same
tbansal1
2017/06/22 21:46:15
Done.
| |
| 111 } | |
| 112 | |
| 113 ContentSettingPatternSource::~ContentSettingPatternSource() {} | |
|
raymes
2017/06/22 03:41:26
Did you consider exposing a GetContentSetting() fu
tbansal1
2017/06/22 21:46:16
Done.
| |
| 95 | 114 |
| 96 RendererContentSettingRules::RendererContentSettingRules() {} | 115 RendererContentSettingRules::RendererContentSettingRules() {} |
| 97 | 116 |
| 98 RendererContentSettingRules::~RendererContentSettingRules() {} | 117 RendererContentSettingRules::~RendererContentSettingRules() {} |
| OLD | NEW |