OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var WALLPAPER_PICKER_WIDTH = 574; | 5 var WALLPAPER_PICKER_WIDTH = 574; |
6 var WALLPAPER_PICKER_HEIGHT = 420; | 6 var WALLPAPER_PICKER_HEIGHT = 420; |
7 var SURPRISE_ME_ALARM_NAME = 'DefaultEnableSurpriseMe'; | |
8 | 7 |
9 var wallpaperPickerWindow; | 8 var wallpaperPickerWindow; |
10 | 9 |
11 var surpriseWallpaper = null; | 10 var surpriseWallpaper = null; |
12 | 11 |
13 function SurpriseWallpaper() { | 12 function SurpriseWallpaper() { |
14 } | 13 } |
15 | 14 |
16 /** | 15 /** |
17 * Gets SurpriseWallpaper instance. In case it hasn't been initialized, a new | 16 * Gets SurpriseWallpaper instance. In case it hasn't been initialized, a new |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout, | 264 WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout, |
266 function() {}, function() {}); | 265 function() {}, function() {}); |
267 } | 266 } |
268 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey, | 267 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey, |
269 newValue, false); | 268 newValue, false); |
270 } | 269 } |
271 }); | 270 }); |
272 } | 271 } |
273 }); | 272 }); |
274 | 273 |
275 chrome.alarms.onAlarm.addListener(function(alarm) { | 274 chrome.alarms.onAlarm.addListener(function() { |
276 if (alarm.name === SURPRISE_ME_ALARM_NAME) { | 275 SurpriseWallpaper.getInstance().next(); |
277 Constants.WallpaperSyncStorage.get(Constants.AccessSurpriseMeEnabledKey, | |
278 function(items) { | |
279 if (!items.hasOwnProperty(Constants.AccessSurpriseMeEnabledKey)) { | |
280 WallpaperUtil.saveToStorage(Constants.AccessSurpriseMeEnabledKey, | |
281 true, true); | |
282 } | |
283 }); | |
284 } else { | |
285 SurpriseWallpaper.getInstance().next(); | |
286 } | |
287 }); | 276 }); |
288 | |
289 /** | |
290 * Enables surprise me wallpaper iff it has not already been configured. | |
291 */ | |
292 chrome.wallpaperPrivate.onRequestEnableSurpriseMe.addListener(function() { | |
293 chrome.alarms.create(SURPRISE_ME_ALARM_NAME, {delayInMinutes: 5}); | |
294 }); | |
OLD | NEW |