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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/CookieItemsView.js

Issue 2567873002: DevTools: Add ability to add and edit cookies (Closed)
Patch Set: Rebase. Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 this._textFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, this._ filterChanged, this); 50 this._textFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, this._ filterChanged, this);
51 this._filterBar.addFilter(this._textFilterUI); 51 this._filterBar.addFilter(this._textFilterUI);
52 52
53 this._filterSeparator = new UI.ToolbarSeparator(); 53 this._filterSeparator = new UI.ToolbarSeparator();
54 this._filterButton = this._filterBar.filterButton(); 54 this._filterButton = this._filterBar.filterButton();
55 55
56 this._target = target; 56 this._target = target;
57 this._treeElement = treeElement; 57 this._treeElement = treeElement;
58 this._cookieDomain = cookieDomain; 58 this._cookieDomain = cookieDomain;
59 59
60 this._emptyWidget = new UI.EmptyWidget(
61 cookieDomain ?
62 Common.UIString('This site has no cookies.') :
63 Common.UIString(
64 'By default cookies are disabled for local files.\nYou could ove rride this by starting the browser with --enable-file-cookies command line flag. '));
65 this._emptyWidget.show(this.element);
66
67 this.element.addEventListener('contextmenu', this._contextMenu.bind(this), t rue); 60 this.element.addEventListener('contextmenu', this._contextMenu.bind(this), t rue);
68 } 61 }
69 62
70 /** 63 /**
71 * @override 64 * @override
72 * @return {!Array.<!UI.ToolbarItem>} 65 * @return {!Array.<!UI.ToolbarItem>}
73 */ 66 */
74 syncToolbarItems() { 67 syncToolbarItems() {
75 return [this._refreshButton, this._clearButton, this._deleteButton, this._fi lterSeparator, this._filterButton]; 68 return [this._refreshButton, this._clearButton, this._deleteButton, this._fi lterSeparator, this._filterButton];
76 } 69 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 SDK.Cookies.getCookiesAsync(this._target, resourceURLs, this._updateWithCook ies.bind(this)); 107 SDK.Cookies.getCookiesAsync(this._target, resourceURLs, this._updateWithCook ies.bind(this));
115 } 108 }
116 109
117 /** 110 /**
118 * @param {!Array.<!SDK.Cookie>} allCookies 111 * @param {!Array.<!SDK.Cookie>} allCookies
119 */ 112 */
120 _updateWithCookies(allCookies) { 113 _updateWithCookies(allCookies) {
121 this._cookies = allCookies; 114 this._cookies = allCookies;
122 this._totalSize = allCookies.reduce((size, cookie) => size + cookie.size(), 0); 115 this._totalSize = allCookies.reduce((size, cookie) => size + cookie.size(), 0);
123 116
124 if (!this._cookies.length) {
125 // Nothing to show.
126 this._emptyWidget.show(this.element);
127 this._filterButton.setEnabled(false);
128 this._clearButton.setEnabled(false);
129 this._deleteButton.setEnabled(false);
130 if (this._cookiesTable)
131 this._cookiesTable.detach();
132 return;
133 }
134
135 if (!this._cookiesTable) { 117 if (!this._cookiesTable) {
118 const parsedURL = this._cookieDomain.asParsedURL();
119 const domain = parsedURL ? parsedURL.host : '';
136 this._cookiesTable = 120 this._cookiesTable =
137 new CookieTable.CookiesTable(false, this._update.bind(this), this._ena bleDeleteButton.bind(this)); 121 new CookieTable.CookiesTable(false, this._update.bind(this), this._ena bleDeleteButton.bind(this), domain);
138 } 122 }
139 123
140 var shownCookies = this._filterCookies(this._cookies); 124 var shownCookies = this._filterCookies(this._cookies);
141 this._cookiesTable.setCookies(shownCookies); 125 this._cookiesTable.setCookies(shownCookies);
142 this._emptyWidget.detach();
143 this._filterBar.show(this.element); 126 this._filterBar.show(this.element);
144 this._cookiesTable.show(this.element); 127 this._cookiesTable.show(this.element);
145 this._treeElement.subtitle = 128 this._treeElement.subtitle =
146 String.sprintf(Common.UIString('%d cookies (%s)'), this._cookies.length, Number.bytesToString(this._totalSize)); 129 String.sprintf(Common.UIString('%d cookies (%s)'), this._cookies.length, Number.bytesToString(this._totalSize));
147 this._filterButton.setEnabled(true); 130 this._filterButton.setEnabled(true);
148 this._clearButton.setEnabled(true); 131 this._clearButton.setEnabled(true);
149 this._deleteButton.setEnabled(!!this._cookiesTable.selectedCookie()); 132 this._deleteButton.setEnabled(!!this._cookiesTable.selectedCookie());
150 } 133 }
151 134
152 /** 135 /**
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 180 }
198 181
199 _contextMenu(event) { 182 _contextMenu(event) {
200 if (!this._cookies.length) { 183 if (!this._cookies.length) {
201 var contextMenu = new UI.ContextMenu(event); 184 var contextMenu = new UI.ContextMenu(event);
202 contextMenu.appendItem(Common.UIString('Refresh'), this._update.bind(this) ); 185 contextMenu.appendItem(Common.UIString('Refresh'), this._update.bind(this) );
203 contextMenu.show(); 186 contextMenu.show();
204 } 187 }
205 } 188 }
206 }; 189 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698