| 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 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 FileManager.prototype.onTasksFound_ = function(selection, tasksList) { | 2081 FileManager.prototype.onTasksFound_ = function(selection, tasksList) { |
| 2084 removeChildren(this.taskButtons_); | 2082 removeChildren(this.taskButtons_); |
| 2085 | 2083 |
| 2086 for (var i = 0; i < tasksList.length; i++) { | 2084 for (var i = 0; i < tasksList.length; i++) { |
| 2087 var task = tasksList[i]; | 2085 var task = tasksList[i]; |
| 2088 | 2086 |
| 2089 // Tweak images, titles of internal tasks. | 2087 // Tweak images, titles of internal tasks. |
| 2090 var task_parts = task.taskId.split('|'); | 2088 var task_parts = task.taskId.split('|'); |
| 2091 if (task_parts[0] == this.getExtensionId_()) { | 2089 if (task_parts[0] == this.getExtensionId_()) { |
| 2092 task.internal = true; | 2090 task.internal = true; |
| 2093 if (task_parts[1] == 'preview') { | 2091 if (task_parts[1] == 'play') { |
| 2094 // TODO(serya): This hack needed until task.iconUrl get working | 2092 // TODO(serya): This hack needed until task.iconUrl is working |
| 2095 // (see GetFileTasksFileBrowserFunction::RunImpl). | 2093 // (see GetFileTasksFileBrowserFunction::RunImpl). |
| 2096 task.iconUrl = | |
| 2097 chrome.extension.getURL('images/icon_preview_16x16.png'); | |
| 2098 task.title = str('PREVIEW_IMAGE'); | |
| 2099 // Do not create the Slideshow button if the Gallery is present. | |
| 2100 if (str('ENABLE_PHOTO_EDITOR')) continue; | |
| 2101 } else if (task_parts[1] == 'play') { | |
| 2102 task.iconUrl = | 2094 task.iconUrl = |
| 2103 chrome.extension.getURL('images/icon_play_16x16.png'); | 2095 chrome.extension.getURL('images/icon_play_16x16.png'); |
| 2104 task.title = str('PLAY_MEDIA').replace("&", ""); | 2096 task.title = str('PLAY_MEDIA').replace("&", ""); |
| 2105 } else if (task_parts[1] == 'enqueue') { | 2097 } else if (task_parts[1] == 'enqueue') { |
| 2106 task.iconUrl = | 2098 task.iconUrl = |
| 2107 chrome.extension.getURL('images/icon_add_to_queue_16x16.png'); | 2099 chrome.extension.getURL('images/icon_add_to_queue_16x16.png'); |
| 2108 task.title = str('ENQUEUE'); | 2100 task.title = str('ENQUEUE'); |
| 2109 } else if (task_parts[1] == 'mount-archive') { | 2101 } else if (task_parts[1] == 'mount-archive') { |
| 2110 task.iconUrl = | 2102 task.iconUrl = |
| 2111 chrome.extension.getURL('images/icon_mount_archive_16x16.png'); | 2103 chrome.extension.getURL('images/icon_mount_archive_16x16.png'); |
| 2112 task.title = str('MOUNT_ARCHIVE'); | 2104 task.title = str('MOUNT_ARCHIVE'); |
| 2113 } else if (task_parts[1] == 'gallery') { | 2105 } else if (task_parts[1] == 'gallery') { |
| 2114 task.iconUrl = | 2106 task.iconUrl = |
| 2115 chrome.extension.getURL('images/icon_preview_16x16.png'); | 2107 chrome.extension.getURL('images/icon_preview_16x16.png'); |
| 2116 task.title = str('GALLERY'); | 2108 task.title = str('GALLERY'); |
| 2117 task.allTasks = tasksList; | 2109 task.allTasks = tasksList; |
| 2118 | |
| 2119 // Skip the button creation. | |
| 2120 if (!str('ENABLE_PHOTO_EDITOR')) continue; | |
| 2121 this.galleryTask_ = task; | 2110 this.galleryTask_ = task; |
| 2122 } | 2111 } |
| 2123 } | 2112 } |
| 2124 this.renderTaskButton_(task); | 2113 this.renderTaskButton_(task); |
| 2125 } | 2114 } |
| 2126 | 2115 |
| 2127 // These are done in separate functions, as the checks require | 2116 // These are done in separate functions, as the checks require |
| 2128 // asynchronous function calls. | 2117 // asynchronous function calls. |
| 2129 this.maybeRenderUnmountTask_(selection); | 2118 this.maybeRenderUnmountTask_(selection); |
| 2130 this.maybeRenderFormattingTask_(selection); | 2119 this.maybeRenderFormattingTask_(selection); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2299 if (rescanDirectoryNeeded) | 2288 if (rescanDirectoryNeeded) |
| 2300 self.rescanDirectory_(null, 300); | 2289 self.rescanDirectory_(null, 300); |
| 2301 }); | 2290 }); |
| 2302 }; | 2291 }; |
| 2303 | 2292 |
| 2304 /** | 2293 /** |
| 2305 * Event handler called when some internal task should be executed. | 2294 * Event handler called when some internal task should be executed. |
| 2306 */ | 2295 */ |
| 2307 FileManager.prototype.onFileTaskExecute_ = function(id, details) { | 2296 FileManager.prototype.onFileTaskExecute_ = function(id, details) { |
| 2308 var urls = details.urls; | 2297 var urls = details.urls; |
| 2309 if (id == 'preview') { | 2298 if (id == 'play' || id == 'enqueue') { |
| 2310 g_slideshow_data = urls; | |
| 2311 chrome.tabs.create({url: "slideshow.html"}); | |
| 2312 } else if (id == 'play' || id == 'enqueue') { | |
| 2313 chrome.fileBrowserPrivate.viewFiles(urls, id); | 2299 chrome.fileBrowserPrivate.viewFiles(urls, id); |
| 2314 } else if (id == 'mount-archive') { | 2300 } else if (id == 'mount-archive') { |
| 2315 for (var index = 0; index < urls.length; ++index) { | 2301 for (var index = 0; index < urls.length; ++index) { |
| 2316 this.mountRequests_.push(urls[index]); | 2302 this.mountRequests_.push(urls[index]); |
| 2317 chrome.fileBrowserPrivate.addMount(urls[index], 'file', {}); | 2303 chrome.fileBrowserPrivate.addMount(urls[index], 'file', {}); |
| 2318 } | 2304 } |
| 2319 } else if (id == 'unmount-archive') { | 2305 } else if (id == 'unmount-archive') { |
| 2320 for (var index = 0; index < urls.length; ++index) { | 2306 for (var index = 0; index < urls.length; ++index) { |
| 2321 chrome.fileBrowserPrivate.removeMount(urls[index]); | 2307 chrome.fileBrowserPrivate.removeMount(urls[index]); |
| 2322 } | 2308 } |
| (...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3990 }); | 3976 }); |
| 3991 }, onError); | 3977 }, onError); |
| 3992 | 3978 |
| 3993 function onError(err) { | 3979 function onError(err) { |
| 3994 console.log('Error while checking free space: ' + err); | 3980 console.log('Error while checking free space: ' + err); |
| 3995 setTimeout(doCheck, 1000 * 60); | 3981 setTimeout(doCheck, 1000 * 60); |
| 3996 } | 3982 } |
| 3997 } | 3983 } |
| 3998 } | 3984 } |
| 3999 })(); | 3985 })(); |
| OLD | NEW |