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

Side by Side Diff: chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js

Issue 2954863003: MD Settings: Convert all browser proxies to use ES6 class syntax. (Closed)
Patch Set: Remove @constructor annotations. Created 3 years, 5 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
OLDNEW
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 /** 5 /**
6 * @fileoverview A helper object used from the "Site Settings" section to 6 * @fileoverview A helper object used from the "Site Settings" section to
7 * interact with the content settings prefs. 7 * interact with the content settings prefs.
8 */ 8 */
9 9
10 /** 10 /**
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 /** 91 /**
92 * @typedef {{origin: string, 92 * @typedef {{origin: string,
93 * setting: string, 93 * setting: string,
94 * source: string, 94 * source: string,
95 * zoom: string}} 95 * zoom: string}}
96 */ 96 */
97 var ZoomLevelEntry; 97 var ZoomLevelEntry;
98 98
99 cr.define('settings', function() { 99 cr.define('settings', function() {
100 /** @interface */ 100 /** @interface */
101 function SiteSettingsPrefsBrowserProxy() {} 101 class SiteSettingsPrefsBrowserProxy {
102
103 SiteSettingsPrefsBrowserProxy.prototype = {
104 /** 102 /**
105 * Sets the default value for a site settings category. 103 * Sets the default value for a site settings category.
106 * @param {string} contentType The name of the category to change. 104 * @param {string} contentType The name of the category to change.
107 * @param {string} defaultValue The name of the value to set as default. 105 * @param {string} defaultValue The name of the value to set as default.
108 */ 106 */
109 setDefaultValueForContentType: function(contentType, defaultValue) {}, 107 setDefaultValueForContentType(contentType, defaultValue) {}
110 108
111 /** 109 /**
112 * Gets the cookie details for a particular site. 110 * Gets the cookie details for a particular site.
113 * @param {string} site The name of the site. 111 * @param {string} site The name of the site.
114 * @return {!Promise<!CookieList>} 112 * @return {!Promise<!CookieList>}
115 */ 113 */
116 getCookieDetails: function(site) {}, 114 getCookieDetails(site) {}
117 115
118 /** 116 /**
119 * Gets the default value for a site settings category. 117 * Gets the default value for a site settings category.
120 * @param {string} contentType The name of the category to query. 118 * @param {string} contentType The name of the category to query.
121 * @return {!Promise<!DefaultContentSetting>} 119 * @return {!Promise<!DefaultContentSetting>}
122 */ 120 */
123 getDefaultValueForContentType: function(contentType) {}, 121 getDefaultValueForContentType(contentType) {}
124 122
125 /** 123 /**
126 * Gets the exceptions (site list) for a particular category. 124 * Gets the exceptions (site list) for a particular category.
127 * @param {string} contentType The name of the category to query. 125 * @param {string} contentType The name of the category to query.
128 * @return {!Promise<!Array<!RawSiteException>>} 126 * @return {!Promise<!Array<!RawSiteException>>}
129 */ 127 */
130 getExceptionList: function(contentType) {}, 128 getExceptionList(contentType) {}
131 129
132 /** 130 /**
133 * Gets the exception details for a particular site. 131 * Gets the exception details for a particular site.
134 * @param {string} site The name of the site. 132 * @param {string} site The name of the site.
135 * @return {!Promise<!RawSiteException>} 133 * @return {!Promise<!RawSiteException>}
136 */ 134 */
137 getSiteDetails: function(site) {}, 135 getSiteDetails(site) {}
138 136
139 /** 137 /**
140 * Resets the category permission for a given origin (expressed as primary 138 * Resets the category permission for a given origin (expressed as primary
141 * and secondary patterns). 139 * and secondary patterns).
142 * @param {string} primaryPattern The origin to change (primary pattern). 140 * @param {string} primaryPattern The origin to change (primary pattern).
143 * @param {string} secondaryPattern The embedding origin to change 141 * @param {string} secondaryPattern The embedding origin to change
144 * (secondary pattern). 142 * (secondary pattern).
145 * @param {string} contentType The name of the category to reset. 143 * @param {string} contentType The name of the category to reset.
146 * @param {boolean} incognito Whether this applies only to a current 144 * @param {boolean} incognito Whether this applies only to a current
147 * incognito session exception. 145 * incognito session exception.
148 */ 146 */
149 resetCategoryPermissionForOrigin: function( 147 resetCategoryPermissionForOrigin(
150 primaryPattern, secondaryPattern, contentType, incognito) {}, 148 primaryPattern, secondaryPattern, contentType, incognito) {}
151 149
152 /** 150 /**
153 * Sets the category permission for a given origin (expressed as primary 151 * Sets the category permission for a given origin (expressed as primary
154 * and secondary patterns). 152 * and secondary patterns).
155 * @param {string} primaryPattern The origin to change (primary pattern). 153 * @param {string} primaryPattern The origin to change (primary pattern).
156 * @param {string} secondaryPattern The embedding origin to change 154 * @param {string} secondaryPattern The embedding origin to change
157 * (secondary pattern). 155 * (secondary pattern).
158 * @param {string} contentType The name of the category to change. 156 * @param {string} contentType The name of the category to change.
159 * @param {string} value The value to change the permission to. 157 * @param {string} value The value to change the permission to.
160 * @param {boolean} incognito Whether this rule applies only to the current 158 * @param {boolean} incognito Whether this rule applies only to the current
161 * incognito session. 159 * incognito session.
162 */ 160 */
163 setCategoryPermissionForOrigin: function( 161 setCategoryPermissionForOrigin(
164 primaryPattern, secondaryPattern, contentType, value, incognito) {}, 162 primaryPattern, secondaryPattern, contentType, value, incognito) {}
165 163
166 /** 164 /**
167 * Checks whether a pattern is valid. 165 * Checks whether a pattern is valid.
168 * @param {string} pattern The pattern to check 166 * @param {string} pattern The pattern to check
169 * @return {!Promise<boolean>} True if the pattern is valid. 167 * @return {!Promise<boolean>} True if the pattern is valid.
170 */ 168 */
171 isPatternValid: function(pattern) {}, 169 isPatternValid(pattern) {}
172 170
173 /** 171 /**
174 * Gets the list of default capture devices for a given type of media. List 172 * Gets the list of default capture devices for a given type of media. List
175 * is returned through a JS call to updateDevicesMenu. 173 * is returned through a JS call to updateDevicesMenu.
176 * @param {string} type The type to look up. 174 * @param {string} type The type to look up.
177 */ 175 */
178 getDefaultCaptureDevices: function(type) {}, 176 getDefaultCaptureDevices(type) {}
179 177
180 /** 178 /**
181 * Sets a default devices for a given type of media. 179 * Sets a default devices for a given type of media.
182 * @param {string} type The type of media to configure. 180 * @param {string} type The type of media to configure.
183 * @param {string} defaultValue The id of the media device to set. 181 * @param {string} defaultValue The id of the media device to set.
184 */ 182 */
185 setDefaultCaptureDevice: function(type, defaultValue) {}, 183 setDefaultCaptureDevice(type, defaultValue) {}
186 184
187 /** 185 /**
188 * Reloads all cookies. 186 * Reloads all cookies.
189 * @return {!Promise<!CookieList>} Returns the full cookie 187 * @return {!Promise<!CookieList>} Returns the full cookie
190 * list. 188 * list.
191 */ 189 */
192 reloadCookies: function() {}, 190 reloadCookies() {}
193 191
194 /** 192 /**
195 * Fetches all children of a given cookie. 193 * Fetches all children of a given cookie.
196 * @param {string} path The path to the parent cookie. 194 * @param {string} path The path to the parent cookie.
197 * @return {!Promise<!Array<!CookieDataSummaryItem>>} Returns a cookie list 195 * @return {!Promise<!Array<!CookieDataSummaryItem>>} Returns a cookie list
198 * for the given path. 196 * for the given path.
199 */ 197 */
200 loadCookieChildren: function(path) {}, 198 loadCookieChildren(path) {}
201 199
202 /** 200 /**
203 * Removes a given cookie. 201 * Removes a given cookie.
204 * @param {string} path The path to the parent cookie. 202 * @param {string} path The path to the parent cookie.
205 */ 203 */
206 removeCookie: function(path) {}, 204 removeCookie(path) {}
207 205
208 /** 206 /**
209 * Removes all cookies. 207 * Removes all cookies.
210 * @return {!Promise<!CookieList>} Returns the up to date 208 * @return {!Promise<!CookieList>} Returns the up to date
211 * cookie list once deletion is complete (empty list). 209 * cookie list once deletion is complete (empty list).
212 */ 210 */
213 removeAllCookies: function() {}, 211 removeAllCookies() {}
214 212
215 /** 213 /**
216 * observes _all_ of the the protocol handler state, which includes a list 214 * observes _all_ of the the protocol handler state, which includes a list
217 * that is returned through JS calls to 'setProtocolHandlers' along with 215 * that is returned through JS calls to 'setProtocolHandlers' along with
218 * other state sent with the messages 'setIgnoredProtocolHandler' and 216 * other state sent with the messages 'setIgnoredProtocolHandler' and
219 * 'setHandlersEnabled'. 217 * 'setHandlersEnabled'.
220 */ 218 */
221 observeProtocolHandlers: function() {}, 219 observeProtocolHandlers() {}
222 220
223 /** 221 /**
224 * Observes one aspect of the protocol handler so that updates to the 222 * Observes one aspect of the protocol handler so that updates to the
225 * enabled/disabled state are sent. A 'setHandlersEnabled' will be sent 223 * enabled/disabled state are sent. A 'setHandlersEnabled' will be sent
226 * from C++ immediately after receiving this observe request and updates 224 * from C++ immediately after receiving this observe request and updates
227 * may follow via additional 'setHandlersEnabled' messages. 225 * may follow via additional 'setHandlersEnabled' messages.
228 * 226 *
229 * If |observeProtocolHandlers| is called, there's no need to call this 227 * If |observeProtocolHandlers| is called, there's no need to call this
230 * observe as well. 228 * observe as well.
231 */ 229 */
232 observeProtocolHandlersEnabledState: function() {}, 230 observeProtocolHandlersEnabledState() {}
233 231
234 /** 232 /**
235 * Enables or disables the ability for sites to ask to become the default 233 * Enables or disables the ability for sites to ask to become the default
236 * protocol handlers. 234 * protocol handlers.
237 * @param {boolean} enabled Whether sites can ask to become default. 235 * @param {boolean} enabled Whether sites can ask to become default.
238 */ 236 */
239 setProtocolHandlerDefault: function(enabled) {}, 237 setProtocolHandlerDefault(enabled) {}
240 238
241 /** 239 /**
242 * Sets a certain url as default for a given protocol handler. 240 * Sets a certain url as default for a given protocol handler.
243 * @param {string} protocol The protocol to set a default for. 241 * @param {string} protocol The protocol to set a default for.
244 * @param {string} url The url to use as the default. 242 * @param {string} url The url to use as the default.
245 */ 243 */
246 setProtocolDefault: function(protocol, url) {}, 244 setProtocolDefault(protocol, url) {}
247 245
248 /** 246 /**
249 * Deletes a certain protocol handler by url. 247 * Deletes a certain protocol handler by url.
250 * @param {string} protocol The protocol to delete the url from. 248 * @param {string} protocol The protocol to delete the url from.
251 * @param {string} url The url to delete. 249 * @param {string} url The url to delete.
252 */ 250 */
253 removeProtocolHandler: function(protocol, url) {}, 251 removeProtocolHandler(protocol, url) {}
254 252
255 /** 253 /**
256 * Fetches a list of all USB devices and the sites permitted to use them. 254 * Fetches a list of all USB devices and the sites permitted to use them.
257 * @return {!Promise<!Array<!UsbDeviceEntry>>} The list of USB devices. 255 * @return {!Promise<!Array<!UsbDeviceEntry>>} The list of USB devices.
258 */ 256 */
259 fetchUsbDevices: function() {}, 257 fetchUsbDevices() {}
260 258
261 /** 259 /**
262 * Removes a particular USB device object permission by origin and embedding 260 * Removes a particular USB device object permission by origin and embedding
263 * origin. 261 * origin.
264 * @param {string} origin The origin to look up the permission for. 262 * @param {string} origin The origin to look up the permission for.
265 * @param {string} embeddingOrigin the embedding origin to look up. 263 * @param {string} embeddingOrigin the embedding origin to look up.
266 * @param {!UsbDeviceDetails} usbDevice The USB device to revoke permission 264 * @param {!UsbDeviceDetails} usbDevice The USB device to revoke permission
267 * for. 265 * for.
268 */ 266 */
269 removeUsbDevice: function(origin, embeddingOrigin, usbDevice) {}, 267 removeUsbDevice(origin, embeddingOrigin, usbDevice) {}
270 268
271 /** 269 /**
272 * Fetches the incognito status of the current profile (whether an icognito 270 * Fetches the incognito status of the current profile (whether an icognito
273 * profile exists). Returns the results via onIncognitoStatusChanged. 271 * profile exists). Returns the results via onIncognitoStatusChanged.
274 */ 272 */
275 updateIncognitoStatus: function() {}, 273 updateIncognitoStatus() {}
276 274
277 /** 275 /**
278 * Fetches the currently defined zoom levels for sites. Returns the results 276 * Fetches the currently defined zoom levels for sites. Returns the results
279 * via onZoomLevelsChanged. 277 * via onZoomLevelsChanged.
280 */ 278 */
281 fetchZoomLevels: function() {}, 279 fetchZoomLevels() {}
282 280
283 /** 281 /**
284 * Removes a zoom levels for a given host. 282 * Removes a zoom levels for a given host.
285 * @param {string} host The host to remove zoom levels for. 283 * @param {string} host The host to remove zoom levels for.
286 */ 284 */
287 removeZoomLevel: function(host) {}, 285 removeZoomLevel(host) {}
288 }; 286 }
289 287
290 /** 288 /**
291 * @constructor
292 * @implements {settings.SiteSettingsPrefsBrowserProxy} 289 * @implements {settings.SiteSettingsPrefsBrowserProxy}
293 */ 290 */
294 function SiteSettingsPrefsBrowserProxyImpl() {} 291 class SiteSettingsPrefsBrowserProxyImpl {
295
296 // The singleton instance_ is replaced with a test version of this wrapper
297 // during testing.
298 cr.addSingletonGetter(SiteSettingsPrefsBrowserProxyImpl);
299
300 SiteSettingsPrefsBrowserProxyImpl.prototype = {
301 /** @override */ 292 /** @override */
302 setDefaultValueForContentType: function(contentType, defaultValue) { 293 setDefaultValueForContentType(contentType, defaultValue) {
303 chrome.send('setDefaultValueForContentType', [contentType, defaultValue]); 294 chrome.send('setDefaultValueForContentType', [contentType, defaultValue]);
304 }, 295 }
305 296
306 /** @override */ 297 /** @override */
307 getCookieDetails: function(site) { 298 getCookieDetails(site) {
308 return cr.sendWithPromise('getCookieDetails', site); 299 return cr.sendWithPromise('getCookieDetails', site);
309 }, 300 }
310 301
311 /** @override */ 302 /** @override */
312 getDefaultValueForContentType: function(contentType) { 303 getDefaultValueForContentType(contentType) {
313 return cr.sendWithPromise('getDefaultValueForContentType', contentType); 304 return cr.sendWithPromise('getDefaultValueForContentType', contentType);
314 }, 305 }
315 306
316 /** @override */ 307 /** @override */
317 getExceptionList: function(contentType) { 308 getExceptionList(contentType) {
318 return cr.sendWithPromise('getExceptionList', contentType); 309 return cr.sendWithPromise('getExceptionList', contentType);
319 }, 310 }
320 311
321 /** @override */ 312 /** @override */
322 getSiteDetails: function(site) { 313 getSiteDetails(site) {
323 return cr.sendWithPromise('getSiteDetails', site); 314 return cr.sendWithPromise('getSiteDetails', site);
324 }, 315 }
325 316
326 /** @override */ 317 /** @override */
327 resetCategoryPermissionForOrigin: function( 318 resetCategoryPermissionForOrigin(
328 primaryPattern, secondaryPattern, contentType, incognito) { 319 primaryPattern, secondaryPattern, contentType, incognito) {
329 chrome.send( 320 chrome.send(
330 'resetCategoryPermissionForOrigin', 321 'resetCategoryPermissionForOrigin',
331 [primaryPattern, secondaryPattern, contentType, incognito]); 322 [primaryPattern, secondaryPattern, contentType, incognito]);
332 }, 323 }
333 324
334 /** @override */ 325 /** @override */
335 setCategoryPermissionForOrigin: function( 326 setCategoryPermissionForOrigin(
336 primaryPattern, secondaryPattern, contentType, value, incognito) { 327 primaryPattern, secondaryPattern, contentType, value, incognito) {
337 // TODO(dschuyler): It may be incorrect for JS to send the embeddingOrigin 328 // TODO(dschuyler): It may be incorrect for JS to send the embeddingOrigin
338 // pattern. Look into removing this parameter from site_settings_handler. 329 // pattern. Look into removing this parameter from site_settings_handler.
339 // Ignoring the |secondaryPattern| and using '' instead is a quick-fix. 330 // Ignoring the |secondaryPattern| and using '' instead is a quick-fix.
340 chrome.send( 331 chrome.send(
341 'setCategoryPermissionForOrigin', 332 'setCategoryPermissionForOrigin',
342 [primaryPattern, '', contentType, value, incognito]); 333 [primaryPattern, '', contentType, value, incognito]);
343 }, 334 }
344 335
345 /** @override */ 336 /** @override */
346 isPatternValid: function(pattern) { 337 isPatternValid(pattern) {
347 return cr.sendWithPromise('isPatternValid', pattern); 338 return cr.sendWithPromise('isPatternValid', pattern);
348 }, 339 }
349 340
350 /** @override */ 341 /** @override */
351 getDefaultCaptureDevices: function(type) { 342 getDefaultCaptureDevices(type) {
352 chrome.send('getDefaultCaptureDevices', [type]); 343 chrome.send('getDefaultCaptureDevices', [type]);
353 }, 344 }
354 345
355 /** @override */ 346 /** @override */
356 setDefaultCaptureDevice: function(type, defaultValue) { 347 setDefaultCaptureDevice(type, defaultValue) {
357 chrome.send('setDefaultCaptureDevice', [type, defaultValue]); 348 chrome.send('setDefaultCaptureDevice', [type, defaultValue]);
358 }, 349 }
359 350
360 /** @override */ 351 /** @override */
361 reloadCookies: function() { 352 reloadCookies() {
362 return cr.sendWithPromise('reloadCookies'); 353 return cr.sendWithPromise('reloadCookies');
363 }, 354 }
364 355
365 /** @override */ 356 /** @override */
366 loadCookieChildren: function(path) { 357 loadCookieChildren(path) {
367 return cr.sendWithPromise('loadCookie', path); 358 return cr.sendWithPromise('loadCookie', path);
368 }, 359 }
369 360
370 /** @override */ 361 /** @override */
371 removeCookie: function(path) { 362 removeCookie(path) {
372 chrome.send('removeCookie', [path]); 363 chrome.send('removeCookie', [path]);
373 }, 364 }
374 365
375 /** @override */ 366 /** @override */
376 removeAllCookies: function() { 367 removeAllCookies() {
377 return cr.sendWithPromise('removeAllCookies'); 368 return cr.sendWithPromise('removeAllCookies');
378 }, 369 }
379 370
380 /** @override */ 371 /** @override */
381 observeProtocolHandlers: function() { 372 observeProtocolHandlers() {
382 chrome.send('observeProtocolHandlers'); 373 chrome.send('observeProtocolHandlers');
383 }, 374 }
384 375
385 /** @override */ 376 /** @override */
386 observeProtocolHandlersEnabledState: function() { 377 observeProtocolHandlersEnabledState() {
387 chrome.send('observeProtocolHandlersEnabledState'); 378 chrome.send('observeProtocolHandlersEnabledState');
388 }, 379 }
389 380
390 /** @override */ 381 /** @override */
391 setProtocolHandlerDefault: function(enabled) { 382 setProtocolHandlerDefault(enabled) {
392 chrome.send('setHandlersEnabled', [enabled]); 383 chrome.send('setHandlersEnabled', [enabled]);
393 }, 384 }
394 385
395 /** @override */ 386 /** @override */
396 setProtocolDefault: function(protocol, url) { 387 setProtocolDefault(protocol, url) {
397 chrome.send('setDefault', [[protocol, url]]); 388 chrome.send('setDefault', [[protocol, url]]);
398 }, 389 }
399 390
400 /** @override */ 391 /** @override */
401 removeProtocolHandler: function(protocol, url) { 392 removeProtocolHandler(protocol, url) {
402 chrome.send('removeHandler', [[protocol, url]]); 393 chrome.send('removeHandler', [[protocol, url]]);
403 }, 394 }
404 395
405 /** @override */ 396 /** @override */
406 fetchUsbDevices: function() { 397 fetchUsbDevices() {
407 return cr.sendWithPromise('fetchUsbDevices'); 398 return cr.sendWithPromise('fetchUsbDevices');
408 }, 399 }
409 400
410 /** @override */ 401 /** @override */
411 removeUsbDevice: function(origin, embeddingOrigin, usbDevice) { 402 removeUsbDevice(origin, embeddingOrigin, usbDevice) {
412 chrome.send('removeUsbDevice', [origin, embeddingOrigin, usbDevice]); 403 chrome.send('removeUsbDevice', [origin, embeddingOrigin, usbDevice]);
413 }, 404 }
414 405
415 /** @override */ 406 /** @override */
416 updateIncognitoStatus: function() { 407 updateIncognitoStatus() {
417 chrome.send('updateIncognitoStatus'); 408 chrome.send('updateIncognitoStatus');
418 }, 409 }
419 410
420 /** @override */ 411 /** @override */
421 fetchZoomLevels: function() { 412 fetchZoomLevels() {
422 chrome.send('fetchZoomLevels'); 413 chrome.send('fetchZoomLevels');
423 }, 414 }
424 415
425 /** @override */ 416 /** @override */
426 removeZoomLevel: function(host) { 417 removeZoomLevel(host) {
427 chrome.send('removeZoomLevel', [host]); 418 chrome.send('removeZoomLevel', [host]);
428 }, 419 }
429 }; 420 }
421
422 // The singleton instance_ is replaced with a test version of this wrapper
423 // during testing.
424 cr.addSingletonGetter(SiteSettingsPrefsBrowserProxyImpl);
430 425
431 return { 426 return {
432 SiteSettingsPrefsBrowserProxy: SiteSettingsPrefsBrowserProxy, 427 SiteSettingsPrefsBrowserProxy: SiteSettingsPrefsBrowserProxy,
433 SiteSettingsPrefsBrowserProxyImpl: SiteSettingsPrefsBrowserProxyImpl, 428 SiteSettingsPrefsBrowserProxyImpl: SiteSettingsPrefsBrowserProxyImpl,
434 }; 429 };
435 }); 430 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698