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 /** | 5 /** |
6 * Only used for tests. | 6 * Only used for tests. |
7 * @typedef {{ | 7 * @typedef {{ |
8 * auto_downloads: !Array<!RawSiteException>}, | 8 * auto_downloads: !Array<!RawSiteException>}, |
9 * background_sync: !Array<!RawSiteException>}, | 9 * background_sync: !Array<!RawSiteException>}, |
10 * camera: !Array<!RawSiteException>}, | 10 * camera: !Array<!RawSiteException>}, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 * @implements {settings.SiteSettingsPrefsBrowserProxy} | 78 * @implements {settings.SiteSettingsPrefsBrowserProxy} |
79 * @extends {TestBrowserProxy} | 79 * @extends {TestBrowserProxy} |
80 */ | 80 */ |
81 var TestSiteSettingsPrefsBrowserProxy = function() { | 81 var TestSiteSettingsPrefsBrowserProxy = function() { |
82 TestBrowserProxy.call(this, [ | 82 TestBrowserProxy.call(this, [ |
83 'fetchUsbDevices', | 83 'fetchUsbDevices', |
84 'fetchZoomLevels', | 84 'fetchZoomLevels', |
85 'getCookieDetails', | 85 'getCookieDetails', |
86 'getDefaultValueForContentType', | 86 'getDefaultValueForContentType', |
87 'getExceptionList', | 87 'getExceptionList', |
| 88 'getOriginPermissions', |
88 'isPatternValid', | 89 'isPatternValid', |
89 'observeProtocolHandlers', | 90 'observeProtocolHandlers', |
90 'observeProtocolHandlersEnabledState', | 91 'observeProtocolHandlersEnabledState', |
91 'reloadCookies', | 92 'reloadCookies', |
92 'removeCookie', | 93 'removeCookie', |
93 'removeProtocolHandler', | 94 'removeProtocolHandler', |
94 'removeUsbDevice', | 95 'removeUsbDevice', |
95 'removeZoomLevel', | 96 'removeZoomLevel', |
96 'resetCategoryPermissionForOrigin', | 97 'resetCategoryPermissionForOrigin', |
97 'setCategoryPermissionForOrigin', | 98 'setCategoryPermissionForOrigin', |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 307 |
307 /** @override */ | 308 /** @override */ |
308 resetCategoryPermissionForOrigin: function( | 309 resetCategoryPermissionForOrigin: function( |
309 primaryPattern, secondaryPattern, contentType, incognito) { | 310 primaryPattern, secondaryPattern, contentType, incognito) { |
310 this.methodCalled('resetCategoryPermissionForOrigin', | 311 this.methodCalled('resetCategoryPermissionForOrigin', |
311 [primaryPattern, secondaryPattern, contentType, incognito]); | 312 [primaryPattern, secondaryPattern, contentType, incognito]); |
312 return Promise.resolve(); | 313 return Promise.resolve(); |
313 }, | 314 }, |
314 | 315 |
315 /** @override */ | 316 /** @override */ |
| 317 getOriginPermissions: function(origin, contentTypes) { |
| 318 this.methodCalled('getOriginPermissions', [origin, contentTypes]); |
| 319 |
| 320 var exceptionList = []; |
| 321 contentTypes.forEach(function(contentType) { |
| 322 // Convert |contentType| to its corresponding pref name, if different. |
| 323 if (contentType == settings.ContentSettingsTypes.GEOLOCATION) { |
| 324 contentType = 'geolocation'; |
| 325 } else if (contentType == settings.ContentSettingsTypes.CAMERA) { |
| 326 contentType = 'camera'; |
| 327 } else if (contentType == settings.ContentSettingsTypes.MIC) { |
| 328 contentType = 'mic'; |
| 329 } else if (contentType == settings.ContentSettingsTypes.BACKGROUND_SYNC) { |
| 330 contentType = 'background_sync'; |
| 331 } else if ( |
| 332 contentType == settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS) { |
| 333 contentType = 'auto_downloads'; |
| 334 } else if ( |
| 335 contentType == settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS) { |
| 336 contentType = 'unsandboxed_plugins'; |
| 337 } |
| 338 |
| 339 var setting = undefined; |
| 340 this.prefs_.exceptions[contentType].some(function(originPrefs) { |
| 341 if (originPrefs.origin == origin) { |
| 342 setting = originPrefs.setting; |
| 343 return true; |
| 344 } |
| 345 }); |
| 346 assert( |
| 347 settings !== undefined, |
| 348 'There was no exception set for origin: ' + origin + |
| 349 ' and contentType: ' + contentType); |
| 350 |
| 351 exceptionList.push({ |
| 352 embeddingOrigin: '', |
| 353 incognito: false, |
| 354 origin: origin, |
| 355 displayName: '', |
| 356 setting: setting, |
| 357 source: undefined |
| 358 }) |
| 359 }, this); |
| 360 return Promise.resolve(exceptionList); |
| 361 }, |
| 362 |
| 363 /** @override */ |
316 setCategoryPermissionForOrigin: function( | 364 setCategoryPermissionForOrigin: function( |
317 primaryPattern, secondaryPattern, contentType, value, incognito) { | 365 primaryPattern, secondaryPattern, contentType, value, incognito) { |
318 this.methodCalled('setCategoryPermissionForOrigin', | 366 this.methodCalled('setCategoryPermissionForOrigin', |
319 [primaryPattern, secondaryPattern, contentType, value, incognito]); | 367 [primaryPattern, secondaryPattern, contentType, value, incognito]); |
320 return Promise.resolve(); | 368 return Promise.resolve(); |
321 }, | 369 }, |
322 | 370 |
323 /** @override */ | 371 /** @override */ |
324 fetchZoomLevels: function() { | 372 fetchZoomLevels: function() { |
325 cr.webUIListenerCallback('onZoomLevelsChanged', this.zoomList_); | 373 cr.webUIListenerCallback('onZoomLevelsChanged', this.zoomList_); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 /** @override */ | 421 /** @override */ |
374 removeProtocolHandler: function() { | 422 removeProtocolHandler: function() { |
375 this.methodCalled('removeProtocolHandler', arguments); | 423 this.methodCalled('removeProtocolHandler', arguments); |
376 }, | 424 }, |
377 | 425 |
378 /** @override */ | 426 /** @override */ |
379 updateIncognitoStatus: function() { | 427 updateIncognitoStatus: function() { |
380 this.methodCalled('updateIncognitoStatus', arguments); | 428 this.methodCalled('updateIncognitoStatus', arguments); |
381 } | 429 } |
382 }; | 430 }; |
OLD | NEW |