Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Setting the src of an img to an empty string can crash the browser, so we | 5 // Setting the src of an img to an empty string can crash the browser, so we |
| 6 // use an empty 1x1 gif instead. | 6 // use an empty 1x1 gif instead. |
| 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' | 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' |
| 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; | 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; |
| 9 | 9 |
| 10 var g_slideshow_data = null; | |
| 11 | |
| 12 // If directory files changes too often, don't rescan directory more than once | 10 // If directory files changes too often, don't rescan directory more than once |
| 13 // per specified interval | 11 // per specified interval |
| 14 const SIMULTANEOUS_RESCAN_INTERVAL = 1000; | 12 const SIMULTANEOUS_RESCAN_INTERVAL = 1000; |
| 15 | 13 |
| 16 /** | 14 /** |
| 17 * FileManager constructor. | 15 * FileManager constructor. |
| 18 * | 16 * |
| 19 * FileManager objects encapsulate the functionality of the file selector | 17 * FileManager objects encapsulate the functionality of the file selector |
| 20 * dialogs, as well as the full screen file manager application (though the | 18 * dialogs, as well as the full screen file manager application (though the |
| 21 * latter is not yet implemented). | 19 * latter is not yet implemented). |
| (...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2075 FileManager.prototype.onTasksFound_ = function(selection, tasksList) { | 2073 FileManager.prototype.onTasksFound_ = function(selection, tasksList) { |
| 2076 removeChildren(this.taskButtons_); | 2074 removeChildren(this.taskButtons_); |
| 2077 | 2075 |
| 2078 for (var i = 0; i < tasksList.length; i++) { | 2076 for (var i = 0; i < tasksList.length; i++) { |
| 2079 var task = tasksList[i]; | 2077 var task = tasksList[i]; |
| 2080 | 2078 |
| 2081 // Tweak images, titles of internal tasks. | 2079 // Tweak images, titles of internal tasks. |
| 2082 var task_parts = task.taskId.split('|'); | 2080 var task_parts = task.taskId.split('|'); |
| 2083 if (task_parts[0] == this.getExtensionId_()) { | 2081 if (task_parts[0] == this.getExtensionId_()) { |
| 2084 task.internal = true; | 2082 task.internal = true; |
| 2085 if (task_parts[1] == 'preview') { | 2083 if (task_parts[1] == 'play') { |
| 2086 // TODO(serya): This hack needed until task.iconUrl get working | |
|
dgozman
2011/12/05 11:47:34
I think, you should keep this TODO (just move it b
Vladislav Kaznacheev
2011/12/05 13:40:11
Done.
| |
| 2087 // (see GetFileTasksFileBrowserFunction::RunImpl). | |
| 2088 task.iconUrl = | |
| 2089 chrome.extension.getURL('images/icon_preview_16x16.png'); | |
| 2090 task.title = str('PREVIEW_IMAGE'); | |
| 2091 // Do not create the Slideshow button if the Gallery is present. | |
| 2092 if (str('ENABLE_PHOTO_EDITOR')) continue; | |
| 2093 } else if (task_parts[1] == 'play') { | |
| 2094 task.iconUrl = | 2084 task.iconUrl = |
| 2095 chrome.extension.getURL('images/icon_play_16x16.png'); | 2085 chrome.extension.getURL('images/icon_play_16x16.png'); |
| 2096 task.title = str('PLAY_MEDIA').replace("&", ""); | 2086 task.title = str('PLAY_MEDIA').replace("&", ""); |
| 2097 } else if (task_parts[1] == 'enqueue') { | 2087 } else if (task_parts[1] == 'enqueue') { |
| 2098 task.iconUrl = | 2088 task.iconUrl = |
| 2099 chrome.extension.getURL('images/icon_add_to_queue_16x16.png'); | 2089 chrome.extension.getURL('images/icon_add_to_queue_16x16.png'); |
| 2100 task.title = str('ENQUEUE'); | 2090 task.title = str('ENQUEUE'); |
| 2101 } else if (task_parts[1] == 'mount-archive') { | 2091 } else if (task_parts[1] == 'mount-archive') { |
| 2102 task.iconUrl = | 2092 task.iconUrl = |
| 2103 chrome.extension.getURL('images/icon_mount_archive_16x16.png'); | 2093 chrome.extension.getURL('images/icon_mount_archive_16x16.png'); |
| 2104 task.title = str('MOUNT_ARCHIVE'); | 2094 task.title = str('MOUNT_ARCHIVE'); |
| 2105 } else if (task_parts[1] == 'gallery') { | 2095 } else if (task_parts[1] == 'gallery') { |
| 2106 task.iconUrl = | 2096 task.iconUrl = |
| 2107 chrome.extension.getURL('images/icon_preview_16x16.png'); | 2097 chrome.extension.getURL('images/icon_preview_16x16.png'); |
| 2108 task.title = str('GALLERY'); | 2098 task.title = str('GALLERY'); |
| 2109 task.allTasks = tasksList; | 2099 task.allTasks = tasksList; |
| 2110 | |
| 2111 // Skip the button creation. | |
| 2112 if (!str('ENABLE_PHOTO_EDITOR')) continue; | |
| 2113 this.galleryTask_ = task; | 2100 this.galleryTask_ = task; |
| 2114 } | 2101 } |
| 2115 } | 2102 } |
| 2116 this.renderTaskButton_(task); | 2103 this.renderTaskButton_(task); |
| 2117 } | 2104 } |
| 2118 | 2105 |
| 2119 // These are done in separate functions, as the checks require | 2106 // These are done in separate functions, as the checks require |
| 2120 // asynchronous function calls. | 2107 // asynchronous function calls. |
| 2121 this.maybeRenderUnmountTask_(selection); | 2108 this.maybeRenderUnmountTask_(selection); |
| 2122 this.maybeRenderFormattingTask_(selection); | 2109 this.maybeRenderFormattingTask_(selection); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2291 if (rescanDirectoryNeeded) | 2278 if (rescanDirectoryNeeded) |
| 2292 self.rescanDirectory_(null, 300); | 2279 self.rescanDirectory_(null, 300); |
| 2293 }); | 2280 }); |
| 2294 }; | 2281 }; |
| 2295 | 2282 |
| 2296 /** | 2283 /** |
| 2297 * Event handler called when some internal task should be executed. | 2284 * Event handler called when some internal task should be executed. |
| 2298 */ | 2285 */ |
| 2299 FileManager.prototype.onFileTaskExecute_ = function(id, details) { | 2286 FileManager.prototype.onFileTaskExecute_ = function(id, details) { |
| 2300 var urls = details.urls; | 2287 var urls = details.urls; |
| 2301 if (id == 'preview') { | 2288 if (id == 'play' || id == 'enqueue') { |
| 2302 g_slideshow_data = urls; | |
| 2303 chrome.tabs.create({url: "slideshow.html"}); | |
| 2304 } else if (id == 'play' || id == 'enqueue') { | |
| 2305 chrome.fileBrowserPrivate.viewFiles(urls, id); | 2289 chrome.fileBrowserPrivate.viewFiles(urls, id); |
| 2306 } else if (id == 'mount-archive') { | 2290 } else if (id == 'mount-archive') { |
| 2307 for (var index = 0; index < urls.length; ++index) { | 2291 for (var index = 0; index < urls.length; ++index) { |
| 2308 this.mountRequests_.push(urls[index]); | 2292 this.mountRequests_.push(urls[index]); |
| 2309 chrome.fileBrowserPrivate.addMount(urls[index], 'file', {}); | 2293 chrome.fileBrowserPrivate.addMount(urls[index], 'file', {}); |
| 2310 } | 2294 } |
| 2311 } else if (id == 'unmount-archive') { | 2295 } else if (id == 'unmount-archive') { |
| 2312 for (var index = 0; index < urls.length; ++index) { | 2296 for (var index = 0; index < urls.length; ++index) { |
| 2313 chrome.fileBrowserPrivate.removeMount(urls[index]); | 2297 chrome.fileBrowserPrivate.removeMount(urls[index]); |
| 2314 } | 2298 } |
| (...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3982 }); | 3966 }); |
| 3983 }, onError); | 3967 }, onError); |
| 3984 | 3968 |
| 3985 function onError(err) { | 3969 function onError(err) { |
| 3986 console.log('Error while checking free space: ' + err); | 3970 console.log('Error while checking free space: ' + err); |
| 3987 setTimeout(doCheck, 1000 * 60); | 3971 setTimeout(doCheck, 1000 * 60); |
| 3988 } | 3972 } |
| 3989 } | 3973 } |
| 3990 } | 3974 } |
| 3991 })(); | 3975 })(); |
| OLD | NEW |