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