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

Side by Side Diff: Source/devtools/front_end/components/DockController.js

Issue 283063003: DevTools: Implement extension-based status bar buttons (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix setting-based buttons initialization logic Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 { 37 {
38 this._canDock = canDock; 38 this._canDock = canDock;
39 if (!canDock) { 39 if (!canDock) {
40 this._dockSide = WebInspector.DockController.State.Undocked; 40 this._dockSide = WebInspector.DockController.State.Undocked;
41 this._updateUI(); 41 this._updateUI();
42 return; 42 return;
43 } 43 }
44 44
45 WebInspector.settings.currentDockState = WebInspector.settings.createSetting ("currentDockState", ""); 45 WebInspector.settings.currentDockState = WebInspector.settings.createSetting ("currentDockState", "");
46 WebInspector.settings.lastDockState = WebInspector.settings.createSetting("l astDockState", ""); 46 WebInspector.settings.lastDockState = WebInspector.settings.createSetting("l astDockState", "");
47 var states = [WebInspector.DockController.State.DockedToBottom, WebInspector .DockController.State.Undocked, WebInspector.DockController.State.DockedToRight] ;
48 var titles = [WebInspector.UIString("Dock to main window."), WebInspector.UI String("Undock into separate window."), WebInspector.UIString("Dock to main wind ow.")];
49 if (WebInspector.experimentsSettings.dockToLeft.isEnabled()) {
50 states.push(WebInspector.DockController.State.DockedToLeft);
51 titles.push(WebInspector.UIString("Dock to main window."));
52 }
53 this._dockToggleButton = new WebInspector.StatusBarStatesSettingButton(
54 "dock-status-bar-item",
55 states,
56 titles,
57 WebInspector.settings.currentDockState,
58 WebInspector.settings.lastDockState,
59 this._dockSideChanged.bind(this));
60 } 47 }
61 48
62 WebInspector.DockController.State = { 49 WebInspector.DockController.State = {
63 DockedToBottom: "bottom", 50 DockedToBottom: "bottom",
64 DockedToRight: "right", 51 DockedToRight: "right",
65 DockedToLeft: "left", 52 DockedToLeft: "left",
66 Undocked: "undocked" 53 Undocked: "undocked"
67 } 54 }
68 55
69 // Use BeforeDockSideChanged to do something before all the UI bits are updated, 56 // Use BeforeDockSideChanged to do something before all the UI bits are updated,
70 // DockSideChanged to update UI, and AfterDockSideChanged to perform actions 57 // DockSideChanged to update UI, and AfterDockSideChanged to perform actions
71 // after frontend is docked/undocked in the browser. 58 // after frontend is docked/undocked in the browser.
72 WebInspector.DockController.Events = { 59 WebInspector.DockController.Events = {
73 BeforeDockSideChanged: "BeforeDockSideChanged", 60 BeforeDockSideChanged: "BeforeDockSideChanged",
74 DockSideChanged: "DockSideChanged", 61 DockSideChanged: "DockSideChanged",
75 AfterDockSideChanged: "AfterDockSideChanged" 62 AfterDockSideChanged: "AfterDockSideChanged"
76 } 63 }
77 64
78 WebInspector.DockController.prototype = { 65 WebInspector.DockController.prototype = {
79 initialize: function() 66 initialize: function()
80 { 67 {
81 if (this._canDock) 68 if (!this._canDock)
82 this._dockToggleButton.toggleInitialState(); 69 return;
70
71 this._states = [WebInspector.DockController.State.DockedToBottom, WebIns pector.DockController.State.Undocked, WebInspector.DockController.State.DockedTo Right];
72 this._titles = [WebInspector.UIString("Dock to main window."), WebInspec tor.UIString("Undock into separate window."), WebInspector.UIString("Dock to mai n window.")];
73 if (WebInspector.experimentsSettings.dockToLeft.isEnabled()) {
74 this._states.push(WebInspector.DockController.State.DockedToLeft);
75 this._titles.push(WebInspector.UIString("Dock to main window."));
76 }
77 var initialState = WebInspector.settings.currentDockState.get();
78 initialState = this._states.indexOf(initialState) >= 0 ? initialState : this._states[0];
79 this._dockSideChanged(initialState);
83 }, 80 },
84 81
85 /** 82 /**
86 * @return {?Element}
87 */
88 get element()
89 {
90 return this._canDock ? this._dockToggleButton.element : null;
91 },
92
93 /**
94 * @return {string} 83 * @return {string}
95 */ 84 */
96 dockSide: function() 85 dockSide: function()
97 { 86 {
98 return this._dockSide; 87 return this._dockSide;
99 }, 88 },
100 89
101 /** 90 /**
102 * @return {boolean} 91 * @return {boolean}
103 */ 92 */
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 body.classList.remove("dock-to-left"); 151 body.classList.remove("dock-to-left");
163 body.classList.remove("dock-to-bottom"); 152 body.classList.remove("dock-to-bottom");
164 break; 153 break;
165 } 154 }
166 }, 155 },
167 156
168 __proto__: WebInspector.Object.prototype 157 __proto__: WebInspector.Object.prototype
169 } 158 }
170 159
171 /** 160 /**
161 * @constructor
162 * @implements {WebInspector.StatusBarButton.Provider}
163 */
164 WebInspector.DockController.ButtonProvider = function()
165 {
166 }
167
168 WebInspector.DockController.ButtonProvider.prototype = {
169 /**
170 * @return {?WebInspector.StatusBarButton}
171 */
172 button: function()
173 {
174 if (!WebInspector.dockController.canDock())
175 return null;
176
177 if (!this._dockToggleButton) {
178 this._dockToggleButton = new WebInspector.StatusBarStatesSettingButt on(
179 "dock-status-bar-item",
180 WebInspector.dockController._states,
181 WebInspector.dockController._titles,
182 WebInspector.dockController.dockSide(),
183 WebInspector.settings.currentDockState,
184 WebInspector.settings.lastDockState,
185 WebInspector.dockController._dockSideChanged.bind(WebInspect or.dockController));
186 }
187 return this._dockToggleButton;
188 }
189 }
190
191 /**
172 * @type {!WebInspector.DockController} 192 * @type {!WebInspector.DockController}
173 */ 193 */
174 WebInspector.dockController; 194 WebInspector.dockController;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698