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

Side by Side Diff: components/content_settings/core/browser/content_settings_registry.cc

Issue 1895993003: Add migration code to change existing domain scoped content settings to be origin scoped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove logs and format Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser/content_settings_registry.h" 5 #include "components/content_settings/core/browser/content_settings_registry.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void ContentSettingsRegistry::ResetForTest() { 89 void ContentSettingsRegistry::ResetForTest() {
90 website_settings_registry_->ResetForTest(); 90 website_settings_registry_->ResetForTest();
91 content_settings_info_.clear(); 91 content_settings_info_.clear();
92 Init(); 92 Init();
93 } 93 }
94 94
95 ContentSettingsRegistry::~ContentSettingsRegistry() {} 95 ContentSettingsRegistry::~ContentSettingsRegistry() {}
96 96
97 const ContentSettingsInfo* ContentSettingsRegistry::Get( 97 const ContentSettingsInfo* ContentSettingsRegistry::Get(
98 ContentSettingsType type) const { 98 ContentSettingsType type) const {
99 LOG(ERROR) << "--------lshang--------Get-----" << type;
raymes 2016/06/16 03:23:50 nit: remove this
lshang 2016/06/20 01:34:22 Done.
99 const auto& it = content_settings_info_.find(type); 100 const auto& it = content_settings_info_.find(type);
100 if (it != content_settings_info_.end()) 101 if (it != content_settings_info_.end())
101 return it->second.get(); 102 return it->second.get();
102 return nullptr; 103 return nullptr;
103 } 104 }
104 105
105 ContentSettingsRegistry::const_iterator ContentSettingsRegistry::begin() const { 106 ContentSettingsRegistry::const_iterator ContentSettingsRegistry::begin() const {
106 return const_iterator(content_settings_info_.begin()); 107 return const_iterator(content_settings_info_.begin());
107 } 108 }
108 109
109 ContentSettingsRegistry::const_iterator ContentSettingsRegistry::end() const { 110 ContentSettingsRegistry::const_iterator ContentSettingsRegistry::end() const {
110 return const_iterator(content_settings_info_.end()); 111 return const_iterator(content_settings_info_.end());
111 } 112 }
112 113
113 void ContentSettingsRegistry::Init() { 114 void ContentSettingsRegistry::Init() {
114 // TODO(raymes): This registration code should not have to be in a single 115 // TODO(raymes): This registration code should not have to be in a single
115 // location. It should be possible to register a setting from the code 116 // location. It should be possible to register a setting from the code
116 // associated with it. 117 // associated with it.
117 118
118 // WARNING: The string names of the permissions passed in below are used to 119 // WARNING: The string names of the permissions passed in below are used to
119 // generate preference names and should never be changed! 120 // generate preference names and should never be changed!
120 121
121 Register(CONTENT_SETTINGS_TYPE_COOKIES, "cookies", CONTENT_SETTING_ALLOW, 122 Register(CONTENT_SETTINGS_TYPE_COOKIES, "cookies", CONTENT_SETTING_ALLOW,
122 WebsiteSettingsInfo::SYNCABLE, 123 WebsiteSettingsInfo::SYNCABLE,
123 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme), 124 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme),
124 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, 125 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK,
125 CONTENT_SETTING_SESSION_ONLY), 126 CONTENT_SETTING_SESSION_ONLY),
126 WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE, 127 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
127 WebsiteSettingsRegistry::ALL_PLATFORMS, 128 WebsiteSettingsRegistry::ALL_PLATFORMS,
128 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 129 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
129 130
130 Register(CONTENT_SETTINGS_TYPE_IMAGES, "images", CONTENT_SETTING_ALLOW, 131 Register(CONTENT_SETTINGS_TYPE_IMAGES, "images", CONTENT_SETTING_ALLOW,
131 WebsiteSettingsInfo::SYNCABLE, 132 WebsiteSettingsInfo::SYNCABLE,
132 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme, 133 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme,
133 kExtensionScheme), 134 kExtensionScheme),
134 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), 135 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK),
135 WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, 136 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
136 WebsiteSettingsRegistry::DESKTOP, 137 WebsiteSettingsRegistry::DESKTOP,
137 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 138 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
138 139
139 Register(CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript", 140 Register(CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript",
140 CONTENT_SETTING_ALLOW, WebsiteSettingsInfo::SYNCABLE, 141 CONTENT_SETTING_ALLOW, WebsiteSettingsInfo::SYNCABLE,
141 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme, 142 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme,
142 kExtensionScheme), 143 kExtensionScheme),
143 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), 144 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK),
144 WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, 145 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
145 WebsiteSettingsRegistry::DESKTOP | 146 WebsiteSettingsRegistry::DESKTOP |
146 WebsiteSettingsRegistry::PLATFORM_ANDROID, 147 WebsiteSettingsRegistry::PLATFORM_ANDROID,
147 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 148 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
148 149
149 Register(CONTENT_SETTINGS_TYPE_PLUGINS, "plugins", 150 Register(CONTENT_SETTINGS_TYPE_PLUGINS, "plugins",
150 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, 151 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT,
151 WebsiteSettingsInfo::SYNCABLE, 152 WebsiteSettingsInfo::SYNCABLE,
152 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme), 153 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme),
153 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, 154 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK,
154 CONTENT_SETTING_ASK, 155 CONTENT_SETTING_ASK,
155 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT), 156 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT),
156 WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, 157 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
157 WebsiteSettingsRegistry::DESKTOP, 158 WebsiteSettingsRegistry::DESKTOP,
158 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 159 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
159 160
160 Register(CONTENT_SETTINGS_TYPE_POPUPS, "popups", CONTENT_SETTING_BLOCK, 161 Register(CONTENT_SETTINGS_TYPE_POPUPS, "popups", CONTENT_SETTING_BLOCK,
161 WebsiteSettingsInfo::SYNCABLE, 162 WebsiteSettingsInfo::SYNCABLE,
162 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme, 163 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme,
163 kExtensionScheme), 164 kExtensionScheme),
164 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), 165 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK),
165 WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, 166 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
raymes 2016/06/16 03:23:50 Shouldn't these be TOP_LEVEL_ORIGIN_ONLY?
lshang 2016/06/20 01:34:22 Done.
166 WebsiteSettingsRegistry::ALL_PLATFORMS, 167 WebsiteSettingsRegistry::ALL_PLATFORMS,
167 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 168 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
168 169
169 Register(CONTENT_SETTINGS_TYPE_GEOLOCATION, "geolocation", 170 Register(CONTENT_SETTINGS_TYPE_GEOLOCATION, "geolocation",
170 CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE, 171 CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE,
171 WhitelistedSchemes(), 172 WhitelistedSchemes(),
172 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, 173 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK,
173 CONTENT_SETTING_ASK), 174 CONTENT_SETTING_ASK),
174 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, 175 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE,
175 WebsiteSettingsRegistry::DESKTOP | 176 WebsiteSettingsRegistry::DESKTOP |
(...skipping 19 matching lines...) Expand all
195 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, 196 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE,
196 WebsiteSettingsRegistry::DESKTOP | 197 WebsiteSettingsRegistry::DESKTOP |
197 WebsiteSettingsRegistry::PLATFORM_ANDROID, 198 WebsiteSettingsRegistry::PLATFORM_ANDROID,
198 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 199 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
199 200
200 Register(CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock", CONTENT_SETTING_ASK, 201 Register(CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock", CONTENT_SETTING_ASK,
201 WebsiteSettingsInfo::SYNCABLE, 202 WebsiteSettingsInfo::SYNCABLE,
202 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme), 203 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme),
203 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, 204 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK,
204 CONTENT_SETTING_ASK), 205 CONTENT_SETTING_ASK),
205 WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, 206 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
raymes 2016/06/16 03:23:50 and this one?
lshang 2016/06/20 01:34:22 Done.
206 WebsiteSettingsRegistry::DESKTOP, 207 WebsiteSettingsRegistry::DESKTOP,
207 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 208 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
208 209
209 Register(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic", 210 Register(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic",
210 CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE, 211 CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE,
211 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme), 212 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme),
212 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, 213 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK,
213 CONTENT_SETTING_ASK), 214 CONTENT_SETTING_ASK),
214 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, 215 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
215 WebsiteSettingsRegistry::DESKTOP | 216 WebsiteSettingsRegistry::DESKTOP |
(...skipping 18 matching lines...) Expand all
234 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, 235 WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE,
235 WebsiteSettingsRegistry::DESKTOP, 236 WebsiteSettingsRegistry::DESKTOP,
236 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 237 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
237 238
238 Register(CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "automatic-downloads", 239 Register(CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "automatic-downloads",
239 CONTENT_SETTING_ASK, WebsiteSettingsInfo::SYNCABLE, 240 CONTENT_SETTING_ASK, WebsiteSettingsInfo::SYNCABLE,
240 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme, 241 WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme,
241 kExtensionScheme), 242 kExtensionScheme),
242 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, 243 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK,
243 CONTENT_SETTING_ASK), 244 CONTENT_SETTING_ASK),
244 WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, 245 WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE,
245 WebsiteSettingsRegistry::DESKTOP | 246 WebsiteSettingsRegistry::DESKTOP |
246 WebsiteSettingsRegistry::PLATFORM_ANDROID, 247 WebsiteSettingsRegistry::PLATFORM_ANDROID,
247 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 248 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
248 249
249 Register(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex", CONTENT_SETTING_ASK, 250 Register(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex", CONTENT_SETTING_ASK,
250 WebsiteSettingsInfo::SYNCABLE, WhitelistedSchemes(), 251 WebsiteSettingsInfo::SYNCABLE, WhitelistedSchemes(),
251 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, 252 ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK,
252 CONTENT_SETTING_ASK), 253 CONTENT_SETTING_ASK),
253 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, 254 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE,
254 WebsiteSettingsRegistry::DESKTOP | 255 WebsiteSettingsRegistry::DESKTOP |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 WebsiteSettingsRegistry::PLATFORM_ANDROID, 310 WebsiteSettingsRegistry::PLATFORM_ANDROID,
310 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 311 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
311 312
312 // Content settings that aren't used to store any data. TODO(raymes): use a 313 // Content settings that aren't used to store any data. TODO(raymes): use a
313 // different mechanism rather than content settings to represent these. 314 // different mechanism rather than content settings to represent these.
314 // Since nothing is stored in them, there is no real point in them being a 315 // Since nothing is stored in them, there is no real point in them being a
315 // content setting. 316 // content setting.
316 Register(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "protocol-handler", 317 Register(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "protocol-handler",
317 CONTENT_SETTING_DEFAULT, WebsiteSettingsInfo::UNSYNCABLE, 318 CONTENT_SETTING_DEFAULT, WebsiteSettingsInfo::UNSYNCABLE,
318 WhitelistedSchemes(), ValidSettings(), 319 WhitelistedSchemes(), ValidSettings(),
319 WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, 320 WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE,
320 WebsiteSettingsRegistry::DESKTOP, 321 WebsiteSettingsRegistry::DESKTOP,
321 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 322 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
322 323
323 Register(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, "mixed-script", 324 Register(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, "mixed-script",
324 CONTENT_SETTING_DEFAULT, WebsiteSettingsInfo::UNSYNCABLE, 325 CONTENT_SETTING_DEFAULT, WebsiteSettingsInfo::UNSYNCABLE,
325 WhitelistedSchemes(), ValidSettings(), 326 WhitelistedSchemes(), ValidSettings(),
326 WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, 327 WebsiteSettingsInfo::TOP_LEVEL_ORIGIN_ONLY_SCOPE,
327 WebsiteSettingsRegistry::DESKTOP, 328 WebsiteSettingsRegistry::DESKTOP,
328 ContentSettingsInfo::INHERIT_IN_INCOGNITO); 329 ContentSettingsInfo::INHERIT_IN_INCOGNITO);
329 330
330 Register(CONTENT_SETTINGS_TYPE_BLUETOOTH_GUARD, "bluetooth-guard", 331 Register(CONTENT_SETTINGS_TYPE_BLUETOOTH_GUARD, "bluetooth-guard",
331 CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE, 332 CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE,
332 WhitelistedSchemes(), 333 WhitelistedSchemes(),
333 ValidSettings(CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK), 334 ValidSettings(CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK),
334 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, 335 WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE,
335 WebsiteSettingsRegistry::DESKTOP | 336 WebsiteSettingsRegistry::DESKTOP |
336 WebsiteSettingsRegistry::PLATFORM_ANDROID, 337 WebsiteSettingsRegistry::PLATFORM_ANDROID,
(...skipping 30 matching lines...) Expand all
367 if (!website_settings_info) 368 if (!website_settings_info)
368 return; 369 return;
369 370
370 DCHECK(!ContainsKey(content_settings_info_, type)); 371 DCHECK(!ContainsKey(content_settings_info_, type));
371 content_settings_info_[type] = base::WrapUnique( 372 content_settings_info_[type] = base::WrapUnique(
372 new ContentSettingsInfo(website_settings_info, whitelisted_schemes, 373 new ContentSettingsInfo(website_settings_info, whitelisted_schemes,
373 valid_settings, incognito_behavior)); 374 valid_settings, incognito_behavior));
374 } 375 }
375 376
376 } // namespace content_settings 377 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698