Commit 12af1f69 authored by finnur's avatar finnur Committed by Commit bot

Site Settings Desktop: Implement Cookie Search.

BUG=634039, 614277
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2338283002
Cr-Commit-Position: refs/heads/master@{#419142}
parent 9d1e5045
......@@ -1737,6 +1737,12 @@
<message name="IDS_SETTINGS_SITE_SETTINGS_COOKIE_REMOVE_ALL" desc="Label for the button to delete all cookies for a site.">
Remove All
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_COOKIE_REMOVE_ALL_SHOWN" desc="Label for the button to delete all visible cookies for a site.">
Remove All Shown
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_COOKIE_SEARCH" desc="A placeholder label shown inside the Cookie Data filter textbox as a hint that the user can enter a substring to search for.">
Search cookies
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_THIRD_PARTY_COOKIE" desc="Label for the Block 3rd-party cookie checkbox on the Cookies category.">
Block third-party cookies.
</message>
......
......@@ -2,6 +2,7 @@
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="/icons.html">
<link rel="import" href="/settings_page/settings_subpage_search.html">
<link rel="import" href="/settings_shared_css.html">
<link rel="import" href="/site_settings/site_data_details_dialog.html">
<link rel="import" href="/site_settings/site_settings_behavior.html">
......@@ -28,18 +29,25 @@
.site {
margin-top: 7px;
}
#filter {
margin-top: -4px;
}
</style>
<div class="layout horizontal">
<div class="flex site-header">$i18n{siteSettingsCookieHeader}</div>
<div class="secondary-action" hidden$="[[!removeAllIsVisible_(sites)]]">
<paper-button on-tap="onDeleteAllSites_" class="secondary-button">
$i18n{siteSettingsCookieRemoveAll}
<paper-button on-tap="onDeleteMultipleSites_" class="secondary-button">
[[computeRemoveLabel_(filterString_)]]
</paper-button>
</div>
<settings-subpage-search id="filter" on-search-changed="onSearchChanged_"
label="$i18n{siteSettingsCookieSearch}">
</settings-subpage-search>
</div>
<div class="list-frame vertical-list">
<template is="dom-repeat" items="[[sites]]">
<template is="dom-repeat" id="list" items="[[sites]]" filter="showItem_">
<div class="list-item layout horizontal">
<div class="layout horizontal flex" on-tap="onSiteTap_" actionable>
<div class="favicon-image site"
......@@ -48,10 +56,8 @@
<div class="flex middle">[[item.site]]</div>
<div class="site">[[item.localData]]</div>
</div>
<div>
<paper-icon-button on-tap="onDeleteSite_"
icon="settings:delete"></paper-icon-button>
</div>
<paper-icon-button on-tap="onDeleteSite_"
icon="settings:delete"></paper-icon-button>
</div>
</template>
</div>
......
......@@ -30,6 +30,14 @@ Polymer({
* Keeps track of how many outstanding requests for more data there are.
*/
requests_: Number,
/**
* The current filter applied to the cookie data list.
*/
filterString_: {
type: String,
value: '',
}
},
ready: function() {
......@@ -50,9 +58,27 @@ Polymer({
}.bind(this));
},
/**
* A filter function for the list.
* @param {!CookieDataSummaryItem} item The item to possibly filter out.
* @return {!boolean} Whether to show the item.
* @private
*/
showItem_: function(item) {
if (this.filterString_.length == 0)
return true;
return item.site.indexOf(this.filterString_) > -1;
},
/** @private */
onSearchChanged_: function(e) {
this.filterString_ = e.detail;
this.$.list.render();
},
/**
* Returns whether remove all should be shown.
* @param {Array<CookieDataSummaryItem>} sites The sites list to use to
* @param {!Array<!CookieDataSummaryItem>} sites The sites list to use to
* determine whether the button should be visible.
* @private
*/
......@@ -60,6 +86,17 @@ Polymer({
return sites.length > 0;
},
/**
* Returns the string to use for the Remove label.
* @return {!string} filterString The current filter string.
* @private
*/
computeRemoveLabel_: function(filterString) {
if (filterString.length == 0)
return loadTimeData.getString('siteSettingsCookieRemoveAll');
return loadTimeData.getString('siteSettingsCookieRemoveAllShown');
},
/**
* Called when the cookie list is ready to be shown.
* @param {!CookieList} list The cookie list to show.
......@@ -118,13 +155,21 @@ Polymer({
},
/**
* Deletes site data for all sites.
* Deletes site data for multiple sites.
* @private
*/
onDeleteAllSites_: function() {
this.browserProxy.removeAllCookies().then(function(list) {
this.loadChildren_(list);
}.bind(this));
onDeleteMultipleSites_: function() {
if (this.filterString_.length == 0) {
this.browserProxy.removeAllCookies().then(function(list) {
this.loadChildren_(list);
}.bind(this));
} else {
var items = this.$.list.items;
for (var i = 0; i < items.length; ++i) {
if (this.showItem_(items[i]))
this.browserProxy.removeCookie(items[i].id);
}
}
},
/**
......
......@@ -1374,6 +1374,9 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source) {
{"siteSettingsCookieRemove", IDS_SETTINGS_SITE_SETTINGS_COOKIE_REMOVE},
{"siteSettingsCookieRemoveAll",
IDS_SETTINGS_SITE_SETTINGS_COOKIE_REMOVE_ALL},
{"siteSettingsCookieRemoveAllShown",
IDS_SETTINGS_SITE_SETTINGS_COOKIE_REMOVE_ALL_SHOWN},
{"siteSettingsCookieSearch", IDS_SETTINGS_SITE_SETTINGS_COOKIE_SEARCH},
{"thirdPartyCookie", IDS_SETTINGS_SITE_SETTINGS_THIRD_PARTY_COOKIE},
{"thirdPartyCookieSublabel",
IDS_SETTINGS_SITE_SETTINGS_THIRD_PARTY_COOKIE_SUBLABEL},
......
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