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'; |
7 | 8 |
8 var wallpaperPickerWindow; | 9 var wallpaperPickerWindow; |
9 | 10 |
10 var surpriseWallpaper = null; | 11 var surpriseWallpaper = null; |
11 | 12 |
12 function SurpriseWallpaper() { | 13 function SurpriseWallpaper() { |
13 } | 14 } |
14 | 15 |
15 /** | 16 /** |
16 * Gets SurpriseWallpaper instance. In case it hasn't been initialized, a new | 17 * 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... |
264 WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout, | 265 WallpaperUtil.setOnlineWallpaper(newValue.url, newValue.layout, |
265 function() {}, function() {}); | 266 function() {}, function() {}); |
266 } | 267 } |
267 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey, | 268 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey, |
268 newValue, false); | 269 newValue, false); |
269 } | 270 } |
270 }); | 271 }); |
271 } | 272 } |
272 }); | 273 }); |
273 | 274 |
274 chrome.alarms.onAlarm.addListener(function() { | 275 chrome.alarms.onAlarm.addListener(function(alarm) { |
275 SurpriseWallpaper.getInstance().next(); | 276 if (alarm.name === SURPRISE_ME_ALARM_NAME) { |
| 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 } |
276 }); | 287 }); |
| 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 |