12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch(function() { 6a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 7a3f7b4e666c476898878fa745f637129375cd889Ben Murdochwindow.buildbot = window.buildbot || {}; 8a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 9a3f7b4e666c476898878fa745f637129375cd889Ben Murdochbuildbot.PrefStore = function() { 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) this.defaults_ = {prefs: {use_notifications: false, 11a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch try_job_username: null}}; 12a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch}; 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 14a3f7b4e666c476898878fa745f637129375cd889Ben Murdochbuildbot.PrefStore.prototype = { 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) get_: function(key, callback) { 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) chrome.storage.sync.get(this.defaults_, 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) function (storage) { 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) callback(storage.prefs[key]); 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }); 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }, 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) set_: function(key, value) { 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) chrome.storage.sync.get(this.defaults_, 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) function (storage) { 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) storage.prefs[key] = value; 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) chrome.storage.sync.set(storage); 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }); 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }, 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) getUseNotifications: function(callback) { 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) this.get_("use_notifications", callback); 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }, 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) setUseNotifications: function(use_notifications) { 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) this.set_("use_notifications", use_notifications); 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }, 372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) getTryJobUsername: function(callback) { 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) this.get_("try_job_username", callback); 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }, 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) setTryJobUsername: function(try_job_username) { 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) this.set_("try_job_username", try_job_username); 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 46a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 47a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch})(); 48