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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/ContentProviderBasedProject.js

Issue 2889013002: DevTools: introduce uiSourceCode.mimeType() method (Closed)
Patch Set: address comments Created 3 years, 7 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 var parentPath = uiSourceCode.parentURL().replace(/^(?:https?|file)\:\/\//, ''); 102 var parentPath = uiSourceCode.parentURL().replace(/^(?:https?|file)\:\/\//, '');
103 try { 103 try {
104 parentPath = decodeURI(parentPath); 104 parentPath = decodeURI(parentPath);
105 } catch (e) { 105 } catch (e) {
106 } 106 }
107 return parentPath + '/' + uiSourceCode.displayName(true); 107 return parentPath + '/' + uiSourceCode.displayName(true);
108 } 108 }
109 109
110 /** 110 /**
111 * @override 111 * @override
112 * @param {!Workspace.UISourceCode} uiSourceCode
113 * @return {string}
114 */
115 mimeType(uiSourceCode) {
116 return /** @type {string} */ (uiSourceCode[Bindings.ContentProviderBasedProj ect._mimeType]);
117 }
118
119 /**
120 * @override
112 * @return {boolean} 121 * @return {boolean}
113 */ 122 */
114 canRename() { 123 canRename() {
115 return false; 124 return false;
116 } 125 }
117 126
118 /** 127 /**
119 * @override 128 * @override
120 * @param {!Workspace.UISourceCode} uiSourceCode 129 * @param {!Workspace.UISourceCode} uiSourceCode
121 * @param {string} newName 130 * @param {string} newName
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 * @param {!Common.Progress} progress 283 * @param {!Common.Progress} progress
275 */ 284 */
276 indexContent(progress) { 285 indexContent(progress) {
277 setImmediate(progress.done.bind(progress)); 286 setImmediate(progress.done.bind(progress));
278 } 287 }
279 288
280 /** 289 /**
281 * @param {!Workspace.UISourceCode} uiSourceCode 290 * @param {!Workspace.UISourceCode} uiSourceCode
282 * @param {!Common.ContentProvider} contentProvider 291 * @param {!Common.ContentProvider} contentProvider
283 * @param {?Workspace.UISourceCodeMetadata} metadata 292 * @param {?Workspace.UISourceCodeMetadata} metadata
293 * @param {string} mimeType
284 */ 294 */
285 addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata) { 295 addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata, mimeType) {
296 uiSourceCode[Bindings.ContentProviderBasedProject._mimeType] = mimeType;
286 this._contentProviders[uiSourceCode.url()] = contentProvider; 297 this._contentProviders[uiSourceCode.url()] = contentProvider;
287 uiSourceCode[Bindings.ContentProviderBasedProject._metadata] = metadata; 298 uiSourceCode[Bindings.ContentProviderBasedProject._metadata] = metadata;
288 this.addUISourceCode(uiSourceCode, true); 299 this.addUISourceCode(uiSourceCode, true);
289 } 300 }
290 301
291 /** 302 /**
292 * @param {string} url 303 * @param {string} url
293 * @param {!Common.ContentProvider} contentProvider 304 * @param {!Common.ContentProvider} contentProvider
305 * @param {string} mimeType
294 * @return {!Workspace.UISourceCode} 306 * @return {!Workspace.UISourceCode}
295 */ 307 */
296 addContentProvider(url, contentProvider) { 308 addContentProvider(url, contentProvider, mimeType) {
297 var uiSourceCode = this.createUISourceCode(url, contentProvider.contentType( )); 309 var uiSourceCode = this.createUISourceCode(url, contentProvider.contentType( ));
298 this.addUISourceCodeWithProvider(uiSourceCode, contentProvider, null); 310 this.addUISourceCodeWithProvider(uiSourceCode, contentProvider, null, mimeTy pe);
299 return uiSourceCode; 311 return uiSourceCode;
300 } 312 }
301 313
302 /** 314 /**
303 * @param {string} path 315 * @param {string} path
304 */ 316 */
305 removeFile(path) { 317 removeFile(path) {
306 delete this._contentProviders[path]; 318 delete this._contentProviders[path];
307 this.removeUISourceCode(path); 319 this.removeUISourceCode(path);
308 } 320 }
309 321
310 reset() { 322 reset() {
311 this._contentProviders = {}; 323 this._contentProviders = {};
312 this.removeProject(); 324 this.removeProject();
313 this.workspace().addProject(this); 325 this.workspace().addProject(this);
314 } 326 }
315 327
316 dispose() { 328 dispose() {
317 this._contentProviders = {}; 329 this._contentProviders = {};
318 this.removeProject(); 330 this.removeProject();
319 } 331 }
320 }; 332 };
321 333
322 Bindings.ContentProviderBasedProject._metadata = Symbol('ContentProviderBasedPro ject.Metadata'); 334 Bindings.ContentProviderBasedProject._metadata = Symbol('ContentProviderBasedPro ject.Metadata');
335 Bindings.ContentProviderBasedProject._mimeType = Symbol('Bindings.ContentProvide rBasedProject._mimeType');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698