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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/NavigatorView.js

Issue 2349343002: DevTools: introduce persistence/ module (Closed)
Patch Set: DevTools: add persistence/ module Created 4 years, 2 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 10 *
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi s), false); 55 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi s), false);
56 56
57 this._navigatorGroupByFolderSetting = WebInspector.moduleSetting("navigatorG roupByFolder"); 57 this._navigatorGroupByFolderSetting = WebInspector.moduleSetting("navigatorG roupByFolder");
58 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged. bind(this)); 58 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged. bind(this));
59 59
60 this._initGrouping(); 60 this._initGrouping();
61 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this ); 61 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this );
62 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.FrameDetached, this._frameDetached, this); 62 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.FrameDetached, this._frameDetached, this);
63 WebInspector.targetManager.observeTargets(this); 63 WebInspector.targetManager.observeTargets(this);
64 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingCreated, this._onBindingCreated, this);
65 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingRemoved, this._onBindingRemoved, this);
64 this._resetWorkspace(WebInspector.workspace); 66 this._resetWorkspace(WebInspector.workspace);
65 } 67 }
66 68
67 WebInspector.NavigatorView.Types = { 69 WebInspector.NavigatorView.Types = {
68 Category: "category", 70 Category: "category",
69 Domain: "domain", 71 Domain: "domain",
70 File: "file", 72 File: "file",
71 FileSystem: "fs", 73 FileSystem: "fs",
72 FileSystemFolder: "fs-folder", 74 FileSystemFolder: "fs-folder",
73 Frame: "frame", 75 Frame: "frame",
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 var searchLabel = WebInspector.UIString.capitalize("Search in ^folder"); 147 var searchLabel = WebInspector.UIString.capitalize("Search in ^folder");
146 if (!path || !path.trim()) { 148 if (!path || !path.trim()) {
147 path = "*"; 149 path = "*";
148 searchLabel = WebInspector.UIString.capitalize("Search in ^all ^files"); 150 searchLabel = WebInspector.UIString.capitalize("Search in ^all ^files");
149 } 151 }
150 contextMenu.appendItem(searchLabel, searchPath); 152 contextMenu.appendItem(searchLabel, searchPath);
151 } 153 }
152 154
153 WebInspector.NavigatorView.prototype = { 155 WebInspector.NavigatorView.prototype = {
154 /** 156 /**
157 * @param {!WebInspector.Event} event
158 */
159 _onBindingCreated: function(event)
160 {
161 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data );
162 this._removeUISourceCode(binding.network);
dgozman 2016/09/22 19:55:54 TODO(lushnikov): remove this after adding a green
lushnikov 2016/09/23 21:56:13 Done.
163 },
164
165 /**
166 * @param {!WebInspector.Event} event
167 */
168 _onBindingRemoved: function(event)
169 {
170 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data );
171 this._addUISourceCode(binding.network);
172 },
173
174 /**
155 * @override 175 * @override
156 */ 176 */
157 focus: function() 177 focus: function()
158 { 178 {
159 this._scriptsTree.focus(); 179 this._scriptsTree.focus();
160 }, 180 },
161 181
162 /** 182 /**
163 * @param {!WebInspector.Workspace} workspace 183 * @param {!WebInspector.Workspace} workspace
164 */ 184 */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 }, 223 },
204 224
205 /** 225 /**
206 * @param {!WebInspector.UISourceCode} uiSourceCode 226 * @param {!WebInspector.UISourceCode} uiSourceCode
207 */ 227 */
208 _addUISourceCode: function(uiSourceCode) 228 _addUISourceCode: function(uiSourceCode)
209 { 229 {
210 if (!this.accept(uiSourceCode)) 230 if (!this.accept(uiSourceCode))
211 return; 231 return;
212 232
233 var binding = WebInspector.persistence.binding(uiSourceCode);
234 if (binding && binding.network === uiSourceCode)
235 return;
236
213 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); 237 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap();
214 var path; 238 var path;
215 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst em) 239 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst em)
216 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSource Code).slice(0, -1); 240 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSource Code).slice(0, -1);
217 else 241 else
218 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod e.url()).slice(1, -1); 242 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod e.url()).slice(1, -1);
219 243
220 var project = uiSourceCode.project(); 244 var project = uiSourceCode.project();
221 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC ode); 245 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC ode);
222 var frame = this._uiSourceCodeFrame(uiSourceCode); 246 var frame = this._uiSourceCodeFrame(uiSourceCode);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 456
433 return (prettyURL || projectOrigin); 457 return (prettyURL || projectOrigin);
434 }, 458 },
435 459
436 /** 460 /**
437 * @param {!WebInspector.UISourceCode} uiSourceCode 461 * @param {!WebInspector.UISourceCode} uiSourceCode
438 * @param {boolean=} select 462 * @param {boolean=} select
439 */ 463 */
440 revealUISourceCode: function(uiSourceCode, select) 464 revealUISourceCode: function(uiSourceCode, select)
441 { 465 {
466 var binding = WebInspector.persistence.binding(uiSourceCode);
467 if (binding && binding.network === uiSourceCode)
468 uiSourceCode = binding.persistent;
442 var node = this._uiSourceCodeNodes.get(uiSourceCode); 469 var node = this._uiSourceCodeNodes.get(uiSourceCode);
443 if (!node) 470 if (!node)
444 return; 471 return;
445 if (this._scriptsTree.selectedTreeElement) 472 if (this._scriptsTree.selectedTreeElement)
446 this._scriptsTree.selectedTreeElement.deselect(); 473 this._scriptsTree.selectedTreeElement.deselect();
447 this._lastSelectedUISourceCode = uiSourceCode; 474 this._lastSelectedUISourceCode = uiSourceCode;
448 node.reveal(select); 475 node.reveal(select);
449 }, 476 },
450 477
451 /** 478 /**
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 1282
1256 /** 1283 /**
1257 * @param {boolean=} ignoreIsDirty 1284 * @param {boolean=} ignoreIsDirty
1258 */ 1285 */
1259 updateTitle: function(ignoreIsDirty) 1286 updateTitle: function(ignoreIsDirty)
1260 { 1287 {
1261 if (!this._treeElement) 1288 if (!this._treeElement)
1262 return; 1289 return;
1263 1290
1264 var titleText = this._uiSourceCode.displayName(); 1291 var titleText = this._uiSourceCode.displayName();
1265 if (!ignoreIsDirty && (this._uiSourceCode.isDirty() || this._uiSourceCod e.hasUnsavedCommittedChanges())) 1292 if (!ignoreIsDirty && (this._uiSourceCode.isDirty() || WebInspector.pers istence.hasUnsavedCommittedChanges(this._uiSourceCode)))
1266 titleText = "*" + titleText; 1293 titleText = "*" + titleText;
1267 this._treeElement.title = titleText; 1294 this._treeElement.title = titleText;
1268 1295
1269 var tooltip = this._uiSourceCode.url(); 1296 var tooltip = this._uiSourceCode.url();
1270 if (this._uiSourceCode.contentType().isFromSourceMap()) 1297 if (this._uiSourceCode.contentType().isFromSourceMap())
1271 tooltip = WebInspector.UIString("%s (from source map)", this._uiSour ceCode.displayName()); 1298 tooltip = WebInspector.UIString("%s (from source map)", this._uiSour ceCode.displayName());
1272 this._treeElement.tooltip = tooltip; 1299 this._treeElement.tooltip = tooltip;
1273 }, 1300 },
1274 1301
1275 /** 1302 /**
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 { 1596 {
1570 if (this._treeElement) 1597 if (this._treeElement)
1571 return this._treeElement; 1598 return this._treeElement;
1572 this._treeElement = new WebInspector.NavigatorFolderTreeElement(this._na vigatorView, this._type, this._title, this._hoverCallback); 1599 this._treeElement = new WebInspector.NavigatorFolderTreeElement(this._na vigatorView, this._type, this._title, this._hoverCallback);
1573 this._treeElement.setNode(this); 1600 this._treeElement.setNode(this);
1574 return this._treeElement; 1601 return this._treeElement;
1575 }, 1602 },
1576 1603
1577 __proto__: WebInspector.NavigatorTreeNode.prototype 1604 __proto__: WebInspector.NavigatorTreeNode.prototype
1578 } 1605 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698