Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/prefs.js

Issue 5442569823584256: Issue 189 - Implement API changes from #117, #153, #192 in Chrome (Closed)
Left Patch Set: Fixed calls in IO.copyFile() Created April 14, 2014, 8:39 p.m.
Right Patch Set: Fixed #301 fallout as well Created April 15, 2014, 7:03 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « lib/filesystem/io.js ('k') | lib/storage/io.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 throw new Error("Attempt to change preference type"); 74 throw new Error("Attempt to change preference type");
75 75
76 let stringified = JSON.stringify(newValue); 76 let stringified = JSON.stringify(newValue);
77 if (stringified != JSON.stringify(defaults[key])) 77 if (stringified != JSON.stringify(defaults[key]))
78 ext.storage[key] = stringified; 78 ext.storage[key] = stringified;
79 else 79 else
80 delete ext.storage[key]; 80 delete ext.storage[key];
81 81
82 value = newValue; 82 value = newValue;
83 83
84 for each (let listener in listeners) 84 for (let listener of listeners)
85 listener(key); 85 listener(key);
86 86
87 return value; 87 return value;
88 }); 88 });
89 } 89 }
90 90
91 91
92 let Prefs = exports.Prefs = { 92 let Prefs = exports.Prefs = {
93 addListener: function(listener) 93 addListener: function(listener)
94 { 94 {
95 if (listeners.indexOf(listener) < 0) 95 if (listeners.indexOf(listener) < 0)
96 listeners.push(listener); 96 listeners.push(listener);
97 }, 97 },
98 98
99 removeListener: function(listener) 99 removeListener: function(listener)
100 { 100 {
101 let index = listeners.indexOf(listener); 101 let index = listeners.indexOf(listener);
102 if (index >= 0) 102 if (index >= 0)
103 listeners.splice(index, 1); 103 listeners.splice(index, 1);
104 }, 104 },
105 }; 105 };
106 106
107 for (let key in defaults) 107 for (let key in defaults)
108 defineProperty(key); 108 defineProperty(key);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld