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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/AppManifestView.js

Issue 2782773002: [DevTools] Remove SDKModels' fromTarget methods (Closed)
Patch Set: addressed review comments Created 3 years, 8 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 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 * @implements {SDK.TargetManager.Observer} 5 * @implements {SDK.SDKModelObserver<!SDK.ResourceTreeModel>}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 Resources.AppManifestView = class extends UI.VBox { 8 Resources.AppManifestView = class extends UI.VBox {
9 constructor() { 9 constructor() {
10 super(true); 10 super(true);
11 this.registerRequiredCSS('resources/appManifestView.css'); 11 this.registerRequiredCSS('resources/appManifestView.css');
12 12
13 this._emptyView = new UI.EmptyWidget(Common.UIString('No manifest detected') ); 13 this._emptyView = new UI.EmptyWidget(Common.UIString('No manifest detected') );
14 var p = this._emptyView.appendParagraph(); 14 var p = this._emptyView.appendParagraph();
15 var linkElement = UI.createExternalLink('https://developers.google.com/web/f undamentals/engage-and-retain/web-app-manifest/?utm_source=devtools', 15 var linkElement = UI.createExternalLink('https://developers.google.com/web/f undamentals/engage-and-retain/web-app-manifest/?utm_source=devtools',
(...skipping 28 matching lines...) Expand all
44 this._themeColorSwatch = InlineEditor.ColorSwatch.create(); 44 this._themeColorSwatch = InlineEditor.ColorSwatch.create();
45 themeColorField.appendChild(this._themeColorSwatch); 45 themeColorField.appendChild(this._themeColorSwatch);
46 46
47 var backgroundColorField = this._presentationSection.appendField(Common.UISt ring('Background color')); 47 var backgroundColorField = this._presentationSection.appendField(Common.UISt ring('Background color'));
48 this._backgroundColorSwatch = InlineEditor.ColorSwatch.create(); 48 this._backgroundColorSwatch = InlineEditor.ColorSwatch.create();
49 backgroundColorField.appendChild(this._backgroundColorSwatch); 49 backgroundColorField.appendChild(this._backgroundColorSwatch);
50 50
51 this._orientationField = this._presentationSection.appendField(Common.UIStri ng('Orientation')); 51 this._orientationField = this._presentationSection.appendField(Common.UIStri ng('Orientation'));
52 this._displayField = this._presentationSection.appendField(Common.UIString(' Display')); 52 this._displayField = this._presentationSection.appendField(Common.UIString(' Display'));
53 53
54 SDK.targetManager.observeTargets(this, SDK.Target.Capability.DOM); 54 SDK.targetManager.observeModels(SDK.ResourceTreeModel, this);
55 } 55 }
56 56
57 /** 57 /**
58 * @override 58 * @override
59 * @param {!SDK.Target} target 59 * @param {!SDK.ResourceTreeModel} resourceTreeModel
60 */ 60 */
61 targetAdded(target) { 61 modelAdded(resourceTreeModel) {
62 if (this._resourceTreeModel) 62 if (this._resourceTreeModel)
63 return; 63 return;
64 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
65 if (!resourceTreeModel)
66 return;
67 this._resourceTreeModel = resourceTreeModel; 64 this._resourceTreeModel = resourceTreeModel;
68 this._updateManifest(); 65 this._updateManifest();
69 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.MainFrameNav igated, this._updateManifest, this); 66 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.MainFrameNav igated, this._updateManifest, this);
70 } 67 }
71 68
72 /** 69 /**
73 * @override 70 * @override
74 * @param {!SDK.Target} target 71 * @param {!SDK.ResourceTreeModel} resourceTreeModel
75 */ 72 */
76 targetRemoved(target) { 73 modelRemoved(resourceTreeModel) {
77 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
78 if (!this._resourceTreeModel || this._resourceTreeModel !== resourceTreeMode l) 74 if (!this._resourceTreeModel || this._resourceTreeModel !== resourceTreeMode l)
79 return; 75 return;
80 resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.MainFrame Navigated, this._updateManifest, this); 76 resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.MainFrame Navigated, this._updateManifest, this);
81 delete this._resourceTreeModel; 77 delete this._resourceTreeModel;
82 } 78 }
83 79
84 _updateManifest() { 80 _updateManifest() {
85 this._resourceTreeModel.fetchAppManifest(this._renderManifest.bind(this)); 81 this._resourceTreeModel.fetchAppManifest(this._renderManifest.bind(this));
86 } 82 }
87 83
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 * @param {!Common.Event} event 154 * @param {!Common.Event} event
159 */ 155 */
160 _addToHomescreen(event) { 156 _addToHomescreen(event) {
161 var target = SDK.targetManager.mainTarget(); 157 var target = SDK.targetManager.mainTarget();
162 if (target && target.hasBrowserCapability()) { 158 if (target && target.hasBrowserCapability()) {
163 target.pageAgent().requestAppBanner(); 159 target.pageAgent().requestAppBanner();
164 Common.console.show(); 160 Common.console.show();
165 } 161 }
166 } 162 }
167 }; 163 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698