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 43fedd1e3288d38a011336e2fa3df603b9cdd7dc..a693e697f67b41ce1963ba944d3197180562164a 100644 |
--- a/chrome/renderer/resources/extensions/content_setting.js |
+++ b/chrome/renderer/resources/extensions/content_setting.js |
@@ -7,6 +7,14 @@ |
var sendRequest = require('sendRequest').sendRequest; |
var validate = require('schemaUtils').validate; |
+// Some content types have been removed and no longer correspond to a real |
+// content setting. Instead, these always return a fixed dummy value, and issue |
+// a warning when accessed. This maps the content type name to the dummy value. |
+var DEPRECATED_CONTENT_TYPES = { |
Devlin
2016/09/27 15:22:36
forgot - please add __proto__: null to this object
Matt Giuca
2016/09/29 03:13:45
Done.
|
+ fullscreen: 'allow', |
+ mouselock: 'allow', |
+}; |
+ |
function extendSchema(schema) { |
var extendedSchema = $Array.slice(schema); |
$Array.unshift(extendedSchema, {'type': 'string'}); |
@@ -22,10 +30,20 @@ function ContentSetting(contentType, settingSchema, schema) { |
this.get = function(details, callback) { |
var getSchema = getFunctionParameters('get'); |
validate([details, callback], getSchema); |
+ |
+ var dummySetting = DEPRECATED_CONTENT_TYPES[contentType]; |
+ if (dummySetting !== undefined) { |
+ console.warn('contentSettings.' + contentType + ' is deprecated; it will ' |
+ + 'always return \'' + dummySetting + '\'.'); |
+ $Function.apply(callback, undefined, [{setting: dummySetting}]); |
+ return; |
+ } |
+ |
return sendRequest('contentSettings.get', |
[contentType, details, callback], |
extendSchema(getSchema)); |
}; |
+ |
this.set = function(details, callback) { |
// 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 |
@@ -42,20 +60,44 @@ function ContentSetting(contentType, settingSchema, schema) { |
var modSetSchema = $Array.slice(rawSetSchema); |
modSetSchema[0] = modSettingParam; |
validate([details, callback], rawSetSchema); |
+ |
+ if (DEPRECATED_CONTENT_TYPES.hasOwnProperty(contentType)) { |
Devlin
2016/09/26 20:30:37
Use the safe-builtin version.
Matt Giuca
2016/09/27 01:18:33
Sorry, I don't know what you want.
Do you mean to
Devlin
2016/09/27 15:22:36
Safe Builtins are cached (safe) versions of variou
Matt Giuca
2016/09/29 03:13:45
Done. OK thanks for the explanation.
|
+ console.warn('contentSettings.' + contentType + ' is deprecated; setting ' |
+ + 'it has no effect.'); |
+ $Function.apply(callback, undefined, []); |
+ return; |
+ } |
+ |
return sendRequest('contentSettings.set', |
[contentType, details, callback], |
extendSchema(modSetSchema)); |
}; |
+ |
this.clear = function(details, callback) { |
var clearSchema = getFunctionParameters('clear'); |
validate([details, callback], clearSchema); |
+ |
+ if (DEPRECATED_CONTENT_TYPES.hasOwnProperty(contentType)) { |
+ console.warn('contentSettings.' + contentType + ' is deprecated; ' |
+ + 'clearing it has no effect.'); |
+ $Function.apply(callback, undefined, []); |
+ return; |
+ } |
+ |
return sendRequest('contentSettings.clear', |
[contentType, details, callback], |
extendSchema(clearSchema)); |
}; |
+ |
this.getResourceIdentifiers = function(callback) { |
var schema = getFunctionParameters('getResourceIdentifiers'); |
validate([callback], schema); |
+ |
+ if (DEPRECATED_CONTENT_TYPES.hasOwnProperty(contentType)) { |
+ $Function.apply(callback, undefined, []); |
+ return; |
+ } |
+ |
return sendRequest( |
'contentSettings.getResourceIdentifiers', |
[contentType, callback], |