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

Unified Diff: chrome/renderer/resources/extensions/content_setting.js

Issue 2903803004: [Extensions Bindings] Fix content settings validation (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/content_settings/standard/test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/content_setting.js
diff --git a/chrome/renderer/resources/extensions/content_setting.js b/chrome/renderer/resources/extensions/content_setting.js
index 81f28b3f14571cdf5cb1e57273885c03ce885579..745008ce6d64e8e5bb2cd69db7598c4a32fedaf0 100644
--- a/chrome/renderer/resources/extensions/content_setting.js
+++ b/chrome/renderer/resources/extensions/content_setting.js
@@ -47,6 +47,15 @@ function ContentSetting(contentType, settingSchema, schema) {
};
this.set = function(details, callback) {
+ // We check if the setting is deprecated first, since the validation will
+ // fail for deprecated types.
+ if ($Object.hasOwnProperty(DEPRECATED_CONTENT_TYPES, contentType)) {
+ console.warn('contentSettings.' + contentType + ' is deprecated; setting '
+ + 'it has no effect.');
+ $Function.apply(callback, undefined, []);
+ return;
+ }
+
// The set schema included in the Schema object is generic, since it varies
// per-setting. However, this is only ever for a single setting, so we can
// enforce the types more thoroughly.
@@ -61,14 +70,7 @@ function ContentSetting(contentType, settingSchema, schema) {
};
var modSetSchema = $Array.slice(rawSetSchema);
modSetSchema[0] = modSettingParam;
- validate([details, callback], rawSetSchema);
Devlin 2017/05/26 01:36:01 This was validating only against the raw schema, w
-
- if ($Object.hasOwnProperty(DEPRECATED_CONTENT_TYPES, contentType)) {
- console.warn('contentSettings.' + contentType + ' is deprecated; setting '
- + 'it has no effect.');
- $Function.apply(callback, undefined, []);
- return;
- }
+ validate([details, callback], modSetSchema);
return sendRequest('contentSettings.set',
[contentType, details, callback],
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/content_settings/standard/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698