Skip to content

Commit ded23fb

Browse files
TimvdLippeCommit Bot
authored and
Commit Bot
committed
Migrate cookie_table/ to import cross-module
Bug: 1006759 Change-Id: I0d5e15c8b89d32f02c3844c032e2e04b11f2e7c1 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2052171 Commit-Queue: Tim van der Lippe <[email protected]> Reviewed-by: Paul Lewis <[email protected]>
1 parent 9b2f871 commit ded23fb

7 files changed

+85
-68
lines changed

front_end/cookie_table/CookiesTable.js

+57-51
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,24 @@
2828
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
const expiresSessionValue = Common.UIString('Session');
31+
import * as Common from '../common/common.js';
32+
import * as DataGrid from '../data_grid/data_grid.js';
33+
import * as Network from '../network/network.js';
34+
import * as SDK from '../sdk/sdk.js';
35+
import * as UI from '../ui/ui.js';
36+
37+
const expiresSessionValue = Common.UIString.UIString('Session');
3238

3339
/**
3440
* @unrestricted
3541
*/
36-
export class CookiesTable extends UI.VBox {
42+
export class CookiesTable extends UI.Widget.VBox {
3743
/**
3844
* @param {boolean=} renderInline
39-
* @param {function(!SDK.Cookie, ?SDK.Cookie): !Promise<boolean>=} saveCallback
45+
* @param {function(!SDK.Cookie.Cookie, ?SDK.Cookie.Cookie): !Promise<boolean>=} saveCallback
4046
* @param {function()=} refreshCallback
4147
* @param {function()=} selectedCallback
42-
* @param {function(!SDK.Cookie, function())=} deleteCallback
48+
* @param {function(!SDK.Cookie.Cookie, function())=} deleteCallback
4349
*/
4450
constructor(renderInline, saveCallback, refreshCallback, selectedCallback, deleteCallback) {
4551
super();
@@ -119,15 +125,15 @@ export class CookiesTable extends UI.VBox {
119125
]);
120126

121127
if (editable) {
122-
this._dataGrid = new DataGrid.DataGrid({
128+
this._dataGrid = new DataGrid.DataGrid.DataGridImpl({
123129
displayName: ls`Editable Cookies`,
124130
columns,
125131
editCallback: this._onUpdateCookie.bind(this),
126132
deleteCallback: this._onDeleteCookie.bind(this),
127133
refreshCallback
128134
});
129135
} else {
130-
this._dataGrid = new DataGrid.DataGrid({displayName: ls`Cookies`, columns});
136+
this._dataGrid = new DataGrid.DataGrid.DataGridImpl({displayName: ls`Cookies`, columns});
131137
}
132138
this._dataGrid.setStriped(true);
133139
this._dataGrid.setName('cookiesTable');
@@ -150,21 +156,21 @@ export class CookiesTable extends UI.VBox {
150156
/** @type {string} */
151157
this._cookieDomain = '';
152158

153-
/** @type {?Map<!SDK.Cookie, !Array<!CookieTable.BlockedReason>>} */
159+
/** @type {?Map<!SDK.Cookie.Cookie, !Array<!CookieTable.BlockedReason>>} */
154160
this._cookieToBlockedReasons = null;
155161
}
156162

157163
/**
158-
* @param {!Array.<!SDK.Cookie>} cookies
159-
* @param {!Map<!SDK.Cookie, !Array<!CookieTable.BlockedReason>>=} cookieToBlockedReasons
164+
* @param {!Array.<!SDK.Cookie.Cookie>} cookies
165+
* @param {!Map<!SDK.Cookie.Cookie, !Array<!CookieTable.BlockedReason>>=} cookieToBlockedReasons
160166
*/
161167
setCookies(cookies, cookieToBlockedReasons) {
162168
this.setCookieFolders([{cookies: cookies}], cookieToBlockedReasons);
163169
}
164170

165171
/**
166-
* @param {!Array.<!{folderName: ?string, cookies: ?Array.<!SDK.Cookie>}>} cookieFolders
167-
* @param {!Map<!SDK.Cookie, !Array<!CookieTable.BlockedReason>>=} cookieToBlockedReasons
172+
* @param {!Array.<!{folderName: ?string, cookies: ?Array.<!SDK.Cookie.Cookie>}>} cookieFolders
173+
* @param {!Map<!SDK.Cookie.Cookie, !Array<!CookieTable.BlockedReason>>=} cookieToBlockedReasons
168174
*/
169175
setCookieFolders(cookieFolders, cookieToBlockedReasons) {
170176
this._data = cookieFolders;
@@ -180,15 +186,15 @@ export class CookiesTable extends UI.VBox {
180186
}
181187

182188
/**
183-
* @return {?SDK.Cookie}
189+
* @return {?SDK.Cookie.Cookie}
184190
*/
185191
selectedCookie() {
186192
const node = this._dataGrid.selectedNode;
187193
return node ? node.cookie : null;
188194
}
189195

190196
/**
191-
* @return {{current: ?SDK.Cookie, neighbor: ?SDK.Cookie}}
197+
* @return {{current: ?SDK.Cookie.Cookie, neighbor: ?SDK.Cookie.Cookie}}
192198
*/
193199
_getSelectionCookies() {
194200
const node = this._dataGrid.selectedNode;
@@ -209,9 +215,9 @@ export class CookiesTable extends UI.VBox {
209215
}
210216

211217
/**
212-
* @param {{current: ?SDK.Cookie, neighbor: ?SDK.Cookie}} selectionCookies
213-
* @param {?Array<!SDK.Cookie>} cookies
214-
* @return {?SDK.Cookie}
218+
* @param {{current: ?SDK.Cookie.Cookie, neighbor: ?SDK.Cookie.Cookie}} selectionCookies
219+
* @param {?Array<!SDK.Cookie.Cookie>} cookies
220+
* @return {?SDK.Cookie.Cookie}
215221
*/
216222
_findSelectedCookie(selectionCookies, cookies) {
217223
if (!cookies) {
@@ -234,8 +240,8 @@ export class CookiesTable extends UI.VBox {
234240
}
235241

236242
/**
237-
* @param {!SDK.Cookie} cookieA
238-
* @param {?SDK.Cookie} cookieB
243+
* @param {!SDK.Cookie.Cookie} cookieA
244+
* @param {?SDK.Cookie.Cookie} cookieB
239245
* @return {boolean}
240246
*/
241247
_isSameCookie(cookieA, cookieB) {
@@ -264,7 +270,7 @@ export class CookiesTable extends UI.VBox {
264270
groupData[SDK.Cookie.Attributes.SameSite] = '';
265271
groupData[SDK.Cookie.Attributes.Priority] = '';
266272

267-
const groupNode = new DataGrid.DataGridNode(groupData);
273+
const groupNode = new DataGrid.DataGrid.DataGridNode(groupData);
268274
groupNode.selectable = true;
269275
this._dataGrid.rootNode().appendChild(groupNode);
270276
groupNode.element().classList.add('row-group');
@@ -283,9 +289,9 @@ export class CookiesTable extends UI.VBox {
283289
}
284290

285291
/**
286-
* @param {!DataGrid.DataGridNode} parentNode
287-
* @param {?Array.<!SDK.Cookie>} cookies
288-
* @param {?SDK.Cookie} selectedCookie
292+
* @param {!DataGrid.DataGrid.DataGridNode} parentNode
293+
* @param {?Array.<!SDK.Cookie.Cookie>} cookies
294+
* @param {?SDK.Cookie.Cookie} selectedCookie
289295
* @param {?string} lastEditedColumnId
290296
*/
291297
_populateNode(parentNode, cookies, selectedCookie, lastEditedColumnId) {
@@ -309,8 +315,8 @@ export class CookiesTable extends UI.VBox {
309315
}
310316

311317
/**
312-
* @param {!DataGrid.DataGridNode} parentNode
313-
* @param {!SDK.Cookie} cookie
318+
* @param {!DataGrid.DataGrid.DataGridNode} parentNode
319+
* @param {!SDK.Cookie.Cookie} cookie
314320
* @param {?string} editedColumnId
315321
*/
316322
_addInactiveNode(parentNode, cookie, editedColumnId) {
@@ -332,13 +338,13 @@ export class CookiesTable extends UI.VBox {
332338
}
333339

334340
/**
335-
* @param {!Array.<!SDK.Cookie>} cookies
341+
* @param {!Array.<!SDK.Cookie.Cookie>} cookies
336342
*/
337343
_sortCookies(cookies) {
338344
const sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1;
339345

340346
/**
341-
* @param {!SDK.Cookie} cookie
347+
* @param {!SDK.Cookie.Cookie} cookie
342348
* @param {string} property
343349
* @return {string}
344350
*/
@@ -348,26 +354,26 @@ export class CookiesTable extends UI.VBox {
348354

349355
/**
350356
* @param {string} property
351-
* @param {!SDK.Cookie} cookie1
352-
* @param {!SDK.Cookie} cookie2
357+
* @param {!SDK.Cookie.Cookie} cookie1
358+
* @param {!SDK.Cookie.Cookie} cookie2
353359
* @return {number}
354360
*/
355361
function compareTo(property, cookie1, cookie2) {
356362
return sortDirection * getValue(cookie1, property).compareTo(getValue(cookie2, property));
357363
}
358364

359365
/**
360-
* @param {!SDK.Cookie} cookie1
361-
* @param {!SDK.Cookie} cookie2
366+
* @param {!SDK.Cookie.Cookie} cookie1
367+
* @param {!SDK.Cookie.Cookie} cookie2
362368
* @return {number}
363369
*/
364370
function numberCompare(cookie1, cookie2) {
365371
return sortDirection * (cookie1.size() - cookie2.size());
366372
}
367373

368374
/**
369-
* @param {!SDK.Cookie} cookie1
370-
* @param {!SDK.Cookie} cookie2
375+
* @param {!SDK.Cookie.Cookie} cookie1
376+
* @param {!SDK.Cookie.Cookie} cookie2
371377
* @return {number}
372378
*/
373379
function priorityCompare(cookie1, cookie2) {
@@ -383,8 +389,8 @@ export class CookiesTable extends UI.VBox {
383389
}
384390

385391
/**
386-
* @param {!SDK.Cookie} cookie1
387-
* @param {!SDK.Cookie} cookie2
392+
* @param {!SDK.Cookie.Cookie} cookie1
393+
* @param {!SDK.Cookie.Cookie} cookie2
388394
* @return {number}
389395
*/
390396
function expiresCompare(cookie1, cookie2) {
@@ -420,8 +426,8 @@ export class CookiesTable extends UI.VBox {
420426
}
421427

422428
/**
423-
* @param {!SDK.Cookie} cookie
424-
* @return {!DataGrid.DataGridNode}
429+
* @param {!SDK.Cookie.Cookie} cookie
430+
* @return {!DataGrid.DataGrid.DataGridNode}
425431
*/
426432
_createGridNode(cookie) {
427433
const data = {};
@@ -461,7 +467,7 @@ export class CookiesTable extends UI.VBox {
461467
}
462468

463469
/**
464-
* @param {!DataGrid.DataGridNode} node
470+
* @param {!DataGrid.DataGrid.DataGridNode} node
465471
*/
466472
_onDeleteCookie(node) {
467473
if (node.cookie && this._deleteCallback) {
@@ -470,7 +476,7 @@ export class CookiesTable extends UI.VBox {
470476
}
471477

472478
/**
473-
* @param {!DataGrid.DataGridNode} editingNode
479+
* @param {!DataGrid.DataGrid.DataGridNode} editingNode
474480
* @param {string} columnIdentifier
475481
* @param {string} oldText
476482
* @param {string} newText
@@ -486,7 +492,7 @@ export class CookiesTable extends UI.VBox {
486492
}
487493

488494
/**
489-
* @param {!DataGrid.DataGridNode} node
495+
* @param {!DataGrid.DataGrid.DataGridNode} node
490496
*/
491497
_setDefaults(node) {
492498
if (node.data[SDK.Cookie.Attributes.Name] === null) {
@@ -507,7 +513,7 @@ export class CookiesTable extends UI.VBox {
507513
}
508514

509515
/**
510-
* @param {!DataGrid.DataGridNode} node
516+
* @param {!DataGrid.DataGrid.DataGridNode} node
511517
*/
512518
_saveNode(node) {
513519
const oldCookie = node.cookie;
@@ -524,10 +530,10 @@ export class CookiesTable extends UI.VBox {
524530

525531
/**
526532
* @param {!Object.<string, string>} data
527-
* @returns {!SDK.Cookie}
533+
* @returns {!SDK.Cookie.Cookie}
528534
*/
529535
_createCookieFromData(data) {
530-
const cookie = new SDK.Cookie(
536+
const cookie = new SDK.Cookie.Cookie(
531537
data[SDK.Cookie.Attributes.Name], data[SDK.Cookie.Attributes.Value], null,
532538
/** @type {!Protocol.Network.CookiePriority} */ (data[SDK.Cookie.Attributes.Priority]));
533539

@@ -566,7 +572,7 @@ export class CookiesTable extends UI.VBox {
566572
if (!domain) {
567573
return true;
568574
}
569-
const parsedURL = Common.ParsedURL.fromString('http://' + domain);
575+
const parsedURL = Common.ParsedURL.ParsedURL.fromString('http://' + domain);
570576
return !!parsedURL && parsedURL.domain() === domain;
571577
}
572578

@@ -575,7 +581,7 @@ export class CookiesTable extends UI.VBox {
575581
* @returns {boolean}
576582
*/
577583
_isValidPath(path) {
578-
const parsedURL = Common.ParsedURL.fromString('http://example.com' + path);
584+
const parsedURL = Common.ParsedURL.ParsedURL.fromString('http://example.com' + path);
579585
return !!parsedURL && parsedURL.path === path;
580586
}
581587

@@ -594,14 +600,14 @@ export class CookiesTable extends UI.VBox {
594600
}
595601

596602
/**
597-
* @param {!UI.ContextMenu} contextMenu
598-
* @param {!DataGrid.DataGridNode} gridNode
603+
* @param {!UI.ContextMenu.ContextMenu} contextMenu
604+
* @param {!DataGrid.DataGrid.DataGridNode} gridNode
599605
*/
600606
_populateContextMenu(contextMenu, gridNode) {
601-
const cookie = /** @type {!SDK.Cookie} */ (gridNode.cookie);
607+
const cookie = /** @type {!SDK.Cookie.Cookie} */ (gridNode.cookie);
602608

603609
contextMenu.revealSection().appendItem(ls`Show Requests With This Cookie`, () => {
604-
Network.NetworkPanel.revealAndFilter([
610+
Network.NetworkPanel.NetworkPanel.revealAndFilter([
605611
{
606612
filterType: 'cookie-domain',
607613
filterValue: cookie.domain(),
@@ -615,10 +621,10 @@ export class CookiesTable extends UI.VBox {
615621
}
616622
}
617623

618-
export class DataGridNode extends DataGrid.DataGridNode {
624+
export class DataGridNode extends DataGrid.DataGrid.DataGridNode {
619625
/**
620626
* @param {!Object<string, *>} data
621-
* @param {!SDK.Cookie} cookie
627+
* @param {!SDK.Cookie.Cookie} cookie
622628
* @param {?Array<!CookieTable.BlockedReason>} blockedReasons
623629
*/
624630
constructor(data, cookie, blockedReasons) {
@@ -662,7 +668,7 @@ export class DataGridNode extends DataGrid.DataGridNode {
662668
}
663669

664670
if (blockedReasonString) {
665-
const infoElement = UI.Icon.create('smallicon-info', 'cookie-warning-icon');
671+
const infoElement = UI.Icon.Icon.create('smallicon-info', 'cookie-warning-icon');
666672
infoElement.title = blockedReasonString;
667673
cell.insertBefore(infoElement, cell.firstChild);
668674
cell.classList.add('flagged-cookie-attribute-cell');

front_end/network/NetworkDataGridNode.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import * as Common from '../common/common.js';
3333
import * as Components from '../components/components.js';
3434
import * as DataGrid from '../data_grid/data_grid.js';
3535
import * as Host from '../host/host.js';
36+
import * as PerfUI from '../perf_ui/perf_ui.js';
3637
import * as SDK from '../sdk/sdk.js';
3738
import * as UI from '../ui/ui.js';
3839

@@ -639,10 +640,10 @@ export class NetworkRequestNode extends NetworkNode {
639640
return !aRequest ? -1 : 1;
640641
}
641642
const aPriority = aRequest.priority();
642-
let aScore = aPriority ? PerfUI.networkPriorityWeight(aPriority) : 0;
643+
let aScore = aPriority ? PerfUI.NetworkPriorities.networkPriorityWeight(aPriority) : 0;
643644
aScore = aScore || 0;
644645
const bPriority = bRequest.priority();
645-
let bScore = bPriority ? PerfUI.networkPriorityWeight(bPriority) : 0;
646+
let bScore = bPriority ? PerfUI.NetworkPriorities.networkPriorityWeight(bPriority) : 0;
646647
bScore = bScore || 0;
647648

648649
return aScore - bScore || aRequest.indentityCompare(bRequest);
@@ -915,7 +916,7 @@ export class NetworkRequestNode extends NetworkNode {
915916
break;
916917
case 'priority':
917918
const priority = this._request.priority();
918-
this._setTextAndTitle(cell, priority ? PerfUI.uiLabelForNetworkPriority(priority) : '');
919+
this._setTextAndTitle(cell, priority ? PerfUI.NetworkPriorities.uiLabelForNetworkPriority(priority) : '');
919920
break;
920921
case 'connectionid':
921922
this._setTextAndTitle(cell, this._request.connectionId);

0 commit comments

Comments
 (0)