Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 23 matching lines...) Expand all Loading... | |
34 subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/excep tionrules.txt", | 34 subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/excep tionrules.txt", |
35 documentation_link: "https://adblockplus.org/redirect?link=%LINK%&lang=%LANG%" , | 35 documentation_link: "https://adblockplus.org/redirect?link=%LINK%&lang=%LANG%" , |
36 update_url_release: "https://update.adblockplus.org/%NAME%/update.json?type=%T YPE%", | 36 update_url_release: "https://update.adblockplus.org/%NAME%/update.json?type=%T YPE%", |
37 update_url_devbuild: "https://adblockplus.org/devbuilds/%NAME%/update.json?typ e=%TYPE%", | 37 update_url_devbuild: "https://adblockplus.org/devbuilds/%NAME%/update.json?typ e=%TYPE%", |
38 update_last_check: 0, | 38 update_last_check: 0, |
39 update_last_error: 0, | 39 update_last_error: 0, |
40 update_soft_expiration: 0, | 40 update_soft_expiration: 0, |
41 update_hard_expiration: 0, | 41 update_hard_expiration: 0, |
42 currentVersion: "0.0", | 42 currentVersion: "0.0", |
43 notificationdata: {}, | 43 notificationdata: {}, |
44 notificationurl: "https://notification.adblockplus.org/notification.json" | 44 notificationurl: "https://notification.adblockplus.org/notification.json", |
45 suppress_first_run_page: false, | |
46 disable_auto_updates: false | |
47 }; | |
48 | |
49 let isPreconfigurable = { | |
Felix Dahlke
2015/06/11 20:21:13
I'd prefer this to work the same way as in Firefox
Oleksandr
2015/06/12 10:47:57
Done.
| |
50 suppress_first_run_page: true, | |
51 disable_auto_updates: true | |
45 }; | 52 }; |
46 | 53 |
47 let values = Object.create(defaults); | 54 let values = Object.create(defaults); |
48 let path = _fileSystem.resolve("prefs.json"); | 55 let path = _fileSystem.resolve("prefs.json"); |
49 let listeners = []; | 56 let listeners = []; |
50 let isDirty = false; | 57 let isDirty = false; |
51 let isSaving = false; | 58 let isSaving = false; |
52 | 59 |
53 function defineProperty(key) | 60 function defineProperty(key) |
54 { | 61 { |
(...skipping 13 matching lines...) Expand all Loading... | |
68 | 75 |
69 for (let listener of listeners) | 76 for (let listener of listeners) |
70 listener(key); | 77 listener(key); |
71 }, | 78 }, |
72 enumerable: true | 79 enumerable: true |
73 }); | 80 }); |
74 } | 81 } |
75 | 82 |
76 function load() | 83 function load() |
77 { | 84 { |
85 // Set default prefs based on _preconfiguredPrefs | |
86 for (let key in _preconfiguredPrefs) | |
87 { | |
88 if (isPreconfigurable[key]) | |
89 { | |
90 values[key] = _preconfiguredPrefs[key]; | |
Eric
2015/06/10 17:48:16
Shouldn't this first check to see if there is a pr
Felix Dahlke
2015/06/11 20:21:13
Yes, should be: `if (key in _preconfiguredPrefs &&
Oleksandr
2015/06/12 07:36:14
Hm, am I missing something? I don't see why would
Felix Dahlke
2015/06/12 07:55:03
Yes you're right, guess me and Eric both missed th
| |
91 } | |
92 } | |
93 | |
78 _fileSystem.read(path, function(result) | 94 _fileSystem.read(path, function(result) |
79 { | 95 { |
80 // prefs.json is expected to be missing, ignore errors reading file | 96 // prefs.json is expected to be missing, ignore errors reading file |
81 if (!result.error) | 97 if (!result.error) |
82 { | 98 { |
83 try | 99 try |
84 { | 100 { |
85 let data = JSON.parse(result.content); | 101 let data = JSON.parse(result.content); |
86 for (let key in data) | 102 for (let key in data) |
87 if (key in defaults) | 103 if (key in defaults) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 let index = listeners.indexOf(listener); | 144 let index = listeners.indexOf(listener); |
129 if (index >= 0) | 145 if (index >= 0) |
130 listeners.splice(index, 1); | 146 listeners.splice(index, 1); |
131 }, | 147 }, |
132 }; | 148 }; |
133 | 149 |
134 for (let key in defaults) | 150 for (let key in defaults) |
135 defineProperty(key); | 151 defineProperty(key); |
136 | 152 |
137 load(); | 153 load(); |
OLD | NEW |