OLD | NEW |
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._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSel
ected, this._editorSelected.bind(this)); | 17 this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSel
ected, this._editorSelected.bind(this)); |
18 } | 18 } |
19 | 19 |
20 WebInspector.WorkspaceMappingTip._infobarSymbol = Symbol("infobar"); | 20 WebInspector.WorkspaceMappingTip._infobarSymbol = Symbol("infobar"); |
21 | 21 |
22 WebInspector.WorkspaceMappingTip.prototype = { | 22 WebInspector.WorkspaceMappingTip.prototype = { |
23 /** | 23 /** |
24 * @param {!WebInspector.Event} event | 24 * @param {!WebInspector.Event} event |
25 */ | 25 */ |
26 _editorSelected: function(event) | 26 _editorSelected: function(event) |
27 { | 27 { |
28 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | 28 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); |
29 if (Runtime.experiments.isEnabled("suggestUsingWorkspace")) { | 29 if (this._editorSelectedTimer) |
30 if (this._editorSelectedTimer) | 30 clearTimeout(this._editorSelectedTimer); |
31 clearTimeout(this._editorSelectedTimer); | 31 this._editorSelectedTimer = setTimeout(this._updateSuggestedMappingInfob
ar.bind(this, uiSourceCode), 3000); |
32 this._editorSelectedTimer = setTimeout(this._updateSuggestedMappingI
nfobar.bind(this, uiSourceCode), 3000); | |
33 } | |
34 }, | 32 }, |
35 | 33 |
36 /** | 34 /** |
37 * @param {!WebInspector.UISourceCode} uiSourceCode | 35 * @param {!WebInspector.UISourceCode} uiSourceCode |
38 */ | 36 */ |
39 _updateSuggestedMappingInfobar: function(uiSourceCode) | 37 _updateSuggestedMappingInfobar: function(uiSourceCode) |
40 { | 38 { |
41 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); | 39 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); |
42 | 40 |
43 if (!uiSourceCodeFrame.isShowing()) | 41 if (!uiSourceCodeFrame.isShowing()) |
44 return; | 42 return; |
45 if (uiSourceCode[WebInspector.WorkspaceMappingTip._infobarSymbol]) | 43 if (uiSourceCode[WebInspector.WorkspaceMappingTip._infobarSymbol]) |
46 return; | 44 return; |
47 | 45 |
48 // First try mapping filesystem -> network. | 46 // First try mapping filesystem -> network. |
49 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) { | 47 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) { |
50 var hasMappings = !!uiSourceCode.url; | 48 var hasMappings = !!uiSourceCode.url; |
51 if (hasMappings) | 49 if (hasMappings) |
52 return; | 50 return; |
53 } | 51 } |
54 | 52 |
55 var networkProjects = this._workspace.projectsForType(WebInspector.proje
ctTypes.FileSystem); | 53 var networkProjects = this._workspace.projectsForType(WebInspector.proje
ctTypes.Network); |
56 networkProjects = networkProjects.concat(this._workspace.projectsForType
(WebInspector.projectTypes.ContentScripts)); | 54 networkProjects = networkProjects.concat(this._workspace.projectsForType
(WebInspector.projectTypes.ContentScripts)); |
57 for (var i = 0; i < networkProjects.length; ++i) { | 55 for (var i = 0; i < networkProjects.length; ++i) { |
58 var name = uiSourceCode.name(); | 56 var name = uiSourceCode.name(); |
59 var networkUiSourceCodes = networkProjects[i].uiSourceCodes(); | 57 var networkUiSourceCodes = networkProjects[i].uiSourceCodes(); |
60 for (var j = 0; j < networkUiSourceCodes.length; ++j) { | 58 for (var j = 0; j < networkUiSourceCodes.length; ++j) { |
61 if (networkUiSourceCodes[j].name() === name) { | 59 if (networkUiSourceCodes[j].name() === name) { |
62 this._createMappingInfobar(uiSourceCode, false); | 60 this._createMappingInfobar(uiSourceCode, false); |
63 return; | 61 return; |
64 } | 62 } |
65 } | 63 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 var rowElement = infobar.createDetailsRowMessage(WebInspector.UIString("
For more information on workspaces, refer to the ")); | 145 var rowElement = infobar.createDetailsRowMessage(WebInspector.UIString("
For more information on workspaces, refer to the ")); |
148 var a = rowElement.createChild("a"); | 146 var a = rowElement.createChild("a"); |
149 a.textContent = "workspaces documentation"; | 147 a.textContent = "workspaces documentation"; |
150 a.href = "https://developer.chrome.com/devtools/docs/workspaces"; | 148 a.href = "https://developer.chrome.com/devtools/docs/workspaces"; |
151 rowElement.createTextChild("."); | 149 rowElement.createTextChild("."); |
152 uiSourceCode[WebInspector.WorkspaceMappingTip._infobarSymbol] = infobar; | 150 uiSourceCode[WebInspector.WorkspaceMappingTip._infobarSymbol] = infobar; |
153 uiSourceCodeFrame.attachInfobars([infobar]); | 151 uiSourceCodeFrame.attachInfobars([infobar]); |
154 WebInspector.runCSSAnimationOnce(infobar.element, "source-frame-infobar-
animation"); | 152 WebInspector.runCSSAnimationOnce(infobar.element, "source-frame-infobar-
animation"); |
155 } | 153 } |
156 } | 154 } |
OLD | NEW |