Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * * 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 535 if (!resources[contentProvider.contentURL()]) | 535 if (!resources[contentProvider.contentURL()]) |
| 536 resources[contentProvider.contentURL()] = this._makeResource(con tentProvider); | 536 resources[contentProvider.contentURL()] = this._makeResource(con tentProvider); |
| 537 } | 537 } |
| 538 var uiSourceCodes = WebInspector.workspace.uiSourceCodesForProjectType(W ebInspector.projectTypes.Network); | 538 var uiSourceCodes = WebInspector.workspace.uiSourceCodesForProjectType(W ebInspector.projectTypes.Network); |
| 539 uiSourceCodes = uiSourceCodes.concat(WebInspector.workspace.uiSourceCode sForProjectType(WebInspector.projectTypes.ContentScripts)); | 539 uiSourceCodes = uiSourceCodes.concat(WebInspector.workspace.uiSourceCode sForProjectType(WebInspector.projectTypes.ContentScripts)); |
| 540 uiSourceCodes.forEach(pushResourceData.bind(this)); | 540 uiSourceCodes.forEach(pushResourceData.bind(this)); |
| 541 WebInspector.resourceTreeModel.forAllResources(pushResourceData.bind(thi s)); | 541 WebInspector.resourceTreeModel.forAllResources(pushResourceData.bind(thi s)); |
| 542 return Object.values(resources); | 542 return Object.values(resources); |
| 543 }, | 543 }, |
| 544 | 544 |
| 545 /** | 545 _onGetRequestContent: function(message, port) |
| 546 * @param {!WebInspector.ContentProvider} contentProvider | |
| 547 * @param {!Object} message | |
| 548 * @param {!MessagePort} port | |
| 549 */ | |
| 550 _getResourceContent: function(contentProvider, message, port) | |
| 551 { | 546 { |
| 547 var request = this._requestById(message.id); | |
| 548 if (!request) | |
| 549 return this._status.E_NOTFOUND(message.id); | |
| 550 | |
| 552 /** | 551 /** |
| 553 * @param {?string} content | 552 * @param {?string} content |
| 554 * @this {WebInspector.ExtensionServer} | 553 * @this {WebInspector.ExtensionServer} |
| 555 */ | 554 */ |
| 556 function onContentAvailable(content) | 555 function onContentAvailable(content) |
| 557 { | 556 { |
| 558 var response = { | 557 var response = { |
| 559 encoding: (content === null) || contentProvider.contentType().is TextType() ? "" : "base64", | 558 encoding: content && request.contentEncoded ? "base64" : "", |
|
vsevik
2014/10/22 14:25:07
We could use contentEncoded for both of them
eustas
2014/10/23 13:40:55
Done.
| |
| 560 content: content | 559 content: content |
| 561 }; | 560 }; |
| 562 this._dispatchCallback(message.requestId, port, response); | 561 this._dispatchCallback(message.requestId, port, response); |
| 563 } | 562 } |
| 564 | 563 |
| 565 contentProvider.requestContent(onContentAvailable.bind(this)); | 564 request.requestContent(onContentAvailable.bind(this)); |
| 566 }, | |
| 567 | |
| 568 _onGetRequestContent: function(message, port) | |
| 569 { | |
| 570 var request = this._requestById(message.id); | |
| 571 if (!request) | |
| 572 return this._status.E_NOTFOUND(message.id); | |
| 573 this._getResourceContent(request, message, port); | |
| 574 }, | 565 }, |
| 575 | 566 |
| 576 _onGetResourceContent: function(message, port) | 567 _onGetResourceContent: function(message, port) |
| 577 { | 568 { |
| 578 var url = /** @type {string} */ (message.url); | 569 var url = /** @type {string} */ (message.url); |
| 579 var contentProvider = WebInspector.workspace.uiSourceCodeForOriginURL(ur l) || WebInspector.resourceForURL(url); | 570 var contentProvider = WebInspector.workspace.uiSourceCodeForOriginURL(ur l) || WebInspector.resourceForURL(url); |
| 580 if (!contentProvider) | 571 if (!contentProvider) |
| 581 return this._status.E_NOTFOUND(url); | 572 return this._status.E_NOTFOUND(url); |
| 582 this._getResourceContent(contentProvider, message, port); | 573 |
| 574 /** | |
| 575 * @param {?string} content | |
| 576 * @this {WebInspector.ExtensionServer} | |
| 577 */ | |
| 578 function onContentAvailable(content) | |
| 579 { | |
| 580 var response = { | |
| 581 encoding: (content === null) || contentProvider.contentType().is TextType() ? "" : "base64", | |
| 582 content: content | |
| 583 }; | |
| 584 this._dispatchCallback(message.requestId, port, response); | |
| 585 } | |
| 586 | |
| 587 contentProvider.requestContent(onContentAvailable.bind(this)); | |
| 583 }, | 588 }, |
| 584 | 589 |
| 585 _onSetResourceContent: function(message, port) | 590 _onSetResourceContent: function(message, port) |
| 586 { | 591 { |
| 587 /** | 592 /** |
| 588 * @param {?Protocol.Error} error | 593 * @param {?Protocol.Error} error |
| 589 * @this {WebInspector.ExtensionServer} | 594 * @this {WebInspector.ExtensionServer} |
| 590 */ | 595 */ |
| 591 function callbackWrapper(error) | 596 function callbackWrapper(error) |
| 592 { | 597 { |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1094 { | 1099 { |
| 1095 if (WebInspector.extensionServer._overridePlatformExtensionAPIForTest) | 1100 if (WebInspector.extensionServer._overridePlatformExtensionAPIForTest) |
| 1096 window.buildPlatformExtensionAPI = WebInspector.extensionServer._overrid ePlatformExtensionAPIForTest; | 1101 window.buildPlatformExtensionAPI = WebInspector.extensionServer._overrid ePlatformExtensionAPIForTest; |
| 1097 WebInspector.extensionServer._addExtensions(extensions); | 1102 WebInspector.extensionServer._addExtensions(extensions); |
| 1098 } | 1103 } |
| 1099 | 1104 |
| 1100 WebInspector.setInspectedTabId = function(tabId) | 1105 WebInspector.setInspectedTabId = function(tabId) |
| 1101 { | 1106 { |
| 1102 WebInspector._inspectedTabId = tabId; | 1107 WebInspector._inspectedTabId = tabId; |
| 1103 } | 1108 } |
| OLD | NEW |