| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 {WebInspector.App} | 5 * @implements {Common.App} |
| 6 * @implements {WebInspector.TargetManager.Observer} | 6 * @implements {SDK.TargetManager.Observer} |
| 7 * @unrestricted | 7 * @unrestricted |
| 8 */ | 8 */ |
| 9 WebInspector.ScreencastApp = class { | 9 Screencast.ScreencastApp = class { |
| 10 constructor() { | 10 constructor() { |
| 11 this._enabledSetting = WebInspector.settings.createSetting('screencastEnable
d', true); | 11 this._enabledSetting = Common.settings.createSetting('screencastEnabled', tr
ue); |
| 12 this._toggleButton = | 12 this._toggleButton = |
| 13 new WebInspector.ToolbarToggle(WebInspector.UIString('Toggle screencast'
), 'largeicon-phone'); | 13 new UI.ToolbarToggle(Common.UIString('Toggle screencast'), 'largeicon-ph
one'); |
| 14 this._toggleButton.setToggled(this._enabledSetting.get()); | 14 this._toggleButton.setToggled(this._enabledSetting.get()); |
| 15 this._toggleButton.addEventListener('click', this._toggleButtonClicked, this
); | 15 this._toggleButton.addEventListener('click', this._toggleButtonClicked, this
); |
| 16 WebInspector.targetManager.observeTargets(this); | 16 SDK.targetManager.observeTargets(this); |
| 17 } | 17 } |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * @return {!WebInspector.ScreencastApp} | 20 * @return {!Screencast.ScreencastApp} |
| 21 */ | 21 */ |
| 22 static _instance() { | 22 static _instance() { |
| 23 if (!WebInspector.ScreencastApp._appInstance) | 23 if (!Screencast.ScreencastApp._appInstance) |
| 24 WebInspector.ScreencastApp._appInstance = new WebInspector.ScreencastApp()
; | 24 Screencast.ScreencastApp._appInstance = new Screencast.ScreencastApp(); |
| 25 return WebInspector.ScreencastApp._appInstance; | 25 return Screencast.ScreencastApp._appInstance; |
| 26 } | 26 } |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @override | 29 * @override |
| 30 * @param {!Document} document | 30 * @param {!Document} document |
| 31 */ | 31 */ |
| 32 presentUI(document) { | 32 presentUI(document) { |
| 33 var rootView = new WebInspector.RootView(); | 33 var rootView = new UI.RootView(); |
| 34 | 34 |
| 35 this._rootSplitWidget = | 35 this._rootSplitWidget = |
| 36 new WebInspector.SplitWidget(false, true, 'InspectorView.screencastSplit
ViewState', 300, 300); | 36 new UI.SplitWidget(false, true, 'InspectorView.screencastSplitViewState'
, 300, 300); |
| 37 this._rootSplitWidget.setVertical(true); | 37 this._rootSplitWidget.setVertical(true); |
| 38 this._rootSplitWidget.setSecondIsSidebar(true); | 38 this._rootSplitWidget.setSecondIsSidebar(true); |
| 39 this._rootSplitWidget.show(rootView.element); | 39 this._rootSplitWidget.show(rootView.element); |
| 40 this._rootSplitWidget.hideMain(); | 40 this._rootSplitWidget.hideMain(); |
| 41 | 41 |
| 42 this._rootSplitWidget.setSidebarWidget(WebInspector.inspectorView); | 42 this._rootSplitWidget.setSidebarWidget(UI.inspectorView); |
| 43 rootView.attachToDocument(document); | 43 rootView.attachToDocument(document); |
| 44 } | 44 } |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * @override | 47 * @override |
| 48 * @param {!WebInspector.Target} target | 48 * @param {!SDK.Target} target |
| 49 */ | 49 */ |
| 50 targetAdded(target) { | 50 targetAdded(target) { |
| 51 if (this._target) | 51 if (this._target) |
| 52 return; | 52 return; |
| 53 this._target = target; | 53 this._target = target; |
| 54 | 54 |
| 55 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target); | 55 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); |
| 56 if (resourceTreeModel) { | 56 if (resourceTreeModel) { |
| 57 this._screencastView = new WebInspector.ScreencastView(target, resourceTre
eModel); | 57 this._screencastView = new Screencast.ScreencastView(target, resourceTreeM
odel); |
| 58 this._rootSplitWidget.setMainWidget(this._screencastView); | 58 this._rootSplitWidget.setMainWidget(this._screencastView); |
| 59 this._screencastView.initialize(); | 59 this._screencastView.initialize(); |
| 60 } else { | 60 } else { |
| 61 this._toggleButton.setEnabled(false); | 61 this._toggleButton.setEnabled(false); |
| 62 } | 62 } |
| 63 this._onScreencastEnabledChanged(); | 63 this._onScreencastEnabledChanged(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * @override | 67 * @override |
| 68 * @param {!WebInspector.Target} target | 68 * @param {!SDK.Target} target |
| 69 */ | 69 */ |
| 70 targetRemoved(target) { | 70 targetRemoved(target) { |
| 71 if (this._target === target) { | 71 if (this._target === target) { |
| 72 delete this._target; | 72 delete this._target; |
| 73 if (!this._screencastView) | 73 if (!this._screencastView) |
| 74 return; | 74 return; |
| 75 this._toggleButton.setEnabled(false); | 75 this._toggleButton.setEnabled(false); |
| 76 this._screencastView.detach(); | 76 this._screencastView.detach(); |
| 77 delete this._screencastView; | 77 delete this._screencastView; |
| 78 this._onScreencastEnabledChanged(); | 78 this._onScreencastEnabledChanged(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 return; | 90 return; |
| 91 var enabled = this._enabledSetting.get() && this._screencastView; | 91 var enabled = this._enabledSetting.get() && this._screencastView; |
| 92 this._toggleButton.setToggled(enabled); | 92 this._toggleButton.setToggled(enabled); |
| 93 if (enabled) | 93 if (enabled) |
| 94 this._rootSplitWidget.showBoth(); | 94 this._rootSplitWidget.showBoth(); |
| 95 else | 95 else |
| 96 this._rootSplitWidget.hideMain(); | 96 this._rootSplitWidget.hideMain(); |
| 97 } | 97 } |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 /** @type {!WebInspector.ScreencastApp} */ | 100 /** @type {!Screencast.ScreencastApp} */ |
| 101 WebInspector.ScreencastApp._appInstance; | 101 Screencast.ScreencastApp._appInstance; |
| 102 | 102 |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * @implements {WebInspector.ToolbarItem.Provider} | 105 * @implements {UI.ToolbarItem.Provider} |
| 106 * @unrestricted | 106 * @unrestricted |
| 107 */ | 107 */ |
| 108 WebInspector.ScreencastApp.ToolbarButtonProvider = class { | 108 Screencast.ScreencastApp.ToolbarButtonProvider = class { |
| 109 /** | 109 /** |
| 110 * @override | 110 * @override |
| 111 * @return {?WebInspector.ToolbarItem} | 111 * @return {?UI.ToolbarItem} |
| 112 */ | 112 */ |
| 113 item() { | 113 item() { |
| 114 return WebInspector.ScreencastApp._instance()._toggleButton; | 114 return Screencast.ScreencastApp._instance()._toggleButton; |
| 115 } | 115 } |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * @implements {WebInspector.AppProvider} | 119 * @implements {Common.AppProvider} |
| 120 * @unrestricted | 120 * @unrestricted |
| 121 */ | 121 */ |
| 122 WebInspector.ScreencastAppProvider = class { | 122 Screencast.ScreencastAppProvider = class { |
| 123 /** | 123 /** |
| 124 * @override | 124 * @override |
| 125 * @return {!WebInspector.App} | 125 * @return {!Common.App} |
| 126 */ | 126 */ |
| 127 createApp() { | 127 createApp() { |
| 128 return WebInspector.ScreencastApp._instance(); | 128 return Screencast.ScreencastApp._instance(); |
| 129 } | 129 } |
| 130 }; | 130 }; |
| OLD | NEW |