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

Unified Diff: third_party/WebKit/Source/devtools/front_end/network/RequestPreviewView.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/network/RequestPreviewView.js
diff --git a/third_party/WebKit/Source/devtools/front_end/network/RequestPreviewView.js b/third_party/WebKit/Source/devtools/front_end/network/RequestPreviewView.js
index 3c7ff1cfc46a2a1ebe178b5694db2686c6163283..c1a3b2a82af17ef20d165365855852ccb5093c53 100644
--- a/third_party/WebKit/Source/devtools/front_end/network/RequestPreviewView.js
+++ b/third_party/WebKit/Source/devtools/front_end/network/RequestPreviewView.js
@@ -27,173 +27,164 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/**
- * @constructor
- * @extends {WebInspector.RequestContentView}
- * @param {!WebInspector.NetworkRequest} request
- * @param {!WebInspector.Widget} responseView
+ * @unrestricted
*/
-WebInspector.RequestPreviewView = function(request, responseView)
-{
- WebInspector.RequestContentView.call(this, request);
+WebInspector.RequestPreviewView = class extends WebInspector.RequestContentView {
+ /**
+ * @param {!WebInspector.NetworkRequest} request
+ * @param {!WebInspector.Widget} responseView
+ */
+ constructor(request, responseView) {
+ super(request);
this._responseView = responseView;
/** @type {?WebInspector.Widget} */
this._previewView = null;
-};
-
-WebInspector.RequestPreviewView.prototype = {
- contentLoaded: function()
- {
- if (!this.request.content && !this.request.contentError()) {
- if (!this._emptyWidget) {
- this._emptyWidget = this._createEmptyWidget();
- this._emptyWidget.show(this.element);
- this._previewView = this._emptyWidget;
- }
- return;
- }
- if (this._emptyWidget) {
- this._emptyWidget.detach();
- delete this._emptyWidget;
- this._previewView = null;
- }
-
- if (!this._previewView)
- this._createPreviewView(handlePreviewView.bind(this));
- else
- this._previewView.show(this.element);
-
- /**
- * @param {!WebInspector.Widget} view
- * @this {WebInspector.RequestPreviewView}
- */
- function handlePreviewView(view)
- {
- this._previewView = view;
- view.show(this.element);
- if (view instanceof WebInspector.SimpleView) {
- var toolbar = new WebInspector.Toolbar("network-item-preview-toolbar", this.element);
- for (var item of /** @type {!WebInspector.SimpleView} */ (this._previewView).syncToolbarItems())
- toolbar.appendToolbarItem(item);
- }
- this._previewViewHandledForTest(view);
- }
- },
+ }
+
+ /**
+ * @override
+ */
+ contentLoaded() {
+ if (!this.request.content && !this.request.contentError()) {
+ if (!this._emptyWidget) {
+ this._emptyWidget = this._createEmptyWidget();
+ this._emptyWidget.show(this.element);
+ this._previewView = this._emptyWidget;
+ }
+ return;
+ }
+ if (this._emptyWidget) {
+ this._emptyWidget.detach();
+ delete this._emptyWidget;
+ this._previewView = null;
+ }
+
+ if (!this._previewView)
+ this._createPreviewView(handlePreviewView.bind(this));
+ else
+ this._previewView.show(this.element);
/**
* @param {!WebInspector.Widget} view
+ * @this {WebInspector.RequestPreviewView}
*/
- _previewViewHandledForTest: function(view) { },
-
- /**
- * @return {!WebInspector.EmptyWidget}
- */
- _createEmptyWidget: function()
- {
- return this._createMessageView(WebInspector.UIString("This request has no preview available."));
- },
-
- /**
- * @param {string} message
- * @return {!WebInspector.EmptyWidget}
- */
- _createMessageView: function(message)
- {
- return new WebInspector.EmptyWidget(message);
- },
-
- /**
- * @return {string}
- */
- _requestContent: function()
- {
- var content = this.request.content;
- return this.request.contentEncoded ? window.atob(content || "") : (content || "");
- },
-
- /**
- * @param {?WebInspector.ParsedJSON} parsedJSON
- * @return {?WebInspector.SearchableView}
- */
- _jsonView: function(parsedJSON)
- {
- if (!parsedJSON || typeof parsedJSON.data !== "object")
- return null;
- return WebInspector.JSONView.createSearchableView(/** @type {!WebInspector.ParsedJSON} */ (parsedJSON));
- },
-
- /**
- * @return {?WebInspector.SearchableView}
- */
- _xmlView: function()
- {
- var parsedXML = WebInspector.XMLView.parseXML(this._requestContent(), this.request.mimeType);
- return parsedXML ? WebInspector.XMLView.createSearchableView(parsedXML) : null;
- },
-
- /**
- * @return {?WebInspector.RequestHTMLView}
- */
- _htmlErrorPreview: function()
- {
- var whitelist = ["text/html", "text/plain", "application/xhtml+xml"];
- if (whitelist.indexOf(this.request.mimeType) === -1)
- return null;
-
- var dataURL = this.request.asDataURL();
- if (dataURL === null)
- return null;
-
- return new WebInspector.RequestHTMLView(this.request, dataURL);
- },
+ function handlePreviewView(view) {
+ this._previewView = view;
+ view.show(this.element);
+ if (view instanceof WebInspector.SimpleView) {
+ var toolbar = new WebInspector.Toolbar('network-item-preview-toolbar', this.element);
+ for (var item of /** @type {!WebInspector.SimpleView} */ (this._previewView).syncToolbarItems())
+ toolbar.appendToolbarItem(item);
+ }
+ this._previewViewHandledForTest(view);
+ }
+ }
+
+ /**
+ * @param {!WebInspector.Widget} view
+ */
+ _previewViewHandledForTest(view) {
+ }
+
+ /**
+ * @return {!WebInspector.EmptyWidget}
+ */
+ _createEmptyWidget() {
+ return this._createMessageView(WebInspector.UIString('This request has no preview available.'));
+ }
+
+ /**
+ * @param {string} message
+ * @return {!WebInspector.EmptyWidget}
+ */
+ _createMessageView(message) {
+ return new WebInspector.EmptyWidget(message);
+ }
+
+ /**
+ * @return {string}
+ */
+ _requestContent() {
+ var content = this.request.content;
+ return this.request.contentEncoded ? window.atob(content || '') : (content || '');
+ }
+
+ /**
+ * @param {?WebInspector.ParsedJSON} parsedJSON
+ * @return {?WebInspector.SearchableView}
+ */
+ _jsonView(parsedJSON) {
+ if (!parsedJSON || typeof parsedJSON.data !== 'object')
+ return null;
+ return WebInspector.JSONView.createSearchableView(/** @type {!WebInspector.ParsedJSON} */ (parsedJSON));
+ }
+
+ /**
+ * @return {?WebInspector.SearchableView}
+ */
+ _xmlView() {
+ var parsedXML = WebInspector.XMLView.parseXML(this._requestContent(), this.request.mimeType);
+ return parsedXML ? WebInspector.XMLView.createSearchableView(parsedXML) : null;
+ }
+
+ /**
+ * @return {?WebInspector.RequestHTMLView}
+ */
+ _htmlErrorPreview() {
+ var whitelist = ['text/html', 'text/plain', 'application/xhtml+xml'];
+ if (whitelist.indexOf(this.request.mimeType) === -1)
+ return null;
+
+ var dataURL = this.request.asDataURL();
+ if (dataURL === null)
+ return null;
+
+ return new WebInspector.RequestHTMLView(this.request, dataURL);
+ }
+
+ /**
+ * @param {function(!WebInspector.Widget)} callback
+ */
+ _createPreviewView(callback) {
+ if (this.request.contentError()) {
+ callback(this._createMessageView(WebInspector.UIString('Failed to load response data')));
+ return;
+ }
+
+ var xmlView = this._xmlView();
+ if (xmlView) {
+ callback(xmlView);
+ return;
+ }
+
+ WebInspector.JSONView.parseJSON(this._requestContent()).then(chooseView.bind(this)).then(callback);
/**
- * @param {function(!WebInspector.Widget)} callback
+ * @this {WebInspector.RequestPreviewView}
+ * @param {?WebInspector.ParsedJSON} jsonData
+ * @return {!WebInspector.Widget}
*/
- _createPreviewView: function(callback)
- {
- if (this.request.contentError()) {
- callback(this._createMessageView(WebInspector.UIString("Failed to load response data")));
- return;
- }
-
- var xmlView = this._xmlView();
- if (xmlView) {
- callback(xmlView);
- return;
- }
-
- WebInspector.JSONView.parseJSON(this._requestContent()).then(chooseView.bind(this)).then(callback);
-
- /**
- * @this {WebInspector.RequestPreviewView}
- * @param {?WebInspector.ParsedJSON} jsonData
- * @return {!WebInspector.Widget}
- */
- function chooseView(jsonData)
- {
- if (jsonData) {
- var jsonView = this._jsonView(jsonData);
- if (jsonView)
- return jsonView;
- }
-
- if (this.request.hasErrorStatusCode() || this.request.resourceType() === WebInspector.resourceTypes.XHR) {
- var htmlErrorPreview = this._htmlErrorPreview();
- if (htmlErrorPreview)
- return htmlErrorPreview;
- }
-
- if (this._responseView.sourceView)
- return this._responseView.sourceView;
-
- if (this.request.resourceType() === WebInspector.resourceTypes.Other)
- return this._createEmptyWidget();
-
- return WebInspector.RequestView.nonSourceViewForRequest(this.request);
- }
- },
-
- __proto__: WebInspector.RequestContentView.prototype
+ function chooseView(jsonData) {
+ if (jsonData) {
+ var jsonView = this._jsonView(jsonData);
+ if (jsonView)
+ return jsonView;
+ }
+
+ if (this.request.hasErrorStatusCode() || this.request.resourceType() === WebInspector.resourceTypes.XHR) {
+ var htmlErrorPreview = this._htmlErrorPreview();
+ if (htmlErrorPreview)
+ return htmlErrorPreview;
+ }
+
+ if (this._responseView.sourceView)
+ return this._responseView.sourceView;
+
+ if (this.request.resourceType() === WebInspector.resourceTypes.Other)
+ return this._createEmptyWidget();
+
+ return WebInspector.RequestView.nonSourceViewForRequest(this.request);
+ }
+ }
};

Powered by Google App Engine
This is Rietveld 408576698