Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 /** | |
| 6 * @constructor | |
| 7 */ | |
| 8 WebInspector.App = function() | |
| 9 { | |
| 10 }; | |
| 11 | |
| 12 WebInspector.App.prototype = { | |
| 13 createRootView: function() | |
| 14 { | |
| 15 }, | |
| 16 | |
| 17 createGlobalStatusBarItems: function() | |
| 18 { | |
| 19 }, | |
| 20 | |
| 21 presentUI: function() | |
| 22 { | |
| 23 WebInspector.inspectorView.showInitialPanel(); | |
| 24 | |
| 25 WebInspector.overridesSupport.applyInitialOverrides(); | |
| 26 if (WebInspector.overridesSupport.hasActiveOverrides()) | |
| 27 WebInspector.inspectorView.showViewInDrawer("emulation", true); | |
| 28 }, | |
| 29 | |
| 30 appendInspectStatusBarItem: function() | |
| 31 { | |
| 32 if (WebInspector.inspectElementModeController) | |
| 33 WebInspector.inspectorView.appendToLeftToolbar(WebInspector.inspectE lementModeController.toggleSearchButton.element); | |
| 34 }, | |
| 35 | |
| 36 appendSettingsStatusBarItem: function() | |
| 37 { | |
| 38 WebInspector.inspectorView.appendToRightToolbar(WebInspector.settingsCon troller.statusBarItem); | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 /** | |
| 43 * @type {!WebInspector.App} | |
| 44 */ | |
| 45 WebInspector.app; | |
| 46 | |
| 47 | |
| 48 /** | |
| 49 * @constructor | |
| 50 * @extends {WebInspector.App} | |
| 51 */ | |
| 52 WebInspector.SimpleApp = function() | |
| 53 { | |
| 54 WebInspector.App.call(this); | |
| 55 }; | |
| 56 | |
| 57 WebInspector.SimpleApp.prototype = { | |
| 58 createGlobalStatusBarItems: function() | |
| 59 { | |
| 60 this.appendInspectStatusBarItem(); | |
| 61 this.appendSettingsStatusBarItem(); | |
| 62 }, | |
| 63 | |
| 64 createRootView: function() | |
| 65 { | |
| 66 var rootView = new WebInspector.RootView(); | |
| 67 WebInspector.inspectorView.show(rootView.element); | |
| 68 rootView.attachToBody(); | |
| 69 }, | |
| 70 | |
| 71 __proto__: WebInspector.App.prototype | |
| 72 }; | |
| 73 | |
| 74 | |
| 75 /** | |
| 76 * @constructor | |
| 77 * @extends {WebInspector.App} | |
| 78 */ | |
| 79 WebInspector.AdvancedApp = function() | |
|
pfeldman
2014/05/28 15:12:01
These all should be different files.
| |
| 80 { | |
| 81 WebInspector.App.call(this); | |
| 82 }; | |
| 83 | |
| 84 WebInspector.AdvancedApp.prototype = { | |
| 85 createGlobalStatusBarItems: function() | |
| 86 { | |
| 87 this.appendInspectStatusBarItem(); | |
| 88 | |
| 89 if (WebInspector.experimentsSettings.responsiveDesign.isEnabled()) { | |
| 90 this._toggleResponsiveDesignButton = new WebInspector.StatusBarButto n(WebInspector.UIString("Responsive design mode."), "responsive-design-status-ba r-item"); | |
| 91 this._toggleResponsiveDesignButton.toggled = WebInspector.overridesS upport.settings.overrideDeviceMetrics.get(); | |
| 92 this._toggleResponsiveDesignButton.addEventListener("click", this._t oggleResponsiveDesign, this); | |
| 93 WebInspector.inspectorView.appendToLeftToolbar(this._toggleResponsiv eDesignButton.element); | |
| 94 WebInspector.overridesSupport.settings.overrideDeviceMetrics.addChan geListener(this._overrideDeviceMetricsChanged, this); | |
| 95 } | |
| 96 | |
| 97 this.appendSettingsStatusBarItem(); | |
| 98 WebInspector.inspectorView.appendToRightToolbar(/** @type {!Element} */ (WebInspector.dockController.element)); | |
| 99 }, | |
| 100 | |
| 101 _toggleResponsiveDesign: function() | |
| 102 { | |
| 103 WebInspector.overridesSupport.settings.overrideDeviceMetrics.set(!this._ toggleResponsiveDesignButton.toggled); | |
| 104 }, | |
| 105 | |
| 106 _overrideDeviceMetricsChanged: function() | |
| 107 { | |
| 108 this._toggleResponsiveDesignButton.toggled = WebInspector.overridesSuppo rt.settings.overrideDeviceMetrics.get(); | |
|
pfeldman
2014/05/28 15:12:01
I'm changing this as well...
| |
| 109 }, | |
| 110 | |
| 111 createRootView: function() | |
| 112 { | |
| 113 var rootView = new WebInspector.RootView(); | |
| 114 | |
| 115 this._rootSplitView = new WebInspector.SplitView(false, true, WebInspect or.dockController.canDock() ? "InspectorView.splitViewState" : "InspectorView.du mmySplitViewState", 300, 300); | |
| 116 this._rootSplitView.show(rootView.element); | |
| 117 | |
| 118 WebInspector.inspectorView.show(this._rootSplitView.sidebarElement()); | |
| 119 | |
| 120 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlacehold er(); | |
| 121 this._inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPa gePlaceholder.Events.Update, this._onSetInspectedPageBounds, this); | |
| 122 if (WebInspector.experimentsSettings.responsiveDesign.isEnabled()) { | |
| 123 var responsiveDesignView = new WebInspector.ResponsiveDesignView(thi s._inspectedPagePlaceholder); | |
| 124 responsiveDesignView.show(this._rootSplitView.mainElement()); | |
| 125 } else | |
| 126 this._inspectedPagePlaceholder.show(this._rootSplitView.mainElement( )); | |
| 127 | |
| 128 WebInspector.dockController.addEventListener(WebInspector.DockController .Events.BeforeDockSideChanged, this._onBeforeDockSideChange, this); | |
| 129 WebInspector.dockController.addEventListener(WebInspector.DockController .Events.DockSideChanged, this._onDockSideChange, this); | |
| 130 WebInspector.dockController.addEventListener(WebInspector.DockController .Events.AfterDockSideChanged, this._onAfterDockSideChange, this); | |
| 131 this._onDockSideChange(); | |
| 132 | |
| 133 rootView.attachToBody(); | |
| 134 }, | |
| 135 | |
| 136 _onBeforeDockSideChange: function() | |
| 137 { | |
| 138 this._changingDockSide = true; | |
| 139 }, | |
| 140 | |
| 141 _onDockSideChange: function() | |
| 142 { | |
| 143 var dockSide = WebInspector.dockController.dockSide(); | |
| 144 if (dockSide === WebInspector.DockController.State.Undocked) { | |
| 145 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement (), false); | |
| 146 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResi zerElement(), false); | |
| 147 this._rootSplitView.hideMain(); | |
| 148 return; | |
| 149 } | |
| 150 | |
| 151 this._rootSplitView.setVertical(dockSide === WebInspector.DockController .State.DockedToLeft || dockSide === WebInspector.DockController.State.DockedToRi ght); | |
| 152 this._rootSplitView.setSecondIsSidebar(dockSide === WebInspector.DockCon troller.State.DockedToRight || dockSide === WebInspector.DockController.State.Do ckedToBottom); | |
| 153 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement(), true); | |
| 154 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResizerE lement(), dockSide === WebInspector.DockController.State.DockedToBottom); | |
| 155 this._rootSplitView.showBoth(); | |
| 156 }, | |
| 157 | |
| 158 _onAfterDockSideChange: function() | |
| 159 { | |
| 160 this._changingDockSide = false; | |
| 161 this._inspectedPagePlaceholder.update(); | |
| 162 }, | |
| 163 | |
| 164 _isDocked: function() | |
| 165 { | |
| 166 return WebInspector.dockController.dockSide() !== WebInspector.DockContr oller.State.Undocked; | |
| 167 }, | |
| 168 | |
| 169 /** | |
| 170 * @param {!WebInspector.Event} event | |
| 171 */ | |
| 172 _onSetInspectedPageBounds: function(event) | |
| 173 { | |
| 174 if (this._changingDockSide || !this._isDocked()) | |
| 175 return; | |
| 176 var bounds = /** @type {{x: number, y: number, width: number, height: nu mber}} */ (event.data); | |
| 177 InspectorFrontendHost.setInspectedPageBounds(bounds); | |
| 178 }, | |
| 179 | |
| 180 __proto__: WebInspector.App.prototype | |
| 181 }; | |
| 182 | |
| 183 | |
| 184 /** | |
| 185 * @constructor | |
| 186 * @extends {WebInspector.App} | |
| 187 */ | |
| 188 WebInspector.ScreencastApp = function() | |
| 189 { | |
| 190 WebInspector.App.call(this); | |
| 191 | |
| 192 this._currentScreencastState = WebInspector.settings.createSetting("currentS creencastState", ""); | |
| 193 this._lastScreencastState = WebInspector.settings.createSetting("lastScreenc astState", ""); | |
| 194 this._toggleScreencastButton = new WebInspector.StatusBarStatesSettingButton ( | |
| 195 "screencast-status-bar-item", | |
| 196 ["disabled", "left", "top"], | |
| 197 [WebInspector.UIString("Disable screencast."), WebInspector.UIString("Sw itch to portrait screencast."), WebInspector.UIString("Switch to landscape scree ncast.")], | |
| 198 this._currentScreencastState, | |
| 199 this._lastScreencastState, | |
| 200 this._onStatusBarButtonStateChanged.bind(this)); | |
| 201 }; | |
| 202 | |
| 203 WebInspector.ScreencastApp.prototype = { | |
| 204 createGlobalStatusBarItems: function() | |
| 205 { | |
| 206 this.appendInspectStatusBarItem(); | |
| 207 this.appendSettingsStatusBarItem(); | |
| 208 WebInspector.inspectorView.appendToRightToolbar(this._toggleScreencastBu tton.element); | |
| 209 }, | |
| 210 | |
| 211 createRootView: function() | |
| 212 { | |
| 213 var rootView = new WebInspector.RootView(); | |
| 214 | |
| 215 this._rootSplitView = new WebInspector.SplitView(false, true, "Inspector View.screencastSplitViewState", 300, 300); | |
| 216 this._rootSplitView.show(rootView.element); | |
| 217 | |
| 218 WebInspector.inspectorView.show(this._rootSplitView.sidebarElement()); | |
| 219 var target = /** @type {!WebInspector.Target} */ (WebInspector.targetMan ager.activeTarget()); | |
| 220 this._screencastView = new WebInspector.ScreencastView(target); | |
| 221 this._screencastView.show(this._rootSplitView.mainElement()); | |
| 222 | |
| 223 this._onStatusBarButtonStateChanged("disabled"); | |
| 224 rootView.attachToBody(); | |
| 225 }, | |
| 226 | |
| 227 presentUI: function() | |
| 228 { | |
| 229 WebInspector.App.prototype.presentUI.call(this); | |
| 230 this._screencastView.initialize(); | |
| 231 this._toggleScreencastButton.toggleInitialState(); | |
| 232 }, | |
| 233 | |
| 234 /** | |
| 235 * @param {string} state | |
| 236 */ | |
| 237 _onStatusBarButtonStateChanged: function(state) | |
| 238 { | |
| 239 if (state === "disabled") { | |
| 240 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement (), false); | |
| 241 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResi zerElement(), false); | |
| 242 this._rootSplitView.hideMain(); | |
| 243 return; | |
| 244 } | |
| 245 | |
| 246 this._rootSplitView.setVertical(state === "left"); | |
| 247 this._rootSplitView.setSecondIsSidebar(true); | |
| 248 this._rootSplitView.toggleResizer(this._rootSplitView.resizerElement(), true); | |
| 249 this._rootSplitView.toggleResizer(WebInspector.inspectorView.topResizerE lement(), state === "top"); | |
| 250 this._rootSplitView.showBoth(); | |
| 251 }, | |
| 252 | |
| 253 __proto__: WebInspector.App.prototype | |
| 254 }; | |
| OLD | NEW |