| 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 * An example empty pref. | 6 * An example empty pref. |
| 7 * @type {SiteSettingsPref} | 7 * @type {SiteSettingsPref} |
| 8 */ | 8 */ |
| 9 var prefsEmpty = { | 9 var prefsEmpty = { |
| 10 defaults: { | 10 defaults: { |
| 11 media_stream_camera: '', | 11 auto_downloads: '', |
| 12 background_sync: '', |
| 13 camera: '', |
| 12 cookies: '', | 14 cookies: '', |
| 13 fullscreen: '', | 15 fullscreen: '', |
| 14 geolocation: '', | 16 geolocation: '', |
| 15 javascript: '', | 17 javascript: '', |
| 16 media_stream_mic: '', | 18 keygen: '', |
| 19 mic: '', |
| 17 notifications: '', | 20 notifications: '', |
| 21 plugins: '', |
| 18 popups: '', | 22 popups: '', |
| 23 unsandboxed_plugins: '', |
| 19 }, | 24 }, |
| 20 exceptions: { | 25 exceptions: { |
| 21 media_stream_camera: [], | 26 auto_downloads: [], |
| 27 background_sync: [], |
| 28 camera: [], |
| 22 cookies: [], | 29 cookies: [], |
| 23 fullscreen: [], | 30 fullscreen: [], |
| 24 geolocation: [], | 31 geolocation: [], |
| 25 javascript: [], | 32 javascript: [], |
| 26 media_stream_mic: [], | 33 keygen: [], |
| 34 mic: [], |
| 27 notifications: [], | 35 notifications: [], |
| 36 plugins: [], |
| 28 popups: [], | 37 popups: [], |
| 38 unsandboxed_plugins: [], |
| 29 }, | 39 }, |
| 30 }; | 40 }; |
| 31 | 41 |
| 32 /** | 42 /** |
| 33 * A test version of SiteSettingsPrefsBrowserProxy. Provides helper methods | 43 * A test version of SiteSettingsPrefsBrowserProxy. Provides helper methods |
| 34 * for allowing tests to know when a method was called, as well as | 44 * for allowing tests to know when a method was called, as well as |
| 35 * specifying mock responses. | 45 * specifying mock responses. |
| 36 * | 46 * |
| 37 * @constructor | 47 * @constructor |
| 38 * @implements {settings.SiteSettingsPrefsBrowserProxy} | 48 * @implements {settings.SiteSettingsPrefsBrowserProxy} |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 /** @override */ | 85 /** @override */ |
| 76 setDefaultValueForContentType: function(contentType, defaultValue) { | 86 setDefaultValueForContentType: function(contentType, defaultValue) { |
| 77 this.methodCalled( | 87 this.methodCalled( |
| 78 'setDefaultValueForContentType', [contentType, defaultValue]); | 88 'setDefaultValueForContentType', [contentType, defaultValue]); |
| 79 }, | 89 }, |
| 80 | 90 |
| 81 /** @override */ | 91 /** @override */ |
| 82 getDefaultValueForContentType: function(contentType) { | 92 getDefaultValueForContentType: function(contentType) { |
| 83 this.methodCalled('getDefaultValueForContentType', contentType); | 93 this.methodCalled('getDefaultValueForContentType', contentType); |
| 84 | 94 |
| 85 if (contentType == settings.ContentSettingsTypes.CAMERA) { | 95 var pref = undefined; |
| 86 return Promise.resolve( | 96 if (contentType == settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS) { |
| 87 this.prefs_.defaults.media_stream_camera != 'block'); | 97 pref = this.prefs_.defaults.auto_downloads; |
| 98 } else if (contentType == settings.ContentSettingsTypes.BACKGROUND_SYNC) { |
| 99 pref = this.prefs_.background_sync; |
| 100 } else if (contentType == settings.ContentSettingsTypes.CAMERA) { |
| 101 pref = this.prefs_.defaults.camera; |
| 88 } else if (contentType == settings.ContentSettingsTypes.COOKIES) { | 102 } else if (contentType == settings.ContentSettingsTypes.COOKIES) { |
| 89 return Promise.resolve(this.prefs_.defaults.cookies != 'block'); | 103 pref = this.prefs_.defaults.cookies; |
| 90 } else if (contentType == settings.ContentSettingsTypes.FULLSCREEN) { | 104 } else if (contentType == settings.ContentSettingsTypes.FULLSCREEN) { |
| 91 return Promise.resolve(this.prefs_.defaults.fullscreen != 'block'); | 105 pref = this.prefs_.defaults.fullscreen; |
| 92 } else if (contentType == settings.ContentSettingsTypes.GEOLOCATION) { | 106 } else if (contentType == settings.ContentSettingsTypes.GEOLOCATION) { |
| 93 return Promise.resolve(this.prefs_.defaults.geolocation != 'block'); | 107 pref = this.prefs_.defaults.geolocation; |
| 94 } else if (contentType == settings.ContentSettingsTypes.IMAGES) { | 108 } else if (contentType == settings.ContentSettingsTypes.IMAGES) { |
| 95 return Promise.resolve(this.prefs_.defaults.images != 'block'); | 109 pref = this.prefs_.defaults.images; |
| 96 } else if (contentType == settings.ContentSettingsTypes.JAVASCRIPT) { | 110 } else if (contentType == settings.ContentSettingsTypes.JAVASCRIPT) { |
| 97 return Promise.resolve(this.prefs_.defaults.javascript != 'block'); | 111 pref = this.prefs_.defaults.javascript; |
| 112 } else if (contentType == settings.ContentSettingsTypes.KEYGEN) { |
| 113 pref = this.prefs_.defaults.keygen; |
| 98 } else if (contentType == settings.ContentSettingsTypes.MIC) { | 114 } else if (contentType == settings.ContentSettingsTypes.MIC) { |
| 99 return Promise.resolve(this.prefs_.defaults.media_stream_mic != 'block'); | 115 pref = this.prefs_.defaults.mic; |
| 100 } else if (contentType == settings.ContentSettingsTypes.NOTIFICATIONS) { | 116 } else if (contentType == settings.ContentSettingsTypes.NOTIFICATIONS) { |
| 101 return Promise.resolve(this.prefs_.defaults.notifications != 'block'); | 117 pref = this.prefs_.defaults.notifications; |
| 102 } else if (contentType == settings.ContentSettingsTypes.POPUPS) { | 118 } else if (contentType == settings.ContentSettingsTypes.POPUPS) { |
| 103 return Promise.resolve(this.prefs_.defaults.popups != 'block'); | 119 pref = this.prefs_.defaults.popups; |
| 120 } else if (contentType == settings.ContentSettingsTypes.PLUGINS) { |
| 121 pref = this.prefs_.defaults.plugins; |
| 122 } else if ( |
| 123 contentType == settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS) { |
| 124 pref = this.prefs_.defaults.unsandboxed_plugins; |
| 104 } else { | 125 } else { |
| 105 console.log('getDefault received unknown category: ' + contentType); | 126 console.log('getDefault received unknown category: ' + contentType); |
| 106 } | 127 } |
| 107 | 128 |
| 108 return Promise.resolve([]); | 129 assert(pref != undefined, 'Pref is missing for ' + contentType); |
| 130 return Promise.resolve(pref != 'block'); |
| 109 }, | 131 }, |
| 110 | 132 |
| 111 /** @override */ | 133 /** @override */ |
| 112 getExceptionList: function(contentType) { | 134 getExceptionList: function(contentType) { |
| 113 this.methodCalled('getExceptionList', contentType); | 135 this.methodCalled('getExceptionList', contentType); |
| 114 | 136 |
| 115 if (contentType == settings.ContentSettingsTypes.CAMERA) | 137 var pref = undefined; |
| 116 return Promise.resolve(this.prefs_.exceptions.media_stream_camera); | 138 if (contentType == settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS) |
| 139 pref = this.prefs_.exceptions.auto_downloads; |
| 140 else if (contentType == settings.ContentSettingsTypes.BACKGROUND_SYNC) |
| 141 pref = this.prefs_.exceptions.background_sync; |
| 142 else if (contentType == settings.ContentSettingsTypes.CAMERA) |
| 143 pref = this.prefs_.exceptions.camera; |
| 117 else if (contentType == settings.ContentSettingsTypes.COOKIES) | 144 else if (contentType == settings.ContentSettingsTypes.COOKIES) |
| 118 return Promise.resolve(this.prefs_.exceptions.cookies); | 145 pref = this.prefs_.exceptions.cookies; |
| 119 else if (contentType == settings.ContentSettingsTypes.FULLSCREEN) | 146 else if (contentType == settings.ContentSettingsTypes.FULLSCREEN) |
| 120 return Promise.resolve(this.prefs_.exceptions.fullscreen); | 147 pref = this.prefs_.exceptions.fullscreen; |
| 121 else if (contentType == settings.ContentSettingsTypes.GEOLOCATION) | 148 else if (contentType == settings.ContentSettingsTypes.GEOLOCATION) |
| 122 return Promise.resolve(this.prefs_.exceptions.geolocation); | 149 pref = this.prefs_.exceptions.geolocation; |
| 123 else if (contentType == settings.ContentSettingsTypes.IMAGES) | 150 else if (contentType == settings.ContentSettingsTypes.IMAGES) |
| 124 return Promise.resolve(this.prefs_.exceptions.images); | 151 pref = this.prefs_.exceptions.images; |
| 125 else if (contentType == settings.ContentSettingsTypes.JAVASCRIPT) | 152 else if (contentType == settings.ContentSettingsTypes.JAVASCRIPT) |
| 126 return Promise.resolve(this.prefs_.exceptions.javascript); | 153 pref = this.prefs_.exceptions.javascript; |
| 154 else if (contentType == settings.ContentSettingsTypes.KEYGEN) |
| 155 pref = this.prefs_.exceptions.keygen; |
| 127 else if (contentType == settings.ContentSettingsTypes.MIC) | 156 else if (contentType == settings.ContentSettingsTypes.MIC) |
| 128 return Promise.resolve(this.prefs_.exceptions.media_stream_mic); | 157 pref = this.prefs_.exceptions.mic; |
| 129 else if (contentType == settings.ContentSettingsTypes.NOTIFICATIONS) | 158 else if (contentType == settings.ContentSettingsTypes.NOTIFICATIONS) |
| 130 return Promise.resolve(this.prefs_.exceptions.notifications); | 159 pref = this.prefs_.exceptions.notifications; |
| 160 else if (contentType == settings.ContentSettingsTypes.PLUGINS) |
| 161 pref = this.prefs_.exceptions.plugins; |
| 131 else if (contentType == settings.ContentSettingsTypes.POPUPS) | 162 else if (contentType == settings.ContentSettingsTypes.POPUPS) |
| 132 return Promise.resolve(this.prefs_.exceptions.popups); | 163 pref = this.prefs_.exceptions.popups; |
| 164 else if (contentType == settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS) |
| 165 pref = this.prefs_.exceptions.unsandboxed_plugins; |
| 133 else | 166 else |
| 134 console.log('getExceptionList received unknown category: ' + contentType); | 167 console.log('getExceptionList received unknown category: ' + contentType); |
| 135 | 168 |
| 136 return Promise.resolve([]); | 169 assert(pref != undefined, 'Pref is missing for ' + contentType); |
| 170 return Promise.resolve(pref); |
| 137 }, | 171 }, |
| 138 | 172 |
| 139 /** @override */ | 173 /** @override */ |
| 140 resetCategoryPermissionForOrigin: function( | 174 resetCategoryPermissionForOrigin: function( |
| 141 primaryPattern, secondaryPattern, contentType) { | 175 primaryPattern, secondaryPattern, contentType) { |
| 142 this.methodCalled('resetCategoryPermissionForOrigin', | 176 this.methodCalled('resetCategoryPermissionForOrigin', |
| 143 [primaryPattern, secondaryPattern, contentType]); | 177 [primaryPattern, secondaryPattern, contentType]); |
| 144 return Promise.resolve(); | 178 return Promise.resolve(); |
| 145 }, | 179 }, |
| 146 | 180 |
| 147 /** @override */ | 181 /** @override */ |
| 148 setCategoryPermissionForOrigin: function( | 182 setCategoryPermissionForOrigin: function( |
| 149 primaryPattern, secondaryPattern, contentType, value) { | 183 primaryPattern, secondaryPattern, contentType, value) { |
| 150 this.methodCalled('setCategoryPermissionForOrigin', | 184 this.methodCalled('setCategoryPermissionForOrigin', |
| 151 [primaryPattern, secondaryPattern, contentType, value]); | 185 [primaryPattern, secondaryPattern, contentType, value]); |
| 152 return Promise.resolve(); | 186 return Promise.resolve(); |
| 153 }, | 187 }, |
| 154 }; | 188 }; |
| OLD | NEW |