forked from GoogleChrome/chrome-extensions-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
47 lines (37 loc) · 1.17 KB
/
prefs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
window.buildbot = window.buildbot || {};
buildbot.PrefStore = function() {
this.defaults_ = {prefs: {use_notifications: false,
try_job_username: null}};
};
buildbot.PrefStore.prototype = {
get_: function(key, callback) {
chrome.storage.sync.get(this.defaults_,
function (storage) {
callback(storage.prefs[key]);
});
},
set_: function(key, value) {
chrome.storage.sync.get(this.defaults_,
function (storage) {
storage.prefs[key] = value;
chrome.storage.sync.set(storage);
});
},
getUseNotifications: function(callback) {
this.get_("use_notifications", callback);
},
setUseNotifications: function(use_notifications) {
this.set_("use_notifications", use_notifications);
},
getTryJobUsername: function(callback) {
this.get_("try_job_username", callback);
},
setTryJobUsername: function(try_job_username) {
this.set_("try_job_username", try_job_username);
}
};
})();