Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 8036019: [filebrowser] Enable sharing in gallery. For now, show all image-related extensions as 'Sharing'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/image_editor/gallery.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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; 10 var g_slideshow_data = null;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 // The list of callbacks to be invoked during the directory rescan after 124 // The list of callbacks to be invoked during the directory rescan after
125 // all paste tasks are complete. 125 // all paste tasks are complete.
126 this.pasteSuccessCallbacks_ = []; 126 this.pasteSuccessCallbacks_ = [];
127 127
128 // The list of active mount points to distinct them from other directories. 128 // The list of active mount points to distinct them from other directories.
129 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { 129 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) {
130 self.mountPoints_ = mountPoints; 130 self.mountPoints_ = mountPoints;
131 }); 131 });
132 132
133 chrome.fileBrowserHandler.onExecute.addListener(
134 this.onFileTaskExecute_.bind(this));
135
136 this.initCommands_(); 133 this.initCommands_();
137 this.initDom_(); 134 this.initDom_();
138 this.initDialogType_(); 135 this.initDialogType_();
139 this.setupCurrentDirectory_(); 136 this.setupCurrentDirectory_();
140 137
141 this.summarizeSelection_(); 138 this.summarizeSelection_();
142 this.updatePreview_(); 139 this.updatePreview_();
143 140
144 this.dataModel_.sort('cachedMtime_', 'desc'); 141 this.dataModel_.sort('cachedMtime_', 'desc');
145 142
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 } else if (task_parts[1] == 'mount-archive') { 1661 } else if (task_parts[1] == 'mount-archive') {
1665 task.iconUrl = 1662 task.iconUrl =
1666 chrome.extension.getURL('images/icon_mount_archive_16x16.png'); 1663 chrome.extension.getURL('images/icon_mount_archive_16x16.png');
1667 task.title = str('MOUNT_ARCHIVE'); 1664 task.title = str('MOUNT_ARCHIVE');
1668 if (str('ENABLE_ARCHIVES') != 'true') 1665 if (str('ENABLE_ARCHIVES') != 'true')
1669 continue; 1666 continue;
1670 } else if (task_parts[1] == 'gallery') { 1667 } else if (task_parts[1] == 'gallery') {
1671 task.iconUrl = 1668 task.iconUrl =
1672 chrome.extension.getURL('images/icon_preview_16x16.png'); 1669 chrome.extension.getURL('images/icon_preview_16x16.png');
1673 task.title = str('GALLERY'); 1670 task.title = str('GALLERY');
1671 task.allTasks = tasksList;
1674 if (!GALLERY_ENABLED) continue; // Skip the button creation. 1672 if (!GALLERY_ENABLED) continue; // Skip the button creation.
1675 } 1673 }
1676 } 1674 }
1677 this.renderTaskButton_(task); 1675 this.renderTaskButton_(task);
1678 } 1676 }
1679 1677
1680 // These are done in separate functions, as the checks require 1678 // These are done in separate functions, as the checks require
1681 // asynchronous function calls. 1679 // asynchronous function calls.
1682 this.maybeRenderUnmountTask_(selection); 1680 this.maybeRenderUnmountTask_(selection);
1683 this.maybeRenderFormattingTask_(selection); 1681 this.maybeRenderFormattingTask_(selection);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 }; 1779 };
1782 1780
1783 FileManager.prototype.onDownloadsWarningClick_ = function(event) { 1781 FileManager.prototype.onDownloadsWarningClick_ = function(event) {
1784 chrome.tabs.create({url: DOWNLOADS_FAQ_URL}); 1782 chrome.tabs.create({url: DOWNLOADS_FAQ_URL});
1785 if (this.dialogType_ != FileManager.DialogType.FULL_PAGE) { 1783 if (this.dialogType_ != FileManager.DialogType.FULL_PAGE) {
1786 this.onCancel_(); 1784 this.onCancel_();
1787 } 1785 }
1788 }; 1786 };
1789 1787
1790 FileManager.prototype.onTaskButtonClicked_ = function(event) { 1788 FileManager.prototype.onTaskButtonClicked_ = function(event) {
1791 var task = event.srcElement.task; 1789 this.dispatchFileTask_(event.srcElement.task, this.selection.urls);
1790 };
1791
1792 FileManager.prototype.dispatchFileTask_ = function(task, urls) {
1792 if (task.internal) { 1793 if (task.internal) {
1793 // For internal tasks call the handler directly to avoid being handled 1794 // For internal tasks call the handler directly to avoid being handled
1794 // multiple times. 1795 // multiple times.
1795 var taskId = task.taskId.split('|')[1]; 1796 var taskId = task.taskId.split('|')[1];
1796 this.onFileTaskExecute_(taskId, {entries: this.selection.entries}); 1797 this.onFileTaskExecute_(taskId, {urls: urls, task: task});
1797 return; 1798 return;
1798 } 1799 }
1799 chrome.fileBrowserPrivate.executeTask(task.taskId, 1800 chrome.fileBrowserPrivate.executeTask(task.taskId, urls);
1800 this.selection.urls);
1801 }; 1801 };
1802 1802
1803 /** 1803 /**
1804 * Event handler called when some volume was mounted or unmouted. 1804 * Event handler called when some volume was mounted or unmouted.
1805 */ 1805 */
1806 FileManager.prototype.onMountCompleted_ = function(event) { 1806 FileManager.prototype.onMountCompleted_ = function(event) {
1807 var self = this; 1807 var self = this;
1808 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { 1808 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) {
1809 self.mountPoints_ = mountPoints; 1809 self.mountPoints_ = mountPoints;
1810 if (event.eventType == 'mount') { 1810 if (event.eventType == 'mount') {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 // when mounts location will be decided. 1845 // when mounts location will be decided.
1846 if (rescanDirectoryNeeded) 1846 if (rescanDirectoryNeeded)
1847 self.rescanDirectory_(null, 300); 1847 self.rescanDirectory_(null, 300);
1848 }); 1848 });
1849 }; 1849 };
1850 1850
1851 /** 1851 /**
1852 * Event handler called when some internal task should be executed. 1852 * Event handler called when some internal task should be executed.
1853 */ 1853 */
1854 FileManager.prototype.onFileTaskExecute_ = function(id, details) { 1854 FileManager.prototype.onFileTaskExecute_ = function(id, details) {
1855 var urls = details.entries.map(function(entry) { 1855 var urls = details.urls;
1856 return entry.toURL();
1857 });
1858 if (id == 'preview') { 1856 if (id == 'preview') {
1859 g_slideshow_data = urls; 1857 g_slideshow_data = urls;
1860 chrome.tabs.create({url: "slideshow.html"}); 1858 chrome.tabs.create({url: "slideshow.html"});
1861 } else if (id == 'play' || id == 'enqueue') { 1859 } else if (id == 'play' || id == 'enqueue') {
1862 chrome.fileBrowserPrivate.viewFiles(urls, id); 1860 chrome.fileBrowserPrivate.viewFiles(urls, id);
1863 } else if (id == 'mount-archive') { 1861 } else if (id == 'mount-archive') {
1864 for (var index = 0; index < urls.length; ++index) { 1862 for (var index = 0; index < urls.length; ++index) {
1865 this.mountRequests_.push(urls[index]); 1863 this.mountRequests_.push(urls[index]);
1866 chrome.fileBrowserPrivate.addMount(urls[index], 'file', {}); 1864 chrome.fileBrowserPrivate.addMount(urls[index], 'file', {});
1867 } 1865 }
1868 } else if (id == 'unmount-archive') { 1866 } else if (id == 'unmount-archive') {
1869 for (var index = 0; index < urls.length; ++index) { 1867 for (var index = 0; index < urls.length; ++index) {
1870 chrome.fileBrowserPrivate.removeMount(urls[index]); 1868 chrome.fileBrowserPrivate.removeMount(urls[index]);
1871 } 1869 }
1872 } else if (id == 'format-device') { 1870 } else if (id == 'format-device') {
1873 this.confirm.show(str('FORMATTING_WARNING'), function() { 1871 this.confirm.show(str('FORMATTING_WARNING'), function() {
1874 chrome.fileBrowserPrivate.formatDevice(urls[0]); 1872 chrome.fileBrowserPrivate.formatDevice(urls[0]);
1875 }); 1873 });
1876 } else if (id == 'gallery') { 1874 } else if (id == 'gallery') {
1877 this.openGallery_(urls); 1875 // Pass to gallery all possible tasks except the gallery itself.
1876 var noGallery = [];
1877 for (var index = 0; index < details.task.allTasks.length; index++) {
1878 var task = details.task.allTasks[index];
1879 if (task.taskId != this.getExtensionId_() + '|gallery') {
1880 // Add callback, so gallery can execute the task.
1881 task.execute = this.dispatchFileTask_.bind(this, task);
1882 noGallery.push(task);
1883 }
1884 }
1885 this.openGallery_(urls, noGallery);
1878 } 1886 }
1879 }; 1887 };
1880 1888
1881 FileManager.prototype.getDeviceNumber = function(entry) { 1889 FileManager.prototype.getDeviceNumber = function(entry) {
1882 if (!entry.isDirectory) return undefined; 1890 if (!entry.isDirectory) return undefined;
1883 for (var i = 0; i < this.mountPoints_.length; i++) { 1891 for (var i = 0; i < this.mountPoints_.length; i++) {
1884 if (normalizeAbsolutePath(entry.fullPath) == 1892 if (normalizeAbsolutePath(entry.fullPath) ==
1885 normalizeAbsolutePath(this.mountPoints_[i].mountPath)) { 1893 normalizeAbsolutePath(this.mountPoints_[i].mountPath)) {
1886 return i; 1894 return i;
1887 } 1895 }
1888 } 1896 }
1889 return undefined; 1897 return undefined;
1890 }; 1898 };
1891 1899
1892 FileManager.prototype.openGallery_ = function(urls) { 1900 FileManager.prototype.openGallery_ = function(urls, shareActions) {
1893 var self = this; 1901 var self = this;
1894 1902
1895 var galleryFrame = this.document_.createElement('iframe'); 1903 var galleryFrame = this.document_.createElement('iframe');
1896 galleryFrame.className = 'overlay-pane'; 1904 galleryFrame.className = 'overlay-pane';
1897 galleryFrame.scrolling = 'no'; 1905 galleryFrame.scrolling = 'no';
1898 1906
1899 galleryFrame.onload = function() { 1907 galleryFrame.onload = function() {
1900 galleryFrame.contentWindow.Gallery.open( 1908 galleryFrame.contentWindow.Gallery.open(
1901 self.currentDirEntry_, 1909 self.currentDirEntry_,
1902 urls, 1910 urls,
1903 function () { 1911 function () {
1904 // TODO(kaznacheev): keep selection. 1912 // TODO(kaznacheev): keep selection.
1905 self.rescanDirectoryNow_(); // Make sure new files show up. 1913 self.rescanDirectoryNow_(); // Make sure new files show up.
1906 self.dialogDom_.removeChild(galleryFrame); 1914 self.dialogDom_.removeChild(galleryFrame);
1907 }, 1915 },
1908 self.metadataProvider_); 1916 self.metadataProvider_,
1917 shareActions);
1909 }; 1918 };
1910 1919
1911 galleryFrame.src = 'js/image_editor/gallery.html'; 1920 galleryFrame.src = 'js/image_editor/gallery.html';
1912 this.dialogDom_.appendChild(galleryFrame); 1921 this.dialogDom_.appendChild(galleryFrame);
1913 }; 1922 };
1914 1923
1915 /** 1924 /**
1916 * Update the breadcrumb display to reflect the current directory. 1925 * Update the breadcrumb display to reflect the current directory.
1917 */ 1926 */
1918 FileManager.prototype.updateBreadcrumbs_ = function() { 1927 FileManager.prototype.updateBreadcrumbs_ = function() {
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 3399
3391 if (msg) { 3400 if (msg) {
3392 console.log('no no no'); 3401 console.log('no no no');
3393 this.alert.show(msg, onAccept); 3402 this.alert.show(msg, onAccept);
3394 return false; 3403 return false;
3395 } 3404 }
3396 3405
3397 return true; 3406 return true;
3398 }; 3407 };
3399 })(); 3408 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/image_editor/gallery.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698