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

Unified Diff: chrome/browser/resources/options2/cookies_list.js

Issue 10709006: Show apps protecting local data in chrome://settings/cookies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: argh Created 8 years, 5 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
Index: chrome/browser/resources/options2/cookies_list.js
diff --git a/chrome/browser/resources/options2/cookies_list.js b/chrome/browser/resources/options2/cookies_list.js
index f7b6b97ee9bf7652fa3056ff739608a5439246b8..6ba971d8da869b96e2a1b326cae3e526ef0a68da 100644
--- a/chrome/browser/resources/options2/cookies_list.js
+++ b/chrome/browser/resources/options2/cookies_list.js
@@ -77,6 +77,22 @@ cr.define('options', function() {
return nodes;
}
+ /**
+ * Adds information about an app that protects this data item to the
+ * @{code element}.
+ * @param {Element} element The DOM element the information should be
+ appended to.
+ * @param {{id: string, name: string}} appInfo Information about an app.
+ */
+ function addAppInfo(element, appInfo) {
+ var img = element.ownerDocument.createElement('img');
+ img.src = 'chrome://extension-icon/' + appInfo.id + '/16/1';
+ img.title = loadTimeData.getString('label_protected_by_apps') +
+ ' ' + appInfo.name;
+ img.className = 'protecting-app';
+ element.appendChild(img);
+ }
+
var parentLookup = {};
var lookupRequests = {};
@@ -239,6 +255,7 @@ cr.define('options', function() {
};
if (this.origin)
this.origin.collectSummaryInfo(info);
+
var list = [];
if (info.cookies > 1)
list.push(loadTimeData.getStringF('cookie_plural', info.cookies));
@@ -254,17 +271,23 @@ cr.define('options', function() {
list.push(loadTimeData.getString('cookie_file_system'));
if (info.serverBoundCerts)
list.push(loadTimeData.getString('cookie_server_bound_cert'));
+
var text = '';
- for (var i = 0; i < list.length; ++i)
+ for (var i = 0; i < list.length; ++i) {
if (text.length > 0)
text += ', ' + list[i];
else
text = list[i];
+ }
this.dataChild.textContent = text;
- if (info.quota && info.quota.totalUsage) {
- this.sizeChild.textContent = info.quota.totalUsage;
+
+ for (var key in info.appsProtectingThis) {
+ addAppInfo(this.dataChild, apps[key]);
}
+ if (info.quota && info.quota.totalUsage)
+ this.sizeChild.textContent = info.quota.totalUsage;
+
if (this.expanded)
this.updateItems_();
},
@@ -462,6 +485,15 @@ cr.define('options', function() {
} else if (this.data.type == 'server_bound_cert') {
info.serverBoundCerts++;
}
+
+ var apps = this.data.appsProtectingThis;
+ if (apps) {
+ if (!info.appsProtectingThis)
+ info.appsProtectingThis = {};
+ apps.forEach(function(appInfo) {
+ info.appsProtectingThis[appInfo.id] = appInfo;
+ });
+ }
}
},
@@ -474,44 +506,38 @@ cr.define('options', function() {
if (this.children.length > 0) {
for (var i = 0; i < this.children.length; ++i)
this.children[i].createItems(item);
- } else if (this.data && !this.data.hasChildren) {
- var text = '';
- switch (this.data.type) {
- case 'cookie':
- case 'database':
- text = this.data.name;
- break;
- case 'local_storage':
- text = loadTimeData.getString('cookie_local_storage');
- break;
- case 'app_cache':
- text = loadTimeData.getString('cookie_app_cache');
- break;
- case 'indexed_db':
- text = loadTimeData.getString('cookie_indexed_db');
- break;
- case 'file_system':
- text = loadTimeData.getString('cookie_file_system');
- break;
- case 'server_bound_cert':
- text = loadTimeData.getString('cookie_server_bound_cert');
- break;
- }
- if (!text)
- return;
- var div = item.ownerDocument.createElement('div');
- div.className = 'cookie-item';
- // Help out screen readers and such: this is a clickable thing.
- div.setAttribute('role', 'button');
- div.textContent = text;
- var index = item.appendItem(this, div);
- div.onclick = function() {
- if (item.selectedIndex == index)
- item.selectedIndex = -1;
- else
- item.selectedIndex = index;
- };
+ return;
+ }
+
+ if (!this.data || this.data.hasChildren)
+ return;
+
+ var text = '';
+ switch (this.data.type) {
+ case 'cookie':
+ case 'database':
+ text = this.data.name;
+ break;
+ default:
+ text = loadTimeData.getString('cookie_' + this.data.type);
}
+ if (!text)
+ return;
+
+ var div = item.ownerDocument.createElement('div');
+ div.className = 'cookie-item';
+ // Help out screen readers and such: this is a clickable thing.
+ div.setAttribute('role', 'button');
+ div.tabIndex = 0;
+ div.textContent = text;
+ var apps = this.data.appsProtectingThis;
+ if (apps)
+ apps.forEach(addAppInfo.bind(null, div));
+
+ var index = item.appendItem(this, div);
+ div.onclick = function() {
+ item.selectedIndex = (item.selectedIndex == index) ? -1 : index;
+ };
},
/**
@@ -526,22 +552,22 @@ cr.define('options', function() {
*/
setDetailText: function(element, infoNodes) {
var table;
- if (this.data && !this.data.hasChildren) {
- if (cookieInfo[this.data.type]) {
- var info = cookieInfo[this.data.type];
- var nodes = infoNodes[this.data.type].info;
- for (var i = 0; i < info.length; ++i) {
- var name = info[i][0];
- if (name != 'id' && this.data[name])
- nodes[name].textContent = this.data[name];
- else
- nodes[name].textContent = '';
- }
- table = infoNodes[this.data.type].table;
+ if (this.data && !this.data.hasChildren && cookieInfo[this.data.type]) {
+ var info = cookieInfo[this.data.type];
+ var nodes = infoNodes[this.data.type].info;
+ for (var i = 0; i < info.length; ++i) {
+ var name = info[i][0];
+ if (name != 'id' && this.data[name])
+ nodes[name].textContent = this.data[name];
+ else
+ nodes[name].textContent = '';
}
+ table = infoNodes[this.data.type].table;
}
+
while (element.childNodes.length > 1)
element.removeChild(element.firstChild);
+
if (table)
element.insertBefore(table, element.firstChild);
},
@@ -559,6 +585,7 @@ cr.define('options', function() {
set parent(parent) {
if (parent == this.parent)
return;
+
if (parent instanceof CookieListItem) {
// If the parent is to be a CookieListItem, then we keep the reference
// to it by its containing list and list index, rather than directly.
@@ -572,12 +599,14 @@ cr.define('options', function() {
} else {
this.parent_ = parent;
}
+
if (this.data && this.data.id) {
if (parent)
parentLookup[this.data.id] = this;
else
delete parentLookup[this.data.id];
}
+
if (this.data && this.data.hasChildren &&
!this.children.length && !lookupRequests[this.data.id]) {
lookupRequests[this.data.id] = true;

Powered by Google App Engine
This is Rietveld 408576698