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

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: Fix formatting. Created 3 years, 11 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 this._textFilterUI = new UI.TextFilterUI(true); 49 this._textFilterUI = new UI.TextFilterUI(true);
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._treeElement = treeElement; 56 this._treeElement = treeElement;
57 this._cookieDomain = cookieDomain; 57 this._cookieDomain = cookieDomain;
58 58
59 this._emptyWidget = new UI.EmptyWidget(
60 cookieDomain ?
dgozman 2017/01/20 01:54:51 Let's only show cookies for http:// and https:// o
kdzwinel 2017/01/21 02:12:20 It looks like it's possible to set cookies on file
61 Common.UIString('This site has no cookies.') :
62 Common.UIString(
63 'By default cookies are disabled for local files.\nYou could ove rride this by starting the browser with --enable-file-cookies command line flag. '));
64 this._emptyWidget.show(this.element);
65
66 this.element.addEventListener('contextmenu', this._contextMenu.bind(this), t rue); 59 this.element.addEventListener('contextmenu', this._contextMenu.bind(this), t rue);
67 } 60 }
68 61
69 /** 62 /**
70 * @override 63 * @override
71 * @return {!Array.<!UI.ToolbarItem>} 64 * @return {!Array.<!UI.ToolbarItem>}
72 */ 65 */
73 syncToolbarItems() { 66 syncToolbarItems() {
74 return [this._refreshButton, this._clearButton, this._deleteButton, this._fi lterSeparator, this._filterButton]; 67 return [this._refreshButton, this._clearButton, this._deleteButton, this._fi lterSeparator, this._filterButton];
75 } 68 }
(...skipping 24 matching lines...) Expand all
100 _update() { 93 _update() {
101 SDK.Cookies.getCookiesAsync(this._updateWithCookies.bind(this)); 94 SDK.Cookies.getCookiesAsync(this._updateWithCookies.bind(this));
102 } 95 }
103 96
104 /** 97 /**
105 * @param {!Array.<!SDK.Cookie>} allCookies 98 * @param {!Array.<!SDK.Cookie>} allCookies
106 */ 99 */
107 _updateWithCookies(allCookies) { 100 _updateWithCookies(allCookies) {
108 this._cookies = this._filterCookiesForDomain(allCookies); 101 this._cookies = this._filterCookiesForDomain(allCookies);
109 102
110 if (!this._cookies.length) {
111 // Nothing to show.
112 this._emptyWidget.show(this.element);
113 this._filterButton.setEnabled(false);
114 this._clearButton.setEnabled(false);
115 this._deleteButton.setEnabled(false);
116 if (this._cookiesTable)
117 this._cookiesTable.detach();
118 return;
119 }
120
121 if (!this._cookiesTable) { 103 if (!this._cookiesTable) {
104 const parsedURL = this._cookieDomain.asParsedURL();
105 const domain = parsedURL ? parsedURL.domain() : '';
122 this._cookiesTable = 106 this._cookiesTable =
123 new CookieTable.CookiesTable(false, this._update.bind(this), this._ena bleDeleteButton.bind(this)); 107 new CookieTable.CookiesTable(false, this._update.bind(this), this._ena bleDeleteButton.bind(this), domain);
124 } 108 }
125 109
126 var shownCookies = this._filterCookiesForFilters(this._cookies); 110 var shownCookies = this._filterCookiesForFilters(this._cookies);
127 this._cookiesTable.setCookies(shownCookies); 111 this._cookiesTable.setCookies(shownCookies);
128 this._emptyWidget.detach();
129 this._cookiesTable.show(this.element); 112 this._cookiesTable.show(this.element);
130 this._filterBar.show(this.element); 113 this._filterBar.show(this.element);
131 this._treeElement.subtitle = 114 this._treeElement.subtitle =
132 String.sprintf(Common.UIString('%d cookies (%s)'), this._cookies.length, Number.bytesToString(this._totalSize)); 115 String.sprintf(Common.UIString('%d cookies (%s)'), this._cookies.length, Number.bytesToString(this._totalSize));
133 this._filterButton.setEnabled(true); 116 this._filterButton.setEnabled(true);
134 this._clearButton.setEnabled(true); 117 this._clearButton.setEnabled(true);
135 this._deleteButton.setEnabled(!!this._cookiesTable.selectedCookie()); 118 this._deleteButton.setEnabled(!!this._cookiesTable.selectedCookie());
136 } 119 }
137 120
138 /** 121 /**
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 201 }
219 202
220 _contextMenu(event) { 203 _contextMenu(event) {
221 if (!this._cookies.length) { 204 if (!this._cookies.length) {
222 var contextMenu = new UI.ContextMenu(event); 205 var contextMenu = new UI.ContextMenu(event);
223 contextMenu.appendItem(Common.UIString('Refresh'), this._update.bind(this) ); 206 contextMenu.appendItem(Common.UIString('Refresh'), this._update.bind(this) );
224 contextMenu.show(); 207 contextMenu.show();
225 } 208 }
226 } 209 }
227 }; 210 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698