| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 Sources.WorkspaceMappingTip = class { | 7 Sources.WorkspaceMappingTip = class { |
| 8 /** | 8 /** |
| 9 * @param {!Sources.SourcesPanel} sourcesPanel | 9 * @param {!Sources.SourcesPanel} sourcesPanel |
| 10 * @param {!Workspace.Workspace} workspace | 10 * @param {!Workspace.Workspace} workspace |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 _updateSuggestedMappingInfobar(uiSourceCode) { | 51 _updateSuggestedMappingInfobar(uiSourceCode) { |
| 52 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); | 52 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); |
| 53 | 53 |
| 54 if (!uiSourceCodeFrame.isShowing()) | 54 if (!uiSourceCodeFrame.isShowing()) |
| 55 return; | 55 return; |
| 56 if (uiSourceCode[Sources.WorkspaceMappingTip._infobarSymbol]) | 56 if (uiSourceCode[Sources.WorkspaceMappingTip._infobarSymbol]) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 // First try mapping filesystem -> network. | 59 // First try mapping filesystem -> network. |
| 60 if (!this._workspaceMappingInfobarDisabledSetting.get() && | 60 if (!this._workspaceMappingInfobarDisabledSetting.get() && |
| 61 uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) { | 61 Persistence.FileSystemWorkspaceBinding.isFileSystemUISourceCode(uiSource
Code)) { |
| 62 if (Persistence.persistence.binding(uiSourceCode)) | 62 if (Persistence.persistence.binding(uiSourceCode)) |
| 63 return; | 63 return; |
| 64 | 64 |
| 65 var networkProjects = this._workspace.projectsForType(Workspace.projectTyp
es.Network); | 65 var name = uiSourceCode.name(); |
| 66 networkProjects = networkProjects.concat(this._workspace.projectsForType(W
orkspace.projectTypes.ContentScripts)); | 66 for (var networkUiSourceCode of Bindings.NetworkProject.uiSourceCodes(this
._workspace)) { |
| 67 for (var i = 0; i < networkProjects.length; ++i) { | 67 if (networkUiSourceCode.name() === name && this._isLocalHost(networkUiSo
urceCode.url())) { |
| 68 var name = uiSourceCode.name(); | 68 this._showMappingInfobar(uiSourceCode, false); |
| 69 var networkUiSourceCodes = networkProjects[i].uiSourceCodes(); | 69 return; |
| 70 for (var j = 0; j < networkUiSourceCodes.length; ++j) { | |
| 71 if (networkUiSourceCodes[j].name() === name && this._isLocalHost(netwo
rkUiSourceCodes[j].url())) { | |
| 72 this._showMappingInfobar(uiSourceCode, false); | |
| 73 return; | |
| 74 } | |
| 75 } | 70 } |
| 76 } | 71 } |
| 77 } | 72 } |
| 78 | 73 |
| 79 // Then map network -> filesystem. | 74 // Then map network -> filesystem. |
| 80 if (uiSourceCode.project().type() === Workspace.projectTypes.Network || | 75 if (Bindings.NetworkProject.isNetworkUISourceCode(uiSourceCode)) { |
| 81 uiSourceCode.project().type() === Workspace.projectTypes.ContentScripts)
{ | |
| 82 // Suggest for localhost only. | 76 // Suggest for localhost only. |
| 83 if (!this._isLocalHost(uiSourceCode.url()) || Persistence.persistence.bind
ing(uiSourceCode)) | 77 if (!this._isLocalHost(uiSourceCode.url()) || Persistence.persistence.bind
ing(uiSourceCode)) |
| 84 return; | 78 return; |
| 85 | 79 |
| 86 var filesystemProjects = this._workspace.projectsForType(Workspace.project
Types.FileSystem); | 80 var name = uiSourceCode.name(); |
| 87 for (var i = 0; i < filesystemProjects.length; ++i) { | 81 for (var fsUiSourceCode of Persistence.FileSystemWorkspaceBinding.uiSource
Codes(this._workspace)) { |
| 88 var name = uiSourceCode.name(); | 82 if (fsUiSourceCode.name() === name) { |
| 89 var fsUiSourceCodes = filesystemProjects[i].uiSourceCodes(); | 83 this._showMappingInfobar(uiSourceCode, true); |
| 90 for (var j = 0; j < fsUiSourceCodes.length; ++j) { | 84 return; |
| 91 if (fsUiSourceCodes[j].name() === name) { | |
| 92 this._showMappingInfobar(uiSourceCode, true); | |
| 93 return; | |
| 94 } | |
| 95 } | 85 } |
| 96 } | 86 } |
| 97 | 87 |
| 98 this._showWorkspaceInfobar(uiSourceCode); | 88 this._showWorkspaceInfobar(uiSourceCode); |
| 99 } | 89 } |
| 100 } | 90 } |
| 101 | 91 |
| 102 /** | 92 /** |
| 103 * @param {string} url | 93 * @param {string} url |
| 104 * @return {boolean} | 94 * @return {boolean} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 infobar.createDetailsRowMessage('').appendChild(anchor); | 137 infobar.createDetailsRowMessage('').appendChild(anchor); |
| 148 this._appendInfobar(uiSourceCode, infobar); | 138 this._appendInfobar(uiSourceCode, infobar); |
| 149 } | 139 } |
| 150 | 140 |
| 151 /** | 141 /** |
| 152 * @param {!Workspace.UISourceCode} uiSourceCode | 142 * @param {!Workspace.UISourceCode} uiSourceCode |
| 153 * @param {?Event} event | 143 * @param {?Event} event |
| 154 */ | 144 */ |
| 155 _establishTheMapping(uiSourceCode, event) { | 145 _establishTheMapping(uiSourceCode, event) { |
| 156 event.consume(true); | 146 event.consume(true); |
| 157 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) | 147 if (Persistence.FileSystemWorkspaceBinding.isFileSystemUISourceCode(uiSource
Code)) |
| 158 this._sourcesPanel.mapFileSystemToNetwork(uiSourceCode); | 148 this._sourcesPanel.mapFileSystemToNetwork(uiSourceCode); |
| 159 else | 149 else |
| 160 this._sourcesPanel.mapNetworkToFileSystem(uiSourceCode); | 150 this._sourcesPanel.mapNetworkToFileSystem(uiSourceCode); |
| 161 } | 151 } |
| 162 | 152 |
| 163 /** | 153 /** |
| 164 * @param {!Workspace.UISourceCode} uiSourceCode | 154 * @param {!Workspace.UISourceCode} uiSourceCode |
| 165 * @param {!UI.Infobar} infobar | 155 * @param {!UI.Infobar} infobar |
| 166 */ | 156 */ |
| 167 _appendInfobar(uiSourceCode, infobar) { | 157 _appendInfobar(uiSourceCode, infobar) { |
| 168 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); | 158 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); |
| 169 | 159 |
| 170 var rowElement = | 160 var rowElement = |
| 171 infobar.createDetailsRowMessage(Common.UIString('For more information on
workspaces, refer to the ')); | 161 infobar.createDetailsRowMessage(Common.UIString('For more information on
workspaces, refer to the ')); |
| 172 rowElement.appendChild( | 162 rowElement.appendChild( |
| 173 UI.createDocumentationLink('../setup/setup-workflow', Common.UIString('w
orkspaces documentation'))); | 163 UI.createDocumentationLink('../setup/setup-workflow', Common.UIString('w
orkspaces documentation'))); |
| 174 rowElement.createTextChild('.'); | 164 rowElement.createTextChild('.'); |
| 175 uiSourceCode[Sources.WorkspaceMappingTip._infobarSymbol] = infobar; | 165 uiSourceCode[Sources.WorkspaceMappingTip._infobarSymbol] = infobar; |
| 176 uiSourceCodeFrame.attachInfobars([infobar]); | 166 uiSourceCodeFrame.attachInfobars([infobar]); |
| 177 UI.runCSSAnimationOnce(infobar.element, 'source-frame-infobar-animation'); | 167 UI.runCSSAnimationOnce(infobar.element, 'source-frame-infobar-animation'); |
| 178 } | 168 } |
| 179 }; | 169 }; |
| 180 | 170 |
| 181 Sources.WorkspaceMappingTip._infobarSymbol = Symbol('infobar'); | 171 Sources.WorkspaceMappingTip._infobarSymbol = Symbol('infobar'); |
| OLD | NEW |