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: { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 * A test version of SiteSettingsPrefsBrowserProxy. Provides helper methods | 43 * A test version of SiteSettingsPrefsBrowserProxy. Provides helper methods |
44 * 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 |
45 * specifying mock responses. | 45 * specifying mock responses. |
46 * | 46 * |
47 * @constructor | 47 * @constructor |
48 * @implements {settings.SiteSettingsPrefsBrowserProxy} | 48 * @implements {settings.SiteSettingsPrefsBrowserProxy} |
49 * @extends {settings.TestBrowserProxy} | 49 * @extends {settings.TestBrowserProxy} |
50 */ | 50 */ |
51 var TestSiteSettingsPrefsBrowserProxy = function() { | 51 var TestSiteSettingsPrefsBrowserProxy = function() { |
52 settings.TestBrowserProxy.call(this, [ | 52 settings.TestBrowserProxy.call(this, [ |
| 53 'fetchZoomLevels', |
53 'getDefaultValueForContentType', | 54 'getDefaultValueForContentType', |
54 'getExceptionList', | 55 'getExceptionList', |
| 56 'removeZoomLevel', |
55 'resetCategoryPermissionForOrigin', | 57 'resetCategoryPermissionForOrigin', |
56 'setCategoryPermissionForOrigin', | 58 'setCategoryPermissionForOrigin', |
57 'setDefaultValueForContentType', | 59 'setDefaultValueForContentType', |
58 ]); | 60 ]); |
59 | 61 |
60 /** @private {!SiteSettingsPref} */ | 62 /** @private {!SiteSettingsPref} */ |
61 this.prefs_ = prefsEmpty; | 63 this.prefs_ = prefsEmpty; |
| 64 |
| 65 /** @private {!Array<ZoomLevelEntry>} */ |
| 66 this.zoomList_ = []; |
62 }; | 67 }; |
63 | 68 |
64 // TODO(finnur): Modify the tests so that most of the code this class implements | |
65 // can be ripped out. | |
66 TestSiteSettingsPrefsBrowserProxy.prototype = { | 69 TestSiteSettingsPrefsBrowserProxy.prototype = { |
67 __proto__: settings.TestBrowserProxy.prototype, | 70 __proto__: settings.TestBrowserProxy.prototype, |
68 | 71 |
69 /** | 72 /** |
70 * Sets the prefs to use when testing. | 73 * Sets the prefs to use when testing. |
71 * @param {!SiteSettingsPref} prefs The prefs to set. | 74 * @param {!SiteSettingsPref} prefs The prefs to set. |
72 */ | 75 */ |
73 setPrefs: function(prefs) { | 76 setPrefs: function(prefs) { |
74 this.prefs_ = prefs; | 77 this.prefs_ = prefs; |
75 | 78 |
76 // Notify all listeners that their data may be out of date. | 79 // Notify all listeners that their data may be out of date. |
77 for (var type in settings.ContentSettingsTypes) { | 80 for (var type in settings.ContentSettingsTypes) { |
78 cr.webUIListenerCallback( | 81 cr.webUIListenerCallback( |
79 'contentSettingSitePermissionChanged', | 82 'contentSettingSitePermissionChanged', |
80 settings.ContentSettingsTypes[type], | 83 settings.ContentSettingsTypes[type], |
81 ''); | 84 ''); |
82 } | 85 } |
83 }, | 86 }, |
84 | 87 |
| 88 /** |
| 89 * Sets the prefs to use when testing. |
| 90 * @param !Array<ZoomLevelEntry> list The zoom list to set. |
| 91 */ |
| 92 setZoomList: function(list) { |
| 93 this.zoomList_ = list; |
| 94 }, |
| 95 |
85 /** @override */ | 96 /** @override */ |
86 setDefaultValueForContentType: function(contentType, defaultValue) { | 97 setDefaultValueForContentType: function(contentType, defaultValue) { |
87 this.methodCalled( | 98 this.methodCalled( |
88 'setDefaultValueForContentType', [contentType, defaultValue]); | 99 'setDefaultValueForContentType', [contentType, defaultValue]); |
89 }, | 100 }, |
90 | 101 |
91 /** @override */ | 102 /** @override */ |
92 getDefaultValueForContentType: function(contentType) { | 103 getDefaultValueForContentType: function(contentType) { |
93 this.methodCalled('getDefaultValueForContentType', contentType); | 104 this.methodCalled('getDefaultValueForContentType', contentType); |
94 | 105 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return Promise.resolve(); | 189 return Promise.resolve(); |
179 }, | 190 }, |
180 | 191 |
181 /** @override */ | 192 /** @override */ |
182 setCategoryPermissionForOrigin: function( | 193 setCategoryPermissionForOrigin: function( |
183 primaryPattern, secondaryPattern, contentType, value, incognito) { | 194 primaryPattern, secondaryPattern, contentType, value, incognito) { |
184 this.methodCalled('setCategoryPermissionForOrigin', | 195 this.methodCalled('setCategoryPermissionForOrigin', |
185 [primaryPattern, secondaryPattern, contentType, value]); | 196 [primaryPattern, secondaryPattern, contentType, value]); |
186 return Promise.resolve(); | 197 return Promise.resolve(); |
187 }, | 198 }, |
| 199 |
| 200 /** @override */ |
| 201 fetchZoomLevels: function() { |
| 202 cr.webUIListenerCallback('onZoomLevelsChanged', this.zoomList_); |
| 203 this.methodCalled('fetchZoomLevels'); |
| 204 }, |
| 205 |
| 206 /** @override */ |
| 207 removeZoomLevel: function(host) { |
| 208 this.methodCalled('removeZoomLevel', [host]); |
| 209 }, |
188 }; | 210 }; |
OLD | NEW |