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
3 // found in the LICENSE file.
7 * @extends {WebInspector.App}
8 * @implements {WebInspector.TargetManager.Observer}
10 WebInspector.ScreencastApp = function()
12 WebInspector.App.call(this);
14 var lastScreencastState = WebInspector.settings.createSetting("lastScreencastState", "left");
15 this._currentScreencastState = WebInspector.settings.createSetting("currentScreencastState", "disabled");
16 this._toggleScreencastButton = new WebInspector.StatusBarStatesSettingButton(
17 "screencast-status-bar-item",
18 ["disabled", "left", "top"],
19 [WebInspector.UIString("Disable screencast."), WebInspector.UIString("Switch to portrait screencast."), WebInspector.UIString("Switch to landscape screencast.")],
20 this._currentScreencastState.get(),
21 this._currentScreencastState,
23 this._onStatusBarButtonStateChanged.bind(this));
24 WebInspector.targetManager.observeTargets(this);
27 WebInspector.ScreencastApp.prototype = {
30 var rootView = new WebInspector.RootView();
32 this._rootSplitView = new WebInspector.SplitView(false, true, "InspectorView.screencastSplitViewState", 300, 300);
33 this._rootSplitView.show(rootView.element);
34 this._rootSplitView.hideMain();
36 WebInspector.inspectorView.show(this._rootSplitView.sidebarElement());
37 WebInspector.inspectorView.showInitialPanel();
38 rootView.attachToBody();
42 * @param {!WebInspector.Target} target
44 targetAdded: function(target)
48 this._target = target;
49 if (target.hasCapability(WebInspector.Target.Capabilities.CanScreencast)) {
50 this._screencastView = new WebInspector.ScreencastView(target);
51 this._screencastView.show(this._rootSplitView.mainElement());
52 this._screencastView.initialize();
53 this._onStatusBarButtonStateChanged(this._currentScreencastState.get());
55 this._onStatusBarButtonStateChanged("disabled");
56 this._toggleScreencastButton.setEnabled(false);
61 * @param {!WebInspector.Target} target
63 targetRemoved: function(target)
65 if (this._target === target) {
67 if (!this._screencastView)
69 this._onStatusBarButtonStateChanged("disabled");
70 this._toggleScreencastButton.setEnabled(false);
71 this._screencastView.detach();
72 delete this._screencastView;
77 * @param {string} state
79 _onStatusBarButtonStateChanged: function(state)
81 if (!this._rootSplitView)
83 if (state === "disabled") {
84 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement(), false);
85 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResizerElement(), false);
86 this._rootSplitView.hideMain();
90 this._rootSplitView.setVertical(state === "left");
91 this._rootSplitView.setSecondIsSidebar(true);
92 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement(), true);
93 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResizerElement(), state === "top");
94 this._rootSplitView.showBoth();
97 __proto__: WebInspector.App.prototype
102 * @implements {WebInspector.StatusBarItem.Provider}
104 WebInspector.ScreencastApp.StatusBarButtonProvider = function()
108 WebInspector.ScreencastApp.StatusBarButtonProvider.prototype = {
110 * @return {?WebInspector.StatusBarItem}
114 if (!(WebInspector.app instanceof WebInspector.ScreencastApp))
116 return /** @type {!WebInspector.ScreencastApp} */ (WebInspector.app)._toggleScreencastButton;