OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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 /** @fileoverview A helper object used for testing the Device page. */ | 5 /** @fileoverview A helper object used for testing the Device page. */ |
6 cr.exportPath('settings'); | 6 cr.exportPath('settings'); |
7 | 7 |
8 /** | 8 /** |
9 * Mirrors DeviceType from ash/system/power/power_status.h. | 9 * Mirrors DeviceType from ash/system/power/power_status.h. |
10 * @enum {number} | 10 * @enum {number} |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 /** | 69 /** |
70 * @typedef {{name:string, | 70 * @typedef {{name:string, |
71 * value:string, | 71 * value:string, |
72 * preferred:boolean, | 72 * preferred:boolean, |
73 * supportsLockScreen: boolean}} | 73 * supportsLockScreen: boolean}} |
74 */ | 74 */ |
75 settings.NoteAppInfo; | 75 settings.NoteAppInfo; |
76 | 76 |
77 cr.define('settings', function() { | 77 cr.define('settings', function() { |
78 /** @interface */ | 78 /** @interface */ |
79 function DevicePageBrowserProxy() {} | 79 class DevicePageBrowserProxy { |
80 | |
81 DevicePageBrowserProxy.prototype = { | |
82 /** Initializes the mouse and touchpad handler. */ | 80 /** Initializes the mouse and touchpad handler. */ |
83 initializePointers: function() {}, | 81 initializePointers() {} |
84 | 82 |
85 /** Initializes the stylus handler. */ | 83 /** Initializes the stylus handler. */ |
86 initializeStylus: function() {}, | 84 initializeStylus() {} |
87 | 85 |
88 /** | 86 /** |
89 * Override to interact with the on-tap/on-keydown event on the Learn More | 87 * Override to interact with the on-tap/on-keydown event on the Learn More |
90 * link. | 88 * link. |
91 * @param {!Event} e | 89 * @param {!Event} e |
92 */ | 90 */ |
93 handleLinkEvent: function(e) {}, | 91 handleLinkEvent(e) {} |
94 | 92 |
95 /** Initializes the keyboard WebUI handler. */ | 93 /** Initializes the keyboard WebUI handler. */ |
96 initializeKeyboard: function() {}, | 94 initializeKeyboard() {} |
97 | 95 |
98 /** Shows the Ash keyboard shortcuts overlay. */ | 96 /** Shows the Ash keyboard shortcuts overlay. */ |
99 showKeyboardShortcutsOverlay: function() {}, | 97 showKeyboardShortcutsOverlay() {} |
100 | 98 |
101 /** Requests a power status update. */ | 99 /** Requests a power status update. */ |
102 updatePowerStatus: function() {}, | 100 updatePowerStatus() {} |
103 | 101 |
104 /** | 102 /** |
105 * Sets the ID of the power source to use. | 103 * Sets the ID of the power source to use. |
106 * @param {string} powerSourceId ID of the power source. '' denotes the | 104 * @param {string} powerSourceId ID of the power source. '' denotes the |
107 * battery (no external power source). | 105 * battery (no external power source). |
108 */ | 106 */ |
109 setPowerSource: function(powerSourceId) {}, | 107 setPowerSource(powerSourceId) {} |
110 | 108 |
111 /** Requests the current power management settings. */ | 109 /** Requests the current power management settings. */ |
112 requestPowerManagementSettings: function() {}, | 110 requestPowerManagementSettings() {} |
113 | 111 |
114 /** | 112 /** |
115 * Sets the idle power management behavior. | 113 * Sets the idle power management behavior. |
116 * @param {settings.IdleBehavior} behavior Idle behavior. | 114 * @param {settings.IdleBehavior} behavior Idle behavior. |
117 */ | 115 */ |
118 setIdleBehavior: function(behavior) {}, | 116 setIdleBehavior(behavior) {} |
119 | 117 |
120 /** | 118 /** |
121 * Sets the lid-closed power management behavior. | 119 * Sets the lid-closed power management behavior. |
122 * @param {settings.LidClosedBehavior} behavior Lid-closed behavior. | 120 * @param {settings.LidClosedBehavior} behavior Lid-closed behavior. |
123 */ | 121 */ |
124 setLidClosedBehavior: function(behavior) {}, | 122 setLidClosedBehavior(behavior) {} |
125 | 123 |
126 /** | 124 /** |
127 * |callback| is run when there is new note-taking app information | 125 * |callback| is run when there is new note-taking app information |
128 * available or after |requestNoteTakingApps| has been called. | 126 * available or after |requestNoteTakingApps| has been called. |
129 * @param {function(Array<settings.NoteAppInfo>, boolean):void} callback | 127 * @param {function(Array<settings.NoteAppInfo>, boolean):void} callback |
130 */ | 128 */ |
131 setNoteTakingAppsUpdatedCallback: function(callback) {}, | 129 setNoteTakingAppsUpdatedCallback(callback) {} |
132 | 130 |
133 /** | 131 /** |
134 * Open up the play store with the given URL. | 132 * Open up the play store with the given URL. |
135 * @param {string} url | 133 * @param {string} url |
136 */ | 134 */ |
137 showPlayStore: function(url) {}, | 135 showPlayStore(url) {} |
138 | 136 |
139 /** | 137 /** |
140 * Request current note-taking app info. Invokes any callback registered in | 138 * Request current note-taking app info. Invokes any callback registered in |
141 * |onNoteTakingAppsUpdated|. | 139 * |onNoteTakingAppsUpdated|. |
142 */ | 140 */ |
143 requestNoteTakingApps: function() {}, | 141 requestNoteTakingApps() {} |
144 | 142 |
145 /** | 143 /** |
146 * Changes the preferred note taking app. | 144 * Changes the preferred note taking app. |
147 * @param {string} appId The app id. This should be a value retrieved from a | 145 * @param {string} appId The app id. This should be a value retrieved from a |
148 * |onNoteTakingAppsUpdated| callback. | 146 * |onNoteTakingAppsUpdated| callback. |
149 */ | 147 */ |
150 setPreferredNoteTakingApp: function(appId) {}, | 148 setPreferredNoteTakingApp(appId) {} |
151 }; | 149 } |
152 | 150 |
153 /** | 151 /** |
154 * @constructor | |
155 * @implements {settings.DevicePageBrowserProxy} | 152 * @implements {settings.DevicePageBrowserProxy} |
156 */ | 153 */ |
157 function DevicePageBrowserProxyImpl() {} | 154 class DevicePageBrowserProxyImpl { |
158 cr.addSingletonGetter(DevicePageBrowserProxyImpl); | |
159 | |
160 DevicePageBrowserProxyImpl.prototype = { | |
161 /** @override */ | 155 /** @override */ |
162 initializePointers: function() { | 156 initializePointers() { |
163 chrome.send('initializePointerSettings'); | 157 chrome.send('initializePointerSettings'); |
164 }, | 158 } |
165 | 159 |
166 /** @override */ | 160 /** @override */ |
167 initializeStylus: function() { | 161 initializeStylus() { |
168 chrome.send('initializeStylusSettings'); | 162 chrome.send('initializeStylusSettings'); |
169 }, | 163 } |
170 | 164 |
171 /** override */ | 165 /** override */ |
172 handleLinkEvent: function(e) { | 166 handleLinkEvent(e) { |
173 // Prevent the link from activating its parent element when tapped or | 167 // Prevent the link from activating its parent element when tapped or |
174 // when Enter is pressed. | 168 // when Enter is pressed. |
175 if (e.type != 'keydown' || e.keyCode == 13) | 169 if (e.type != 'keydown' || e.keyCode == 13) |
176 e.stopPropagation(); | 170 e.stopPropagation(); |
177 }, | 171 } |
178 | 172 |
179 /** @override */ | 173 /** @override */ |
180 initializeKeyboard: function() { | 174 initializeKeyboard() { |
181 chrome.send('initializeKeyboardSettings'); | 175 chrome.send('initializeKeyboardSettings'); |
182 }, | 176 } |
183 | 177 |
184 /** @override */ | 178 /** @override */ |
185 showKeyboardShortcutsOverlay: function() { | 179 showKeyboardShortcutsOverlay() { |
186 chrome.send('showKeyboardShortcutsOverlay'); | 180 chrome.send('showKeyboardShortcutsOverlay'); |
187 }, | 181 } |
188 | 182 |
189 /** @override */ | 183 /** @override */ |
190 updatePowerStatus: function() { | 184 updatePowerStatus() { |
191 chrome.send('updatePowerStatus'); | 185 chrome.send('updatePowerStatus'); |
192 }, | 186 } |
193 | 187 |
194 /** @override */ | 188 /** @override */ |
195 setPowerSource: function(powerSourceId) { | 189 setPowerSource(powerSourceId) { |
196 chrome.send('setPowerSource', [powerSourceId]); | 190 chrome.send('setPowerSource', [powerSourceId]); |
197 }, | 191 } |
198 | 192 |
199 /** @override */ | 193 /** @override */ |
200 requestPowerManagementSettings: function() { | 194 requestPowerManagementSettings() { |
201 chrome.send('requestPowerManagementSettings'); | 195 chrome.send('requestPowerManagementSettings'); |
202 }, | 196 } |
203 | 197 |
204 /** @override */ | 198 /** @override */ |
205 setIdleBehavior: function(behavior) { | 199 setIdleBehavior(behavior) { |
206 chrome.send('setIdleBehavior', [behavior]); | 200 chrome.send('setIdleBehavior', [behavior]); |
207 }, | 201 } |
208 | 202 |
209 /** @override */ | 203 /** @override */ |
210 setLidClosedBehavior: function(behavior) { | 204 setLidClosedBehavior(behavior) { |
211 chrome.send('setLidClosedBehavior', [behavior]); | 205 chrome.send('setLidClosedBehavior', [behavior]); |
212 }, | 206 } |
213 | 207 |
214 /** @override */ | 208 /** @override */ |
215 setNoteTakingAppsUpdatedCallback: function(callback) { | 209 setNoteTakingAppsUpdatedCallback(callback) { |
216 cr.addWebUIListener('onNoteTakingAppsUpdated', callback); | 210 cr.addWebUIListener('onNoteTakingAppsUpdated', callback); |
217 }, | 211 } |
218 | 212 |
219 /** @override */ | 213 /** @override */ |
220 showPlayStore: function(url) { | 214 showPlayStore(url) { |
221 chrome.send('showPlayStoreApps', [url]); | 215 chrome.send('showPlayStoreApps', [url]); |
222 }, | 216 } |
223 | 217 |
224 /** @override */ | 218 /** @override */ |
225 requestNoteTakingApps: function() { | 219 requestNoteTakingApps() { |
226 chrome.send('requestNoteTakingApps'); | 220 chrome.send('requestNoteTakingApps'); |
227 }, | 221 } |
228 | 222 |
229 /** @override */ | 223 /** @override */ |
230 setPreferredNoteTakingApp: function(appId) { | 224 setPreferredNoteTakingApp(appId) { |
231 chrome.send('setPreferredNoteTakingApp', [appId]); | 225 chrome.send('setPreferredNoteTakingApp', [appId]); |
232 }, | 226 } |
233 }; | 227 } |
| 228 |
| 229 cr.addSingletonGetter(DevicePageBrowserProxyImpl); |
234 | 230 |
235 return { | 231 return { |
236 DevicePageBrowserProxy: DevicePageBrowserProxy, | 232 DevicePageBrowserProxy: DevicePageBrowserProxy, |
237 DevicePageBrowserProxyImpl: DevicePageBrowserProxyImpl, | 233 DevicePageBrowserProxyImpl: DevicePageBrowserProxyImpl, |
238 }; | 234 }; |
239 }); | 235 }); |
OLD | NEW |