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 WallpaperUtil = { | 5 var WallpaperUtil = { |
6 strings: null, // Object that contains all the flags | 6 strings: null, // Object that contains all the flags |
7 syncFs: null, // syncFileSystem handler | 7 syncFs: null, // syncFileSystem handler |
8 webkitFs: null // webkitFileSystem handler | 8 webkitFs: null // webkitFileSystem handler |
9 }; | 9 }; |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 */ | 70 */ |
71 WallpaperUtil.deleteWallpaperFromSyncFS = function(wallpaperFilename) { | 71 WallpaperUtil.deleteWallpaperFromSyncFS = function(wallpaperFilename) { |
72 var thumbnailFilename = wallpaperFilename + | 72 var thumbnailFilename = wallpaperFilename + |
73 Constants.CustomWallpaperThumbnailSuffix; | 73 Constants.CustomWallpaperThumbnailSuffix; |
74 var success = function(fs) { | 74 var success = function(fs) { |
75 fs.root.getFile(wallpaperFilename, | 75 fs.root.getFile(wallpaperFilename, |
76 {create: false}, | 76 {create: false}, |
77 function(fe) { | 77 function(fe) { |
78 fe.remove(function() {}, null); | 78 fe.remove(function() {}, null); |
79 }, | 79 }, |
80 WallpaperUtil.onFileSystemError); | 80 function(e) { |
81 if (e.name != 'NotFoundError') | |
bshe
2016/01/13 18:43:17
would be good to add a command why we want to igno
xdai1
2016/01/14 23:03:51
Done.
| |
82 WallpaperUtil.onFileSystemError(e); | |
83 }); | |
81 fs.root.getFile(thumbnailFilename, | 84 fs.root.getFile(thumbnailFilename, |
82 {create: false}, | 85 {create: false}, |
83 function(fe) { | 86 function(fe) { |
84 fe.remove(function() {}, null); | 87 fe.remove(function() {}, null); |
85 }, | 88 }, |
86 WallpaperUtil.onFileSystemError); | 89 function(e) { |
90 if (e.name != 'NotFoundError') | |
91 WallpaperUtil.onFileSystemError(e); | |
92 }); | |
87 }; | 93 }; |
88 WallpaperUtil.requestSyncFS(success); | 94 WallpaperUtil.requestSyncFS(success); |
89 }; | 95 }; |
90 | 96 |
91 /** | 97 /** |
92 * Executes callback after requesting the sync settings. | 98 * Executes callback after requesting the sync settings. |
93 * @param {function} callback The callback will be executed. | 99 * @param {function} callback The callback will be executed. |
94 */ | 100 */ |
95 WallpaperUtil.enabledSyncThemesCallback = function(callback) { | 101 WallpaperUtil.enabledSyncThemesCallback = function(callback) { |
96 chrome.wallpaperPrivate.getSyncSetting(function(setting) { | 102 chrome.wallpaperPrivate.getSyncSetting(function(setting) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 wallpaperFilename, | 246 wallpaperFilename, |
241 function(thumbnailData) { | 247 function(thumbnailData) { |
242 // TODO(ranj): Ignore 'canceledWallpaper' error. | 248 // TODO(ranj): Ignore 'canceledWallpaper' error. |
243 if (chrome.runtime.lastError) { | 249 if (chrome.runtime.lastError) { |
244 console.error(chrome.runtime.lastError.message); | 250 console.error(chrome.runtime.lastError.message); |
245 return; | 251 return; |
246 } | 252 } |
247 WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename, | 253 WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename, |
248 reader.result, Constants.WallpaperDirNameEnum.ORIGINAL); | 254 reader.result, Constants.WallpaperDirNameEnum.ORIGINAL); |
249 WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename, | 255 WallpaperUtil.storeWallpaperToLocalFS(wallpaperFilename, |
250 reader.result, Constants.WallpaperDirNameEnum.THUMBNAIL); | 256 thumbnailData, Constants.WallpaperDirNameEnum.THUMBNAIL); |
bshe
2016/01/08 19:56:39
this seem to fix a different issue. do you mind la
xdai1
2016/01/08 20:17:48
Sure! I will separate it in another CL.
| |
251 if (onSuccess) | 257 if (onSuccess) |
252 onSuccess(); | 258 onSuccess(); |
253 }); | 259 }); |
254 }; | 260 }; |
255 reader.readAsArrayBuffer(file); | 261 reader.readAsArrayBuffer(file); |
256 }, WallpaperUtil.onFileSystemError); | 262 }, WallpaperUtil.onFileSystemError); |
257 }, function(e) {} // fail to read file, expected due to download delay | 263 }, function(e) {} // fail to read file, expected due to download delay |
258 ); | 264 ); |
259 }; | 265 }; |
260 WallpaperUtil.requestSyncFS(setWallpaperFromSyncCallback); | 266 WallpaperUtil.requestSyncFS(setWallpaperFromSyncCallback); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 * Runs chrome.test.sendMessage in test environment. Does nothing if running | 383 * Runs chrome.test.sendMessage in test environment. Does nothing if running |
378 * in production environment. | 384 * in production environment. |
379 * | 385 * |
380 * @param {string} message Test message to send. | 386 * @param {string} message Test message to send. |
381 */ | 387 */ |
382 WallpaperUtil.testSendMessage = function(message) { | 388 WallpaperUtil.testSendMessage = function(message) { |
383 var test = chrome.test || window.top.chrome.test; | 389 var test = chrome.test || window.top.chrome.test; |
384 if (test) | 390 if (test) |
385 test.sendMessage(message); | 391 test.sendMessage(message); |
386 }; | 392 }; |
OLD | NEW |