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

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

Issue 2795053002: [subresource_filter] Implement the "Smart" UI on Android (Closed)
Patch Set: engedy review Created 3 years, 8 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 12
13 ContentSetting IntToContentSetting(int content_setting) { 13 ContentSetting IntToContentSetting(int content_setting) {
14 return ((content_setting < 0) || 14 return ((content_setting < 0) ||
15 (content_setting >= CONTENT_SETTING_NUM_SETTINGS)) ? 15 (content_setting >= CONTENT_SETTING_NUM_SETTINGS)) ?
16 CONTENT_SETTING_DEFAULT : static_cast<ContentSetting>(content_setting); 16 CONTENT_SETTING_DEFAULT : static_cast<ContentSetting>(content_setting);
17 } 17 }
18 18
19 // WARNING: This array should not be reordered or removed as it is used for 19 // WARNING: This array should not be reordered or removed as it is used for
20 // histogram values. If a ContentSettingsType value has been removed, the entry 20 // histogram values. If a ContentSettingsType value has been removed, the entry
21 // must be replaced by a placeholder. It should correspond directly to the 21 // must be replaced by a placeholder. It should correspond directly to the
22 // ContentType enum in histograms.xml. 22 // ContentType enum in histograms.xml.
23 // TODO(raymes): We should use a sparse histogram here on the hash of the 23 // TODO(raymes): We should use a sparse histogram here on the hash of the
24 // content settings type name instead. 24 // content settings type name instead.
25 // TODO(raymes): This has become out of sync with histograms.xml. See
26 // crbug.com/697234.
25 ContentSettingsType kHistogramOrder[] = { 27 ContentSettingsType kHistogramOrder[] = {
26 CONTENT_SETTINGS_TYPE_COOKIES, 28 CONTENT_SETTINGS_TYPE_COOKIES,
27 CONTENT_SETTINGS_TYPE_IMAGES, 29 CONTENT_SETTINGS_TYPE_IMAGES,
28 CONTENT_SETTINGS_TYPE_JAVASCRIPT, 30 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
29 CONTENT_SETTINGS_TYPE_PLUGINS, 31 CONTENT_SETTINGS_TYPE_PLUGINS,
30 CONTENT_SETTINGS_TYPE_POPUPS, 32 CONTENT_SETTINGS_TYPE_POPUPS,
31 CONTENT_SETTINGS_TYPE_GEOLOCATION, 33 CONTENT_SETTINGS_TYPE_GEOLOCATION,
32 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 34 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
33 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 35 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
34 CONTENT_SETTINGS_TYPE_DEFAULT, // FULLSCREEN (removed). 36 CONTENT_SETTINGS_TYPE_DEFAULT, // FULLSCREEN (removed).
(...skipping 18 matching lines...) Expand all
53 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, 55 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT,
54 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, 56 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE,
55 CONTENT_SETTINGS_TYPE_DEFAULT, // KEYGEN (removed). 57 CONTENT_SETTINGS_TYPE_DEFAULT, // KEYGEN (removed).
56 CONTENT_SETTINGS_TYPE_BLUETOOTH_GUARD, 58 CONTENT_SETTINGS_TYPE_BLUETOOTH_GUARD,
57 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, 59 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
58 CONTENT_SETTINGS_TYPE_AUTOPLAY, 60 CONTENT_SETTINGS_TYPE_AUTOPLAY,
59 CONTENT_SETTINGS_TYPE_DEFAULT, // PROMPT_NO_DECISION_COUNT (migrated). 61 CONTENT_SETTINGS_TYPE_DEFAULT, // PROMPT_NO_DECISION_COUNT (migrated).
60 CONTENT_SETTINGS_TYPE_IMPORTANT_SITE_INFO, 62 CONTENT_SETTINGS_TYPE_IMPORTANT_SITE_INFO,
61 CONTENT_SETTINGS_TYPE_PERMISSION_AUTOBLOCKER_DATA, 63 CONTENT_SETTINGS_TYPE_PERMISSION_AUTOBLOCKER_DATA,
62 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, 64 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER,
65 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER_DATA,
raymes 2017/04/12 22:35:15 Could you please omit this for now until I've land
Charlie Harrison 2017/04/13 03:41:30 Done.
63 }; 66 };
64 67
65 int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting, 68 int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting,
66 size_t* num_values) { 69 size_t* num_values) {
67 // Translate the list above into a map for fast lookup. 70 // Translate the list above into a map for fast lookup.
68 typedef base::hash_map<int, int> Map; 71 typedef base::hash_map<int, int> Map;
69 CR_DEFINE_STATIC_LOCAL(Map, kMap, ()); 72 CR_DEFINE_STATIC_LOCAL(Map, kMap, ());
70 if (kMap.empty()) { 73 if (kMap.empty()) {
71 for (size_t i = 0; i < arraysize(kHistogramOrder); ++i) { 74 for (size_t i = 0; i < arraysize(kHistogramOrder); ++i) {
72 if (kHistogramOrder[i] != CONTENT_SETTINGS_TYPE_DEFAULT) 75 if (kHistogramOrder[i] != CONTENT_SETTINGS_TYPE_DEFAULT)
(...skipping 21 matching lines...) Expand all
94 ContentSettingPatternSource::ContentSettingPatternSource() 97 ContentSettingPatternSource::ContentSettingPatternSource()
95 : setting(CONTENT_SETTING_DEFAULT), incognito(false) { 98 : setting(CONTENT_SETTING_DEFAULT), incognito(false) {
96 } 99 }
97 100
98 ContentSettingPatternSource::ContentSettingPatternSource( 101 ContentSettingPatternSource::ContentSettingPatternSource(
99 const ContentSettingPatternSource& other) = default; 102 const ContentSettingPatternSource& other) = default;
100 103
101 RendererContentSettingRules::RendererContentSettingRules() {} 104 RendererContentSettingRules::RendererContentSettingRules() {}
102 105
103 RendererContentSettingRules::~RendererContentSettingRules() {} 106 RendererContentSettingRules::~RendererContentSettingRules() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698