| 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 | 7 |
| 8 var wallpaperPickerWindow; | 8 var wallpaperPickerWindow; |
| 9 | 9 |
| 10 var surpriseWallpaper = null; | 10 var surpriseWallpaper = null; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 /** | 206 /** |
| 207 * Calculates when the next wallpaper change should be triggered. | 207 * Calculates when the next wallpaper change should be triggered. |
| 208 * @param {Date} now Current time. | 208 * @param {Date} now Current time. |
| 209 * @return {number} The time when next wallpaper change should happen. | 209 * @return {number} The time when next wallpaper change should happen. |
| 210 */ | 210 */ |
| 211 SurpriseWallpaper.prototype.nextUpdateTime = function(now) { | 211 SurpriseWallpaper.prototype.nextUpdateTime = function(now) { |
| 212 var nextUpdate = new Date(now.setDate(now.getDate() + 1)).toDateString(); | 212 var nextUpdate = new Date(now.setDate(now.getDate() + 1)).toDateString(); |
| 213 return new Date(nextUpdate).getTime(); | 213 return new Date(nextUpdate).getTime(); |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 /** |
| 217 * Enables surprise me wallpaper. |
| 218 */ |
| 219 SurpriseWallpaper.prototype.enableSurpriseMe = function() { |
| 220 Constants.WallpaperSyncStorage.get(Constants.AccessSurpriseMeEnabledKey, |
| 221 function(items) { |
| 222 if (!items.hasProperty(Constants.AccessSurpriseMeEnabledKey) || |
| 223 !items[Constants.AccessSurpriseMeEnabledKey]) { |
| 224 WallpaperUtil.saveToStorage(Constants.AccessSurpriseMeEnabledKey, |
| 225 true, true, NULL); |
| 226 } |
| 227 }); |
| 228 }; |
| 229 |
| 216 chrome.app.runtime.onLaunched.addListener(function() { | 230 chrome.app.runtime.onLaunched.addListener(function() { |
| 217 if (wallpaperPickerWindow && !wallpaperPickerWindow.contentWindow.closed) { | 231 if (wallpaperPickerWindow && !wallpaperPickerWindow.contentWindow.closed) { |
| 218 wallpaperPickerWindow.focus(); | 232 wallpaperPickerWindow.focus(); |
| 219 chrome.wallpaperPrivate.minimizeInactiveWindows(); | 233 chrome.wallpaperPrivate.minimizeInactiveWindows(); |
| 220 return; | 234 return; |
| 221 } | 235 } |
| 222 | 236 |
| 223 chrome.app.window.create('main.html', { | 237 chrome.app.window.create('main.html', { |
| 224 frame: 'none', | 238 frame: 'none', |
| 225 width: WALLPAPER_PICKER_WIDTH, | 239 width: WALLPAPER_PICKER_WIDTH, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey, | 284 WallpaperUtil.saveToStorage(Constants.AccessLocalWallpaperInfoKey, |
| 271 newValue, false); | 285 newValue, false); |
| 272 } | 286 } |
| 273 }); | 287 }); |
| 274 } | 288 } |
| 275 }); | 289 }); |
| 276 | 290 |
| 277 chrome.alarms.onAlarm.addListener(function() { | 291 chrome.alarms.onAlarm.addListener(function() { |
| 278 SurpriseWallpaper.getInstance().next(); | 292 SurpriseWallpaper.getInstance().next(); |
| 279 }); | 293 }); |
| OLD | NEW |