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

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

Issue 2728503003: Update permission warning for contentSettings API
Patch Set: chrome.contentSettings API: Do not allow wildcard patterns that match extension URLs Created 3 years, 9 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 EXTENSION_FUNCTION_VALIDATE( 207 EXTENSION_FUNCTION_VALIDATE(
208 content_settings::ContentSettingsRegistry::GetInstance() 208 content_settings::ContentSettingsRegistry::GetInstance()
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 // Also, do not allow wildcard patterns that match chrome-extension URLs.
218 secondary_pattern == ContentSettingsPattern::Wildcard() && 218 if ((primary_pattern.MatchesExtensionUrls() &&
219 secondary_pattern.MatchesExtensionUrls()) ||
220 (primary_pattern == ContentSettingsPattern::Wildcard() &&
221 secondary_pattern == ContentSettingsPattern::Wildcard())) &&
219 !HostContentSettingsMap::IsDefaultSettingAllowedForType(setting, 222 !HostContentSettingsMap::IsDefaultSettingAllowedForType(setting,
220 content_type)) { 223 content_type)) {
221 static const char kUnsupportedDefaultSettingError[] = 224 static const char kUnsupportedDefaultSettingError[] =
222 "'%s' is not supported as the default setting of %s."; 225 "'%s' is not supported as the default setting of %s.";
223 226
224 // TODO(msramek): Get the same human readable name as is presented 227 // TODO(msramek): Get the same human readable name as is presented
225 // externally in the API, i.e. chrome.contentSettings.<name>.set(). 228 // externally in the API, i.e. chrome.contentSettings.<name>.set().
226 std::string readable_type_name; 229 std::string readable_type_name;
227 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { 230 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
228 readable_type_name = "microphone"; 231 readable_type_name = "microphone";
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 SetResult(std::move(list)); 311 SetResult(std::move(list));
309 BrowserThread::PostTask( 312 BrowserThread::PostTask(
310 BrowserThread::UI, FROM_HERE, base::Bind( 313 BrowserThread::UI, FROM_HERE, base::Bind(
311 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: 314 &ContentSettingsContentSettingGetResourceIdentifiersFunction::
312 SendResponse, 315 SendResponse,
313 this, 316 this,
314 true)); 317 true));
315 } 318 }
316 319
317 } // namespace extensions 320 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698