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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // WARNING: The value specified here for a type should match exactly the value | 22 // WARNING: The value specified here for a type should match exactly the value |
23 // specified in the ContentType enum in enums.xml. Since these values are | 23 // specified in the ContentType enum in enums.xml. Since these values are |
24 // used for histograms, please do not reuse the same value for a different | 24 // used for histograms, please do not reuse the same value for a different |
25 // content setting. Always append to the end and increment. | 25 // content setting. Always append to the end and increment. |
26 // | 26 // |
27 // TODO(raymes): We should use a sparse histogram here on the hash of the | 27 // TODO(raymes): We should use a sparse histogram here on the hash of the |
28 // content settings type name instead. | 28 // content settings type name instead. |
29 // | 29 // |
30 // The array size must be explicit for the static_asserts below. | 30 // The array size must be explicit for the static_asserts below. |
31 constexpr size_t kNumHistogramValues = 31; | 31 constexpr size_t kNumHistogramValues = 32; |
32 constexpr HistogramValue kHistogramValue[kNumHistogramValues] = { | 32 constexpr HistogramValue kHistogramValue[kNumHistogramValues] = { |
33 {CONTENT_SETTINGS_TYPE_COOKIES, 0}, | 33 {CONTENT_SETTINGS_TYPE_COOKIES, 0}, |
34 {CONTENT_SETTINGS_TYPE_IMAGES, 1}, | 34 {CONTENT_SETTINGS_TYPE_IMAGES, 1}, |
35 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, 2}, | 35 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, 2}, |
36 {CONTENT_SETTINGS_TYPE_PLUGINS, 3}, | 36 {CONTENT_SETTINGS_TYPE_PLUGINS, 3}, |
37 {CONTENT_SETTINGS_TYPE_POPUPS, 4}, | 37 {CONTENT_SETTINGS_TYPE_POPUPS, 4}, |
38 {CONTENT_SETTINGS_TYPE_GEOLOCATION, 5}, | 38 {CONTENT_SETTINGS_TYPE_GEOLOCATION, 5}, |
39 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 6}, | 39 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 6}, |
40 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 7}, | 40 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 7}, |
41 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 10}, | 41 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 10}, |
(...skipping 12 matching lines...) Expand all Loading... |
54 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, 27}, | 54 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, 27}, |
55 {CONTENT_SETTINGS_TYPE_AUTOPLAY, 28}, | 55 {CONTENT_SETTINGS_TYPE_AUTOPLAY, 28}, |
56 {CONTENT_SETTINGS_TYPE_IMPORTANT_SITE_INFO, 30}, | 56 {CONTENT_SETTINGS_TYPE_IMPORTANT_SITE_INFO, 30}, |
57 {CONTENT_SETTINGS_TYPE_PERMISSION_AUTOBLOCKER_DATA, 31}, | 57 {CONTENT_SETTINGS_TYPE_PERMISSION_AUTOBLOCKER_DATA, 31}, |
58 {CONTENT_SETTINGS_TYPE_ADS, 32}, | 58 {CONTENT_SETTINGS_TYPE_ADS, 32}, |
59 {CONTENT_SETTINGS_TYPE_ADS_DATA, 33}, | 59 {CONTENT_SETTINGS_TYPE_ADS_DATA, 33}, |
60 {CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, 34}, | 60 {CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, 34}, |
61 {CONTENT_SETTINGS_TYPE_MEDIA_ENGAGEMENT, 35}, | 61 {CONTENT_SETTINGS_TYPE_MEDIA_ENGAGEMENT, 35}, |
62 {CONTENT_SETTINGS_TYPE_SOUND, 36}, | 62 {CONTENT_SETTINGS_TYPE_SOUND, 36}, |
63 {CONTENT_SETTINGS_TYPE_CLIENT_HINTS, 37}, | 63 {CONTENT_SETTINGS_TYPE_CLIENT_HINTS, 37}, |
| 64 {CONTENT_SETTINGS_TYPE_SENSORS, 38}, |
64 }; | 65 }; |
65 | 66 |
66 } // namespace | 67 } // namespace |
67 | 68 |
68 ContentSetting IntToContentSetting(int content_setting) { | 69 ContentSetting IntToContentSetting(int content_setting) { |
69 return ((content_setting < 0) || | 70 return ((content_setting < 0) || |
70 (content_setting >= CONTENT_SETTING_NUM_SETTINGS)) | 71 (content_setting >= CONTENT_SETTING_NUM_SETTINGS)) |
71 ? CONTENT_SETTING_DEFAULT | 72 ? CONTENT_SETTING_DEFAULT |
72 : static_cast<ContentSetting>(content_setting); | 73 : static_cast<ContentSetting>(content_setting); |
73 } | 74 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 129 |
129 ContentSettingPatternSource::~ContentSettingPatternSource() {} | 130 ContentSettingPatternSource::~ContentSettingPatternSource() {} |
130 | 131 |
131 ContentSetting ContentSettingPatternSource::GetContentSetting() const { | 132 ContentSetting ContentSettingPatternSource::GetContentSetting() const { |
132 return content_settings::ValueToContentSetting(setting_value.get()); | 133 return content_settings::ValueToContentSetting(setting_value.get()); |
133 } | 134 } |
134 | 135 |
135 RendererContentSettingRules::RendererContentSettingRules() {} | 136 RendererContentSettingRules::RendererContentSettingRules() {} |
136 | 137 |
137 RendererContentSettingRules::~RendererContentSettingRules() {} | 138 RendererContentSettingRules::~RendererContentSettingRules() {} |
OLD | NEW |