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

Side by Side Diff: chrome/browser/extensions/api/content_settings/content_settings_api.cc

Issue 2853983002: Ensure settings returned from Content Settings providers are valid (Closed)
Patch Set: Ensure settings returned from Content Settings providers are valid Created 3 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/content_settings/content_settings_api.h" 5 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 ->Get(content_type) 209 ->Get(content_type)
210 ->IsSettingValid(setting)); 210 ->IsSettingValid(setting));
211 211
212 // Some content setting types support the full set of values listed in 212 // Some content setting types support the full set of values listed in
213 // content_settings.json only for exceptions. For the default setting, 213 // content_settings.json only for exceptions. For the default setting,
214 // some values might not be supported. 214 // some values might not be supported.
215 // For example, camera supports [allow, ask, block] for exceptions, but only 215 // For example, camera supports [allow, ask, block] for exceptions, but only
216 // [ask, block] for the default setting. 216 // [ask, block] for the default setting.
217 if (primary_pattern == ContentSettingsPattern::Wildcard() && 217 if (primary_pattern == ContentSettingsPattern::Wildcard() &&
218 secondary_pattern == ContentSettingsPattern::Wildcard() && 218 secondary_pattern == ContentSettingsPattern::Wildcard() &&
219 !HostContentSettingsMap::IsDefaultSettingAllowedForType(setting, 219 !content_settings::ContentSettingsRegistry::GetInstance()
220 content_type)) { 220 ->Get(content_type)
221 ->IsDefaultSettingValid(setting)) {
221 static const char kUnsupportedDefaultSettingError[] = 222 static const char kUnsupportedDefaultSettingError[] =
222 "'%s' is not supported as the default setting of %s."; 223 "'%s' is not supported as the default setting of %s.";
223 224
224 // TODO(msramek): Get the same human readable name as is presented 225 // TODO(msramek): Get the same human readable name as is presented
225 // externally in the API, i.e. chrome.contentSettings.<name>.set(). 226 // externally in the API, i.e. chrome.contentSettings.<name>.set().
226 std::string readable_type_name; 227 std::string readable_type_name;
227 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { 228 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
228 readable_type_name = "microphone"; 229 readable_type_name = "microphone";
229 } else if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { 230 } else if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
230 readable_type_name = "camera"; 231 readable_type_name = "camera";
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 SetResult(std::move(list)); 309 SetResult(std::move(list));
309 BrowserThread::PostTask( 310 BrowserThread::PostTask(
310 BrowserThread::UI, FROM_HERE, 311 BrowserThread::UI, FROM_HERE,
311 base::BindOnce( 312 base::BindOnce(
312 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: 313 &ContentSettingsContentSettingGetResourceIdentifiersFunction::
313 SendResponse, 314 SendResponse,
314 this, true)); 315 this, true));
315 } 316 }
316 317
317 } // namespace extensions 318 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698