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

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

Issue 2349343002: DevTools: introduce persistence/ module (Closed)
Patch Set: reupload Created 4 years, 3 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 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @param {!WebInspector.SourcesPanel} sourcesPanel 8 * @param {!WebInspector.SourcesPanel} sourcesPanel
9 * @param {!WebInspector.Workspace} workspace 9 * @param {!WebInspector.Workspace} workspace
10 */ 10 */
11 WebInspector.WorkspaceMappingTip = function(sourcesPanel, workspace) 11 WebInspector.WorkspaceMappingTip = function(sourcesPanel, workspace)
12 { 12 {
13 this._sourcesPanel = sourcesPanel; 13 this._sourcesPanel = sourcesPanel;
14 this._workspace = workspace; 14 this._workspace = workspace;
15 15
16 this._sourcesView = this._sourcesPanel.sourcesView(); 16 this._sourcesView = this._sourcesPanel.sourcesView();
17 this._workspaceInfobarDisabledSetting = WebInspector.settings.createSetting( "workspaceInfobarDisabled", false); 17 this._workspaceInfobarDisabledSetting = WebInspector.settings.createSetting( "workspaceInfobarDisabled", false);
18 this._workspaceMappingInfobarDisabledSetting = WebInspector.settings.createS etting("workspaceMappingInfobarDisabled", false); 18 this._workspaceMappingInfobarDisabledSetting = WebInspector.settings.createS etting("workspaceMappingInfobarDisabled", false);
19 19
20 if (this._workspaceInfobarDisabledSetting.get() && this._workspaceMappingInf obarDisabledSetting.get()) 20 if (this._workspaceInfobarDisabledSetting.get() && this._workspaceMappingInf obarDisabledSetting.get())
21 return; 21 return;
22 this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSel ected, this._editorSelected.bind(this)); 22 this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSel ected, this._editorSelected.bind(this));
23 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingCreated, this._bindingCreated, this);
23 } 24 }
24 25
25 WebInspector.WorkspaceMappingTip._infobarSymbol = Symbol("infobar"); 26 WebInspector.WorkspaceMappingTip._infobarSymbol = Symbol("infobar");
26 27
27 WebInspector.WorkspaceMappingTip.prototype = { 28 WebInspector.WorkspaceMappingTip.prototype = {
28 /** 29 /**
29 * @param {!WebInspector.Event} event 30 * @param {!WebInspector.Event} event
30 */ 31 */
32 _bindingCreated: function(event)
33 {
34 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data );
35 if (binding.network[WebInspector.WorkspaceMappingTip._infobarSymbol])
36 binding.network[WebInspector.WorkspaceMappingTip._infobarSymbol].dis pose();
37 if (binding.fileSystem[WebInspector.WorkspaceMappingTip._infobarSymbol])
38 binding.fileSystem[WebInspector.WorkspaceMappingTip._infobarSymbol]. dispose();
39 },
40
41 /**
42 * @param {!WebInspector.Event} event
43 */
31 _editorSelected: function(event) 44 _editorSelected: function(event)
32 { 45 {
33 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data ); 46 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data );
34 if (this._editorSelectedTimer) 47 if (this._editorSelectedTimer)
35 clearTimeout(this._editorSelectedTimer); 48 clearTimeout(this._editorSelectedTimer);
36 this._editorSelectedTimer = setTimeout(this._updateSuggestedMappingInfob ar.bind(this, uiSourceCode), 3000); 49 this._editorSelectedTimer = setTimeout(this._updateSuggestedMappingInfob ar.bind(this, uiSourceCode), 3000);
37 }, 50 },
38 51
39 /** 52 /**
40 * @param {!WebInspector.UISourceCode} uiSourceCode 53 * @param {!WebInspector.UISourceCode} uiSourceCode
41 */ 54 */
42 _updateSuggestedMappingInfobar: function(uiSourceCode) 55 _updateSuggestedMappingInfobar: function(uiSourceCode)
43 { 56 {
44 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); 57 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode);
45 58
46 if (!uiSourceCodeFrame.isShowing()) 59 if (!uiSourceCodeFrame.isShowing())
47 return; 60 return;
48 if (uiSourceCode[WebInspector.WorkspaceMappingTip._infobarSymbol]) 61 if (uiSourceCode[WebInspector.WorkspaceMappingTip._infobarSymbol])
49 return; 62 return;
50 63
51 // First try mapping filesystem -> network. 64 // First try mapping filesystem -> network.
52 if (!this._workspaceMappingInfobarDisabledSetting.get() && uiSourceCode. project().type() === WebInspector.projectTypes.FileSystem) { 65 if (!this._workspaceMappingInfobarDisabledSetting.get() && uiSourceCode. project().type() === WebInspector.projectTypes.FileSystem) {
53 var networkURL = WebInspector.networkMapping.networkURL(uiSourceCode ); 66 if (WebInspector.persistence.binding(uiSourceCode))
54 var hasMappings = !!networkURL;
55 if (hasMappings)
56 return; 67 return;
57 68
58 var networkProjects = this._workspace.projectsForType(WebInspector.p rojectTypes.Network); 69 var networkProjects = this._workspace.projectsForType(WebInspector.p rojectTypes.Network);
59 networkProjects = networkProjects.concat(this._workspace.projectsFor Type(WebInspector.projectTypes.ContentScripts)); 70 networkProjects = networkProjects.concat(this._workspace.projectsFor Type(WebInspector.projectTypes.ContentScripts));
60 for (var i = 0; i < networkProjects.length; ++i) { 71 for (var i = 0; i < networkProjects.length; ++i) {
61 var name = uiSourceCode.name(); 72 var name = uiSourceCode.name();
62 var networkUiSourceCodes = networkProjects[i].uiSourceCodes(); 73 var networkUiSourceCodes = networkProjects[i].uiSourceCodes();
63 for (var j = 0; j < networkUiSourceCodes.length; ++j) { 74 for (var j = 0; j < networkUiSourceCodes.length; ++j) {
64 if (networkUiSourceCodes[j].name() === name && this._isLocal Host(networkUiSourceCodes[j].url())) { 75 if (networkUiSourceCodes[j].name() === name && this._isLocal Host(networkUiSourceCodes[j].url())) {
65 this._showMappingInfobar(uiSourceCode, false); 76 this._showMappingInfobar(uiSourceCode, false);
66 return; 77 return;
67 } 78 }
68 } 79 }
69 } 80 }
70 } 81 }
71 82
72 // Then map network -> filesystem. 83 // Then map network -> filesystem.
73 if (uiSourceCode.project().type() === WebInspector.projectTypes.Network || uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) { 84 if (uiSourceCode.project().type() === WebInspector.projectTypes.Network || uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) {
74 // Suggest for localhost only. 85 // Suggest for localhost only.
75 if (!this._isLocalHost(uiSourceCode.url())) 86 if (!this._isLocalHost(uiSourceCode.url()) || WebInspector.persisten ce.binding(uiSourceCode))
76 return;
77 var networkURL = WebInspector.networkMapping.networkURL(uiSourceCode );
78 if (WebInspector.networkMapping.uiSourceCodeForURLForAnyTarget(netwo rkURL) !== uiSourceCode)
79 return; 87 return;
80 88
81 var filesystemProjects = this._workspace.projectsForType(WebInspecto r.projectTypes.FileSystem); 89 var filesystemProjects = this._workspace.projectsForType(WebInspecto r.projectTypes.FileSystem);
82 for (var i = 0; i < filesystemProjects.length; ++i) { 90 for (var i = 0; i < filesystemProjects.length; ++i) {
83 var name = uiSourceCode.name(); 91 var name = uiSourceCode.name();
84 var fsUiSourceCodes = filesystemProjects[i].uiSourceCodes(); 92 var fsUiSourceCodes = filesystemProjects[i].uiSourceCodes();
85 for (var j = 0; j < fsUiSourceCodes.length; ++j) { 93 for (var j = 0; j < fsUiSourceCodes.length; ++j) {
86 if (fsUiSourceCodes[j].name() === name) { 94 if (fsUiSourceCodes[j].name() === name) {
87 this._showMappingInfobar(uiSourceCode, true); 95 this._showMappingInfobar(uiSourceCode, true);
88 return; 96 return;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); 171 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode);
164 172
165 var rowElement = infobar.createDetailsRowMessage(WebInspector.UIString(" For more information on workspaces, refer to the ")); 173 var rowElement = infobar.createDetailsRowMessage(WebInspector.UIString(" For more information on workspaces, refer to the "));
166 rowElement.appendChild(WebInspector.linkifyDocumentationURLAsNode("../se tup/setup-workflow", WebInspector.UIString("workspaces documentation"))); 174 rowElement.appendChild(WebInspector.linkifyDocumentationURLAsNode("../se tup/setup-workflow", WebInspector.UIString("workspaces documentation")));
167 rowElement.createTextChild("."); 175 rowElement.createTextChild(".");
168 uiSourceCode[WebInspector.WorkspaceMappingTip._infobarSymbol] = infobar; 176 uiSourceCode[WebInspector.WorkspaceMappingTip._infobarSymbol] = infobar;
169 uiSourceCodeFrame.attachInfobars([infobar]); 177 uiSourceCodeFrame.attachInfobars([infobar]);
170 WebInspector.runCSSAnimationOnce(infobar.element, "source-frame-infobar- animation"); 178 WebInspector.runCSSAnimationOnce(infobar.element, "source-frame-infobar- animation");
171 } 179 }
172 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698