Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / components / content_settings / core / common / content_settings.cc
blob491f973d475e9c9830d3679e4e80cb50ebe15380
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
3 // found in the LICENSE file.
5 #include "components/content_settings/core/common/content_settings.h"
7 #include "base/logging.h"
9 ContentSetting IntToContentSetting(int content_setting) {
10 return ((content_setting < 0) ||
11 (content_setting >= CONTENT_SETTING_NUM_SETTINGS)) ?
12 CONTENT_SETTING_DEFAULT : static_cast<ContentSetting>(content_setting);
15 ContentSettingsTypeHistogram ContentSettingTypeToHistogramValue(
16 ContentSettingsType content_setting) {
17 switch (content_setting) {
18 case CONTENT_SETTINGS_TYPE_DEFAULT:
19 return CONTENT_SETTINGS_TYPE_HISTOGRAM_INVALID;
20 case CONTENT_SETTINGS_TYPE_COOKIES:
21 return CONTENT_SETTINGS_TYPE_HISTOGRAM_COOKIES;
22 case CONTENT_SETTINGS_TYPE_IMAGES:
23 return CONTENT_SETTINGS_TYPE_HISTOGRAM_IMAGES;
24 case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
25 return CONTENT_SETTINGS_TYPE_HISTOGRAM_JAVASCRIPT;
26 case CONTENT_SETTINGS_TYPE_PLUGINS:
27 return CONTENT_SETTINGS_TYPE_HISTOGRAM_PLUGINS;
28 case CONTENT_SETTINGS_TYPE_POPUPS:
29 return CONTENT_SETTINGS_TYPE_HISTOGRAM_POPUPS;
30 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
31 return CONTENT_SETTINGS_TYPE_HISTOGRAM_GEOLOCATION;
32 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
33 return CONTENT_SETTINGS_TYPE_HISTOGRAM_NOTIFICATIONS;
34 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE:
35 return CONTENT_SETTINGS_TYPE_HISTOGRAM_AUTO_SELECT_CERTIFICATE;
36 case CONTENT_SETTINGS_TYPE_FULLSCREEN:
37 return CONTENT_SETTINGS_TYPE_HISTOGRAM_FULLSCREEN;
38 case CONTENT_SETTINGS_TYPE_MOUSELOCK:
39 return CONTENT_SETTINGS_TYPE_HISTOGRAM_MOUSELOCK;
40 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
41 return CONTENT_SETTINGS_TYPE_HISTOGRAM_MIXEDSCRIPT;
42 case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
43 return CONTENT_SETTINGS_TYPE_HISTOGRAM_MEDIASTREAM;
44 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
45 return CONTENT_SETTINGS_TYPE_HISTOGRAM_MEDIASTREAM_MIC;
46 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
47 return CONTENT_SETTINGS_TYPE_HISTOGRAM_MEDIASTREAM_CAMERA;
48 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS:
49 return CONTENT_SETTINGS_TYPE_HISTOGRAM_PROTOCOL_HANDLERS;
50 case CONTENT_SETTINGS_TYPE_PPAPI_BROKER:
51 return CONTENT_SETTINGS_TYPE_HISTOGRAM_PPAPI_BROKER;
52 case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS:
53 return CONTENT_SETTINGS_TYPE_HISTOGRAM_AUTOMATIC_DOWNLOADS;
54 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
55 return CONTENT_SETTINGS_TYPE_HISTOGRAM_MIDI_SYSEX;
56 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
57 return CONTENT_SETTINGS_TYPE_HISTOGRAM_PUSH_MESSAGING;
58 case CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS:
59 return CONTENT_SETTINGS_TYPE_HISTOGRAM_SSL_CERT_DECISIONS;
60 #if defined(OS_WIN)
61 case CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP:
62 return CONTENT_SETTINGS_TYPE_HISTOGRAM_METRO_SWITCH_TO_DESKTOP;
63 #elif defined(OS_ANDROID) || defined(OS_CHROMEOS)
64 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
65 return CONTENT_SETTINGS_TYPE_HISTOGRAM_PROTECTED_MEDIA_IDENTIFIER;
66 #endif
67 case CONTENT_SETTINGS_TYPE_APP_BANNER:
68 return CONTENT_SETTINGS_TYPE_HISTOGRAM_APP_BANNER;
69 case CONTENT_SETTINGS_NUM_TYPES:
70 return CONTENT_SETTINGS_TYPE_HISTOGRAM_INVALID;
72 NOTREACHED();
73 return CONTENT_SETTINGS_TYPE_HISTOGRAM_INVALID;
76 bool IsContentSettingsTypeSyncable(ContentSettingsType content_setting) {
77 switch (content_setting) {
78 case CONTENT_SETTINGS_TYPE_COOKIES:
79 case CONTENT_SETTINGS_TYPE_IMAGES:
80 case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
81 case CONTENT_SETTINGS_TYPE_PLUGINS:
82 case CONTENT_SETTINGS_TYPE_POPUPS:
83 case CONTENT_SETTINGS_TYPE_FULLSCREEN:
84 case CONTENT_SETTINGS_TYPE_MOUSELOCK:
85 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
86 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS:
87 case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS:
88 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
89 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
90 #if defined(OS_WIN)
91 case CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP:
92 #endif
93 return true;
95 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
96 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
97 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE:
98 case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
99 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
100 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
101 case CONTENT_SETTINGS_TYPE_PPAPI_BROKER:
102 case CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS:
103 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
104 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
105 #endif
106 case CONTENT_SETTINGS_TYPE_APP_BANNER:
107 return false;
109 case CONTENT_SETTINGS_TYPE_DEFAULT:
110 case CONTENT_SETTINGS_NUM_TYPES:
111 NOTREACHED();
112 return false;
114 NOTREACHED();
115 return false;
118 ContentSettingPatternSource::ContentSettingPatternSource(
119 const ContentSettingsPattern& primary_pattern,
120 const ContentSettingsPattern& secondary_pattern,
121 ContentSetting setting,
122 const std::string& source,
123 bool incognito)
124 : primary_pattern(primary_pattern),
125 secondary_pattern(secondary_pattern),
126 setting(setting),
127 source(source),
128 incognito(incognito) {}
130 ContentSettingPatternSource::ContentSettingPatternSource()
131 : setting(CONTENT_SETTING_DEFAULT), incognito(false) {
134 RendererContentSettingRules::RendererContentSettingRules() {}
136 RendererContentSettingRules::~RendererContentSettingRules() {}