Commit 946b66d6 authored by dhnishi's avatar dhnishi Committed by Commit bot

Add many more content settings to be set in the Website Settings options

page.

BUG=372607

Review URL: https://codereview.chromium.org/547433002

Cr-Commit-Position: refs/heads/master@{#293728}
parent da8d2304
...@@ -7941,6 +7941,15 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -7941,6 +7941,15 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_WEBSITE_SETTINGS_COOKIES_DESCRIPTION" desc="Label for granting cookies permission on the Website Settings single site view dialog."> <message name="IDS_WEBSITE_SETTINGS_COOKIES_DESCRIPTION" desc="Label for granting cookies permission on the Website Settings single site view dialog.">
Stores data Stores data
</message> </message>
<message name="IDS_WEBSITE_SETTINGS_DOWNLOAD_DESCRIPTION" desc="Label for granting multiple automatic downloads permission on the Website Settings single site view dialog.">
Automatic downloads
</message>
<message name="IDS_WEBSITE_SETTINGS_JAVASCRIPT_DESCRIPTION" desc="Label for granting scripts permission on the Website Settings single site view dialog.">
Runs scripts
</message>
<message name="IDS_WEBSITE_SETTINGS_IMAGES_DESCRIPTION" desc="Label for granting images permission on the Website Settings single site view dialog.">
Displays images
</message>
<message name="IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION" desc="Label for granting geolocation permission on the Website Settings single site view dialog."> <message name="IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION" desc="Label for granting geolocation permission on the Website Settings single site view dialog.">
Knows device location Knows device location
</message> </message>
...@@ -7953,6 +7962,12 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -7953,6 +7962,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION" desc="Label for granting notifications permission on the Website Settings single site view dialog."> <message name="IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION" desc="Label for granting notifications permission on the Website Settings single site view dialog.">
Shows notifications Shows notifications
</message> </message>
<message name="IDS_WEBSITE_SETTINGS_PLUGINS_DESCRIPTION" desc="Label for granting plugins permission on the Website Settings single site view dialog.">
Uses plugins
</message>
<message name="IDS_WEBSITE_SETTINGS_POPUPS_DESCRIPTION" desc="Label for granting popup permission on the Website Settings single site view dialog.">
Displays popups
</message>
<message name="IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS" desc="Placeholder text shown in the search box in the Website Settings dialog."> <message name="IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS" desc="Placeholder text shown in the search box in the Website Settings dialog.">
Search sites Search sites
</message> </message>
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
.origin-permission-list { .origin-permission-list {
-webkit-padding-before: 4px; -webkit-padding-before: 4px;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
height: 192px;
} }
#website-settings-edit-page .website-property-button { #website-settings-edit-page .website-property-button {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<div class="website-column-headers"> <div class="website-column-headers">
<div class="website-header-controls"> <div class="website-header-controls">
<select id="resourceType" class="resource-type-select"> <select id="resourceType" class="resource-type-select">
<option value="geolocation" i18n-content="websitesLabelGeolocation"> <option value="geolocation" i18n-content="websitesLabelLocation">
</option> </option>
<option value="media-stream" i18n-content="websitesLabelMediaStream"> <option value="media-stream" i18n-content="websitesLabelMediaStream">
</option> </option>
......
...@@ -17,7 +17,19 @@ cr.define('options.WebsiteSettings', function() { ...@@ -17,7 +17,19 @@ cr.define('options.WebsiteSettings', function() {
loadTimeData.getString('websitesOptionsPageTabTitle'), loadTimeData.getString('websitesOptionsPageTabTitle'),
'website-settings-edit-page'); 'website-settings-edit-page');
this.permissions = ['geolocation', 'notifications', 'media-stream', this.permissions = ['geolocation', 'notifications', 'media-stream',
'cookies']; 'cookies', 'multiple-automatic-downloads', 'images',
'plugins', 'popups', 'javascript'];
this.permissionsLookup = {
'geolocation': 'Location',
'notifications': 'Notifications',
'media-stream': 'MediaStream',
'cookies': 'Cookies',
'multiple-automatic-downloads': 'Downloads',
'images': 'Images',
'plugins': 'Plugins',
'popups': 'Popups',
'javascript': 'Javascript'
};
} }
cr.addSingletonGetter(WebsiteSettingsEditor); cr.addSingletonGetter(WebsiteSettingsEditor);
...@@ -45,6 +57,13 @@ cr.define('options.WebsiteSettings', function() { ...@@ -45,6 +57,13 @@ cr.define('options.WebsiteSettings', function() {
WebsiteSettingsEditor.getInstance().updatePermissions(); WebsiteSettingsEditor.getInstance().updatePermissions();
PageManager.closeOverlay.bind(PageManager)(); PageManager.closeOverlay.bind(PageManager)();
}; };
var permissionList =
this.pageDiv.querySelector('.origin-permission-list');
for (var key in this.permissions) {
permissionList.appendChild(
this.makePermissionOption_(this.permissions[key]));
}
}, },
/** /**
...@@ -103,6 +122,29 @@ cr.define('options.WebsiteSettings', function() { ...@@ -103,6 +122,29 @@ cr.define('options.WebsiteSettings', function() {
} }
} }
}, },
/**
* Populates the origin permission list with the different usable
* permissions.
* @param {string} permissionName A string with the permission name.
* @return {Element} The element with the usable permission setting.
*/
makePermissionOption_: function(permissionName) {
var permissionOption = cr.doc.createElement('div');
permissionOption.className = 'permission-option';
var permissionNameSpan = cr.doc.createElement('span');
permissionNameSpan.className = 'permission-name';
permissionNameSpan.textContent = loadTimeData.getString('websites' +
this.permissionsLookup[permissionName] + 'Description');
permissionOption.appendChild(permissionNameSpan);
var permissionSelector = cr.doc.createElement('select');
permissionSelector.setAttribute('id', permissionName + '-select-option');
permissionSelector.className = 'weaktrl permission-selection-option';
permissionOption.appendChild(permissionSelector);
return permissionOption;
},
}; };
WebsiteSettingsEditor.populateOrigin = function(localStorage, batteryUsage, WebsiteSettingsEditor.populateOrigin = function(localStorage, batteryUsage,
......
...@@ -26,32 +26,7 @@ ...@@ -26,32 +26,7 @@
<div id="website-settings-permission-column">Permissions</div> <div id="website-settings-permission-column">Permissions</div>
</div> </div>
</div> </div>
<list class="origin-permission-list"> <list class="origin-permission-list"></list>
<div class="permission-option">
<span class="permission-name"
i18n-content="websitesNotificationsDescription"></span>
<select id="notifications-select-option"
class="weaktrl permission-selection-option"></select>
</div>
<div class="permission-option">
<span class="permission-name"
i18n-content="websitesLocationDescription"></span>
<select id="geolocation-select-option"
class="weaktrl permission-selection-option"></select>
</div>
<div class="permission-option">
<span class="permission-name"
i18n-content="websitesMediastreamDescription"></span>
<select id="media-stream-select-option"
class="weaktrl permission-selection-option"></select>
</div>
<div class="permission-option">
<span class="permission-name"
i18n-content="websitesCookiesDescription"></span>
<select id="cookies-select-option"
class="weaktrl permission-selection-option"></select>
</div>
</list>
</div> </div>
<div class="action-area"> <div class="action-area">
<div class="button-strip"> <div class="button-strip">
......
...@@ -38,10 +38,15 @@ const int kHttpsPort = 443; ...@@ -38,10 +38,15 @@ const int kHttpsPort = 443;
const char kPreferencesSource[] = "preference"; const char kPreferencesSource[] = "preference";
const char kStorage[] = "storage"; const char kStorage[] = "storage";
const ContentSettingsType kValidTypes[] = { const ContentSettingsType kValidTypes[] = {
CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
CONTENT_SETTINGS_TYPE_COOKIES,
CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTINGS_TYPE_GEOLOCATION,
CONTENT_SETTINGS_TYPE_IMAGES,
CONTENT_SETTINGS_TYPE_JAVASCRIPT,
CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
CONTENT_SETTINGS_TYPE_MEDIASTREAM, CONTENT_SETTINGS_TYPE_MEDIASTREAM,
CONTENT_SETTINGS_TYPE_COOKIES}; CONTENT_SETTINGS_TYPE_PLUGINS,
CONTENT_SETTINGS_TYPE_POPUPS};
const size_t kValidTypesLength = arraysize(kValidTypes); const size_t kValidTypesLength = arraysize(kValidTypes);
} // namespace } // namespace
...@@ -65,7 +70,7 @@ void WebsiteSettingsHandler::GetLocalizedValues( ...@@ -65,7 +70,7 @@ void WebsiteSettingsHandler::GetLocalizedValues(
{"websitesSettingsEditPage", IDS_WEBSITE_SETTINGS_EDIT_TITLE}, {"websitesSettingsEditPage", IDS_WEBSITE_SETTINGS_EDIT_TITLE},
{"websitesManage", IDS_WEBSITE_SETTINGS_MANAGE}, {"websitesManage", IDS_WEBSITE_SETTINGS_MANAGE},
{"websitesSearch", IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS}, {"websitesSearch", IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS},
{"websitesLabelGeolocation", IDS_WEBSITE_SETTINGS_TYPE_LOCATION}, {"websitesLabelLocation", IDS_WEBSITE_SETTINGS_TYPE_LOCATION},
{"websitesLabelMediaStream", IDS_WEBSITE_SETTINGS_TYPE_MEDIASTREAM}, {"websitesLabelMediaStream", IDS_WEBSITE_SETTINGS_TYPE_MEDIASTREAM},
{"websitesLabelNotifications", IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS}, {"websitesLabelNotifications", IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS},
{"websitesLabelStorage", IDS_WEBSITE_SETTINGS_TYPE_STORAGE}, {"websitesLabelStorage", IDS_WEBSITE_SETTINGS_TYPE_STORAGE},
...@@ -73,10 +78,17 @@ void WebsiteSettingsHandler::GetLocalizedValues( ...@@ -73,10 +78,17 @@ void WebsiteSettingsHandler::GetLocalizedValues(
{"websitesCookiesDescription", IDS_WEBSITE_SETTINGS_COOKIES_DESCRIPTION}, {"websitesCookiesDescription", IDS_WEBSITE_SETTINGS_COOKIES_DESCRIPTION},
{"websitesLocationDescription", {"websitesLocationDescription",
IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION}, IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION},
{"websitesMediastreamDescription", {"websitesMediaStreamDescription",
IDS_WEBSITE_SETTINGS_MEDIASTREAM_DESCRIPTION}, IDS_WEBSITE_SETTINGS_MEDIASTREAM_DESCRIPTION},
{"websitesNotificationsDescription", {"websitesNotificationsDescription",
IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION}, IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION},
{"websitesDownloadsDescription",
IDS_WEBSITE_SETTINGS_DOWNLOAD_DESCRIPTION},
{"websitesPluginsDescription", IDS_WEBSITE_SETTINGS_PLUGINS_DESCRIPTION},
{"websitesPopupsDescription", IDS_WEBSITE_SETTINGS_POPUPS_DESCRIPTION},
{"websitesJavascriptDescription",
IDS_WEBSITE_SETTINGS_JAVASCRIPT_DESCRIPTION},
{"websitesImagesDescription", IDS_WEBSITE_SETTINGS_IMAGES_DESCRIPTION},
{"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON}, {"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON},
{"websitesButtonStop", IDS_WEBSITE_SETTINGS_BATTERY_STOP_BUTTON}, {"websitesButtonStop", IDS_WEBSITE_SETTINGS_BATTERY_STOP_BUTTON},
}; };
...@@ -347,18 +359,10 @@ void WebsiteSettingsHandler::HandleSetOriginPermission( ...@@ -347,18 +359,10 @@ void WebsiteSettingsHandler::HandleSetOriginPermission(
ContentSettingsPattern primary_pattern; ContentSettingsPattern primary_pattern;
ContentSettingsPattern secondary_pattern; ContentSettingsPattern secondary_pattern;
switch (settings_type) { switch (settings_type) {
case CONTENT_SETTINGS_TYPE_COOKIES:
primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
break;
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
secondary_pattern = ContentSettingsPattern::Wildcard(); secondary_pattern = ContentSettingsPattern::Wildcard();
break; break;
case CONTENT_SETTINGS_TYPE_GEOLOCATION:
primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
break;
case CONTENT_SETTINGS_TYPE_MEDIASTREAM: case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
secondary_pattern = ContentSettingsPattern::Wildcard(); secondary_pattern = ContentSettingsPattern::Wildcard();
...@@ -373,9 +377,19 @@ void WebsiteSettingsHandler::HandleSetOriginPermission( ...@@ -373,9 +377,19 @@ void WebsiteSettingsHandler::HandleSetOriginPermission(
std::string(), std::string(),
setting); setting);
return; return;
case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS:
case CONTENT_SETTINGS_TYPE_COOKIES:
case CONTENT_SETTINGS_TYPE_GEOLOCATION:
case CONTENT_SETTINGS_TYPE_IMAGES:
case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
case CONTENT_SETTINGS_TYPE_PLUGINS:
case CONTENT_SETTINGS_TYPE_POPUPS:
primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
break;
default: default:
NOTREACHED() << "Content settings type not yet supported."; NOTREACHED() << "Content settings type not yet supported.";
break; return;
} }
content_settings::SettingInfo info; content_settings::SettingInfo info;
......
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