Commit 9b4b6268 authored by mgiuca's avatar mgiuca Committed by Commit bot

Deprecate chrome.contentSettings.{fullscreen,mouselock} extension API.

These settings no longer hook up to actual data; they just return
'allow' always, and setting them has no effect. Updated documentation.

This is because Chrome now (and has for awhile) ignores these settings
and always permits these actions without asking the user.

BUG=591896

Review-Url: https://codereview.chromium.org/2358893004
Cr-Commit-Position: refs/heads/master@{#422716}
parent efb69e92
......@@ -106,16 +106,6 @@ class ExtensionContentSettingsApiTest : public ExtensionApiTest {
example_url,
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
std::string()));
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(example_url,
example_url,
CONTENT_SETTINGS_TYPE_FULLSCREEN,
std::string()));
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(example_url,
example_url,
CONTENT_SETTINGS_TYPE_MOUSELOCK,
std::string()));
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(example_url,
example_url,
......@@ -164,12 +154,6 @@ class ExtensionContentSettingsApiTest : public ExtensionApiTest {
CONTENT_SETTING_BLOCK,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string()));
......@@ -218,12 +202,6 @@ class ExtensionContentSettingsApiTest : public ExtensionApiTest {
CONTENT_SETTING_ASK,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()));
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()));
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(
url, url, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string()));
......
......@@ -211,12 +211,12 @@
{
"id": "FullscreenContentSetting",
"type": "string",
"enum": ["allow", "ask"]
"enum": ["allow"]
},
{
"id": "MouselockContentSetting",
"type": "string",
"enum": ["allow", "block", "ask"]
"enum": ["allow"]
},
{
"id": "MicrophoneContentSetting",
......@@ -298,7 +298,7 @@
},
"fullscreen": {
"$ref": "ContentSetting",
"description": "Whether to allow sites to toggle the fullscreen mode. One of<br><var>allow</var>: Allow sites to toggle the fullscreen mode,<br><var>ask</var>: Ask when a site wants to toggle the fullscreen mode. <br>Default is <var>ask</var>.<br>The primary URL is the URL of the document which requested to toggle the fullscreen mode. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL).",
"description": "<i>Deprecated.</i> No longer has any effect. Fullscreen permission is now automatically granted for all sites. Value is always <var>allow</var>.",
"value": [
"fullscreen",
{"$ref":"FullscreenContentSetting"}
......@@ -306,7 +306,7 @@
},
"mouselock": {
"$ref": "ContentSetting",
"description": "Whether to allow sites to disable the mouse cursor. One of <br><var>allow</var>: Allow sites to disable the mouse cursor,<br><var>block</var>: Don't allow sites to disable the mouse cursor,<br><var>ask</var>: Ask when a site wants to disable the mouse cursor. <br>Default is <var>ask</var>.<br>The primary URL is the URL of the top-level frame. The secondary URL is not used.",
"description": "<i>Deprecated.</i> No longer has any effect. Mouse lock permission is now automatically granted for all sites. Value is always <var>allow</var>.",
"value": [
"mouselock",
{"$ref":"MouselockContentSetting"}
......
......@@ -7,6 +7,16 @@
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 = {
__proto__: null,
fullscreen: 'allow',
mouselock: 'allow',
};
function extendSchema(schema) {
var extendedSchema = $Array.slice(schema);
$Array.unshift(extendedSchema, {'type': 'string'});
......@@ -22,10 +32,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 +62,44 @@ function ContentSetting(contentType, settingSchema, schema) {
var modSetSchema = $Array.slice(rawSetSchema);
modSetSchema[0] = modSettingParam;
validate([details, callback], rawSetSchema);
if ($Object.hasOwnProperty(DEPRECATED_CONTENT_TYPES, contentType)) {
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 ($Object.hasOwnProperty(DEPRECATED_CONTENT_TYPES, 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 ($Object.hasOwnProperty(DEPRECATED_CONTENT_TYPES, contentType)) {
$Function.apply(callback, undefined, []);
return;
}
return sendRequest(
'contentSettings.getResourceIdentifiers',
[contentType, callback],
......
......@@ -30,14 +30,24 @@ var settings = {
"popups": "allow",
"location": "block",
"notifications": "block",
"fullscreen": "allow",
"mouselock": "block",
"fullscreen": "block", // Should be ignored.
"mouselock": "block", // Should be ignored.
"microphone": "block",
"camera": "block",
"unsandboxedPlugins": "block",
"automaticDownloads": "block"
};
// List of settings that are expected to return different values than were
// written, due to deprecation. For example, "fullscreen" is set to "block" but
// we expect this to be ignored, and so read back as "allow". Any setting
// omitted from this list is expected to read back whatever was written.
var deprecatedSettingsExpectations = {
// Due to deprecation, these should be "allow", regardless of the setting.
"fullscreen": "allow",
"mouselock": "allow"
};
Object.prototype.forEach = function(f) {
var k;
for (k in this) {
......@@ -80,6 +90,7 @@ chrome.test.runTests([
},
function getContentSettings() {
settings.forEach(function(type, setting) {
setting = deprecatedSettingsExpectations[type] || setting;
var message = "Setting for " + type + " should be " + setting;
cs[type].get({
'primaryUrl': 'http://www.google.com',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment