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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 11 matching lines...) Expand all
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 /** 29 /**
30 * @unrestricted 30 * @unrestricted
31 */ 31 */
32 WebInspector.SourcesNavigatorView = class extends WebInspector.NavigatorView { 32 Sources.SourcesNavigatorView = class extends Sources.NavigatorView {
33 constructor() { 33 constructor() {
34 super(); 34 super();
35 WebInspector.targetManager.addEventListener( 35 SDK.targetManager.addEventListener(
36 WebInspector.TargetManager.Events.InspectedURLChanged, this._inspectedUR LChanged, this); 36 SDK.TargetManager.Events.InspectedURLChanged, this._inspectedURLChanged, this);
37 } 37 }
38 38
39 /** 39 /**
40 * @override 40 * @override
41 * @param {!WebInspector.UISourceCode} uiSourceCode 41 * @param {!Workspace.UISourceCode} uiSourceCode
42 * @return {boolean} 42 * @return {boolean}
43 */ 43 */
44 accept(uiSourceCode) { 44 accept(uiSourceCode) {
45 if (!super.accept(uiSourceCode)) 45 if (!super.accept(uiSourceCode))
46 return false; 46 return false;
47 return uiSourceCode.project().type() !== WebInspector.projectTypes.ContentSc ripts && 47 return uiSourceCode.project().type() !== Workspace.projectTypes.ContentScrip ts &&
48 uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets; 48 uiSourceCode.project().type() !== Workspace.projectTypes.Snippets;
49 } 49 }
50 50
51 /** 51 /**
52 * @param {!WebInspector.Event} event 52 * @param {!Common.Event} event
53 */ 53 */
54 _inspectedURLChanged(event) { 54 _inspectedURLChanged(event) {
55 var mainTarget = WebInspector.targetManager.mainTarget(); 55 var mainTarget = SDK.targetManager.mainTarget();
56 if (event.data !== mainTarget) 56 if (event.data !== mainTarget)
57 return; 57 return;
58 var inspectedURL = mainTarget && mainTarget.inspectedURL(); 58 var inspectedURL = mainTarget && mainTarget.inspectedURL();
59 if (!inspectedURL) 59 if (!inspectedURL)
60 return; 60 return;
61 for (var node of this._uiSourceCodeNodes.valuesArray()) { 61 for (var node of this._uiSourceCodeNodes.valuesArray()) {
62 var uiSourceCode = node.uiSourceCode(); 62 var uiSourceCode = node.uiSourceCode();
63 if (uiSourceCode.url() === inspectedURL) 63 if (uiSourceCode.url() === inspectedURL)
64 this.revealUISourceCode(uiSourceCode, true); 64 this.revealUISourceCode(uiSourceCode, true);
65 } 65 }
66 } 66 }
67 67
68 /** 68 /**
69 * @override 69 * @override
70 * @param {!WebInspector.UISourceCode} uiSourceCode 70 * @param {!Workspace.UISourceCode} uiSourceCode
71 */ 71 */
72 uiSourceCodeAdded(uiSourceCode) { 72 uiSourceCodeAdded(uiSourceCode) {
73 var mainTarget = WebInspector.targetManager.mainTarget(); 73 var mainTarget = SDK.targetManager.mainTarget();
74 var inspectedURL = mainTarget && mainTarget.inspectedURL(); 74 var inspectedURL = mainTarget && mainTarget.inspectedURL();
75 if (!inspectedURL) 75 if (!inspectedURL)
76 return; 76 return;
77 if (uiSourceCode.url() === inspectedURL) 77 if (uiSourceCode.url() === inspectedURL)
78 this.revealUISourceCode(uiSourceCode, true); 78 this.revealUISourceCode(uiSourceCode, true);
79 } 79 }
80 80
81 /** 81 /**
82 * @override 82 * @override
83 * @param {!Event} event 83 * @param {!Event} event
84 */ 84 */
85 handleContextMenu(event) { 85 handleContextMenu(event) {
86 var contextMenu = new WebInspector.ContextMenu(event); 86 var contextMenu = new UI.ContextMenu(event);
87 WebInspector.NavigatorView.appendAddFolderItem(contextMenu); 87 Sources.NavigatorView.appendAddFolderItem(contextMenu);
88 contextMenu.show(); 88 contextMenu.show();
89 } 89 }
90 }; 90 };
91 91
92 /** 92 /**
93 * @unrestricted 93 * @unrestricted
94 */ 94 */
95 WebInspector.NetworkNavigatorView = class extends WebInspector.NavigatorView { 95 Sources.NetworkNavigatorView = class extends Sources.NavigatorView {
96 constructor() { 96 constructor() {
97 super(); 97 super();
98 WebInspector.targetManager.addEventListener( 98 SDK.targetManager.addEventListener(
99 WebInspector.TargetManager.Events.InspectedURLChanged, this._inspectedUR LChanged, this); 99 SDK.TargetManager.Events.InspectedURLChanged, this._inspectedURLChanged, this);
100 } 100 }
101 101
102 /** 102 /**
103 * @override 103 * @override
104 * @param {!WebInspector.UISourceCode} uiSourceCode 104 * @param {!Workspace.UISourceCode} uiSourceCode
105 * @return {boolean} 105 * @return {boolean}
106 */ 106 */
107 accept(uiSourceCode) { 107 accept(uiSourceCode) {
108 return uiSourceCode.project().type() === WebInspector.projectTypes.Network; 108 return uiSourceCode.project().type() === Workspace.projectTypes.Network;
109 } 109 }
110 110
111 /** 111 /**
112 * @param {!WebInspector.Event} event 112 * @param {!Common.Event} event
113 */ 113 */
114 _inspectedURLChanged(event) { 114 _inspectedURLChanged(event) {
115 var mainTarget = WebInspector.targetManager.mainTarget(); 115 var mainTarget = SDK.targetManager.mainTarget();
116 if (event.data !== mainTarget) 116 if (event.data !== mainTarget)
117 return; 117 return;
118 var inspectedURL = mainTarget && mainTarget.inspectedURL(); 118 var inspectedURL = mainTarget && mainTarget.inspectedURL();
119 if (!inspectedURL) 119 if (!inspectedURL)
120 return; 120 return;
121 for (var node of this._uiSourceCodeNodes.valuesArray()) { 121 for (var node of this._uiSourceCodeNodes.valuesArray()) {
122 var uiSourceCode = node.uiSourceCode(); 122 var uiSourceCode = node.uiSourceCode();
123 if (uiSourceCode.url() === inspectedURL) 123 if (uiSourceCode.url() === inspectedURL)
124 this.revealUISourceCode(uiSourceCode, true); 124 this.revealUISourceCode(uiSourceCode, true);
125 } 125 }
126 } 126 }
127 127
128 /** 128 /**
129 * @override 129 * @override
130 * @param {!WebInspector.UISourceCode} uiSourceCode 130 * @param {!Workspace.UISourceCode} uiSourceCode
131 */ 131 */
132 uiSourceCodeAdded(uiSourceCode) { 132 uiSourceCodeAdded(uiSourceCode) {
133 var mainTarget = WebInspector.targetManager.mainTarget(); 133 var mainTarget = SDK.targetManager.mainTarget();
134 var inspectedURL = mainTarget && mainTarget.inspectedURL(); 134 var inspectedURL = mainTarget && mainTarget.inspectedURL();
135 if (!inspectedURL) 135 if (!inspectedURL)
136 return; 136 return;
137 if (uiSourceCode.url() === inspectedURL) 137 if (uiSourceCode.url() === inspectedURL)
138 this.revealUISourceCode(uiSourceCode, true); 138 this.revealUISourceCode(uiSourceCode, true);
139 } 139 }
140 }; 140 };
141 141
142 /** 142 /**
143 * @unrestricted 143 * @unrestricted
144 */ 144 */
145 WebInspector.FilesNavigatorView = class extends WebInspector.NavigatorView { 145 Sources.FilesNavigatorView = class extends Sources.NavigatorView {
146 constructor() { 146 constructor() {
147 super(); 147 super();
148 var toolbar = new WebInspector.Toolbar('navigator-toolbar'); 148 var toolbar = new UI.Toolbar('navigator-toolbar');
149 var title = WebInspector.UIString('Add folder to workspace'); 149 var title = Common.UIString('Add folder to workspace');
150 var addButton = new WebInspector.ToolbarButton(title, 'largeicon-add', title ); 150 var addButton = new UI.ToolbarButton(title, 'largeicon-add', title);
151 addButton.addEventListener('click', () => 151 addButton.addEventListener('click', () =>
152 WebInspector.isolatedFileSystemManager.addFileSystem()); 152 Workspace.isolatedFileSystemManager.addFileSystem());
153 toolbar.appendToolbarItem(addButton); 153 toolbar.appendToolbarItem(addButton);
154 this.element.insertBefore(toolbar.element, this.element.firstChild); 154 this.element.insertBefore(toolbar.element, this.element.firstChild);
155 } 155 }
156 156
157 /** 157 /**
158 * @override 158 * @override
159 * @param {!WebInspector.UISourceCode} uiSourceCode 159 * @param {!Workspace.UISourceCode} uiSourceCode
160 * @return {boolean} 160 * @return {boolean}
161 */ 161 */
162 accept(uiSourceCode) { 162 accept(uiSourceCode) {
163 return uiSourceCode.project().type() === WebInspector.projectTypes.FileSyste m; 163 return uiSourceCode.project().type() === Workspace.projectTypes.FileSystem;
164 } 164 }
165 165
166 /** 166 /**
167 * @override 167 * @override
168 * @param {!Event} event 168 * @param {!Event} event
169 */ 169 */
170 handleContextMenu(event) { 170 handleContextMenu(event) {
171 var contextMenu = new WebInspector.ContextMenu(event); 171 var contextMenu = new UI.ContextMenu(event);
172 WebInspector.NavigatorView.appendAddFolderItem(contextMenu); 172 Sources.NavigatorView.appendAddFolderItem(contextMenu);
173 contextMenu.show(); 173 contextMenu.show();
174 } 174 }
175 }; 175 };
176 176
177 /** 177 /**
178 * @unrestricted 178 * @unrestricted
179 */ 179 */
180 WebInspector.ContentScriptsNavigatorView = class extends WebInspector.NavigatorV iew { 180 Sources.ContentScriptsNavigatorView = class extends Sources.NavigatorView {
181 constructor() { 181 constructor() {
182 super(); 182 super();
183 } 183 }
184 184
185 /** 185 /**
186 * @override 186 * @override
187 * @param {!WebInspector.UISourceCode} uiSourceCode 187 * @param {!Workspace.UISourceCode} uiSourceCode
188 * @return {boolean} 188 * @return {boolean}
189 */ 189 */
190 accept(uiSourceCode) { 190 accept(uiSourceCode) {
191 return uiSourceCode.project().type() === WebInspector.projectTypes.ContentSc ripts; 191 return uiSourceCode.project().type() === Workspace.projectTypes.ContentScrip ts;
192 } 192 }
193 }; 193 };
194 194
195 /** 195 /**
196 * @unrestricted 196 * @unrestricted
197 */ 197 */
198 WebInspector.SnippetsNavigatorView = class extends WebInspector.NavigatorView { 198 Sources.SnippetsNavigatorView = class extends Sources.NavigatorView {
199 constructor() { 199 constructor() {
200 super(); 200 super();
201 var toolbar = new WebInspector.Toolbar('navigator-toolbar'); 201 var toolbar = new UI.Toolbar('navigator-toolbar');
202 var newButton = new WebInspector.ToolbarButton('', 'largeicon-add', WebInspe ctor.UIString('New Snippet')); 202 var newButton = new UI.ToolbarButton('', 'largeicon-add', Common.UIString('N ew Snippet'));
203 newButton.addEventListener('click', this._handleCreateSnippet.bind(this)); 203 newButton.addEventListener('click', this._handleCreateSnippet.bind(this));
204 toolbar.appendToolbarItem(newButton); 204 toolbar.appendToolbarItem(newButton);
205 this.element.insertBefore(toolbar.element, this.element.firstChild); 205 this.element.insertBefore(toolbar.element, this.element.firstChild);
206 } 206 }
207 207
208 /** 208 /**
209 * @override 209 * @override
210 * @param {!WebInspector.UISourceCode} uiSourceCode 210 * @param {!Workspace.UISourceCode} uiSourceCode
211 * @return {boolean} 211 * @return {boolean}
212 */ 212 */
213 accept(uiSourceCode) { 213 accept(uiSourceCode) {
214 return uiSourceCode.project().type() === WebInspector.projectTypes.Snippets; 214 return uiSourceCode.project().type() === Workspace.projectTypes.Snippets;
215 } 215 }
216 216
217 /** 217 /**
218 * @override 218 * @override
219 * @param {!Event} event 219 * @param {!Event} event
220 */ 220 */
221 handleContextMenu(event) { 221 handleContextMenu(event) {
222 var contextMenu = new WebInspector.ContextMenu(event); 222 var contextMenu = new UI.ContextMenu(event);
223 contextMenu.appendItem(WebInspector.UIString('New'), this._handleCreateSnipp et.bind(this)); 223 contextMenu.appendItem(Common.UIString('New'), this._handleCreateSnippet.bin d(this));
224 contextMenu.show(); 224 contextMenu.show();
225 } 225 }
226 226
227 /** 227 /**
228 * @override 228 * @override
229 * @param {!Event} event 229 * @param {!Event} event
230 * @param {!WebInspector.UISourceCode} uiSourceCode 230 * @param {!Workspace.UISourceCode} uiSourceCode
231 */ 231 */
232 handleFileContextMenu(event, uiSourceCode) { 232 handleFileContextMenu(event, uiSourceCode) {
233 var contextMenu = new WebInspector.ContextMenu(event); 233 var contextMenu = new UI.ContextMenu(event);
234 contextMenu.appendItem(WebInspector.UIString('Run'), this._handleEvaluateSni ppet.bind(this, uiSourceCode)); 234 contextMenu.appendItem(Common.UIString('Run'), this._handleEvaluateSnippet.b ind(this, uiSourceCode));
235 contextMenu.appendItem(WebInspector.UIString('Rename'), this.rename.bind(thi s, uiSourceCode)); 235 contextMenu.appendItem(Common.UIString('Rename'), this.rename.bind(this, uiS ourceCode));
236 contextMenu.appendItem(WebInspector.UIString('Remove'), this._handleRemoveSn ippet.bind(this, uiSourceCode)); 236 contextMenu.appendItem(Common.UIString('Remove'), this._handleRemoveSnippet. bind(this, uiSourceCode));
237 contextMenu.appendSeparator(); 237 contextMenu.appendSeparator();
238 contextMenu.appendItem(WebInspector.UIString('New'), this._handleCreateSnipp et.bind(this)); 238 contextMenu.appendItem(Common.UIString('New'), this._handleCreateSnippet.bin d(this));
239 contextMenu.appendSeparator(); 239 contextMenu.appendSeparator();
240 contextMenu.appendItem(WebInspector.UIString('Save as...'), this._handleSave As.bind(this, uiSourceCode)); 240 contextMenu.appendItem(Common.UIString('Save as...'), this._handleSaveAs.bin d(this, uiSourceCode));
241 contextMenu.show(); 241 contextMenu.show();
242 } 242 }
243 243
244 /** 244 /**
245 * @param {!WebInspector.UISourceCode} uiSourceCode 245 * @param {!Workspace.UISourceCode} uiSourceCode
246 */ 246 */
247 _handleEvaluateSnippet(uiSourceCode) { 247 _handleEvaluateSnippet(uiSourceCode) {
248 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon text); 248 var executionContext = UI.context.flavor(SDK.ExecutionContext);
249 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets || !executionContext) 249 if (uiSourceCode.project().type() !== Workspace.projectTypes.Snippets || !ex ecutionContext)
250 return; 250 return;
251 WebInspector.scriptSnippetModel.evaluateScriptSnippet(executionContext, uiSo urceCode); 251 Snippets.scriptSnippetModel.evaluateScriptSnippet(executionContext, uiSource Code);
252 } 252 }
253 253
254 /** 254 /**
255 * @param {!WebInspector.UISourceCode} uiSourceCode 255 * @param {!Workspace.UISourceCode} uiSourceCode
256 */ 256 */
257 _handleSaveAs(uiSourceCode) { 257 _handleSaveAs(uiSourceCode) {
258 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets) 258 if (uiSourceCode.project().type() !== Workspace.projectTypes.Snippets)
259 return; 259 return;
260 uiSourceCode.saveAs(); 260 uiSourceCode.saveAs();
261 } 261 }
262 262
263 /** 263 /**
264 * @param {!WebInspector.UISourceCode} uiSourceCode 264 * @param {!Workspace.UISourceCode} uiSourceCode
265 */ 265 */
266 _handleRemoveSnippet(uiSourceCode) { 266 _handleRemoveSnippet(uiSourceCode) {
267 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets) 267 if (uiSourceCode.project().type() !== Workspace.projectTypes.Snippets)
268 return; 268 return;
269 uiSourceCode.remove(); 269 uiSourceCode.remove();
270 } 270 }
271 271
272 _handleCreateSnippet() { 272 _handleCreateSnippet() {
273 this.create(WebInspector.scriptSnippetModel.project(), ''); 273 this.create(Snippets.scriptSnippetModel.project(), '');
274 } 274 }
275 275
276 /** 276 /**
277 * @override 277 * @override
278 */ 278 */
279 sourceDeleted(uiSourceCode) { 279 sourceDeleted(uiSourceCode) {
280 this._handleRemoveSnippet(uiSourceCode); 280 this._handleRemoveSnippet(uiSourceCode);
281 } 281 }
282 }; 282 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698