diff options
7 files changed, 99 insertions, 44 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 7355d30..8f6aca2 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -12785,6 +12785,9 @@ Some features may be unavailable. Please check that the profile exists and you <message name="IDS_FILE_BROWSER_SEARCH_TEXT_LABEL" desc="Search text field label."> Search </message> + <message name="IDS_FILE_BROWSER_VIEW_LABEL" desc="View label."> + View + </message> <message name="IDS_FILE_BROWSER_DEFAULT_NEW_FOLDER_NAME" desc="The default name for a newly created folder."> New Folder diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc index bc6867f..2ac92fd 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc @@ -2141,6 +2141,7 @@ bool FileDialogStringsFunction::RunImpl() { SET_STRING("OPEN_LABEL", IDS_FILE_BROWSER_OPEN_LABEL); SET_STRING("SAVE_LABEL", IDS_FILE_BROWSER_SAVE_LABEL); SET_STRING("OK_LABEL", IDS_FILE_BROWSER_OK_LABEL); + SET_STRING("VIEW_LABEL", IDS_FILE_BROWSER_VIEW_LABEL); SET_STRING("DEFAULT_NEW_FOLDER_NAME", IDS_FILE_BROWSER_DEFAULT_NEW_FOLDER_NAME); diff --git a/chrome/browser/resources/file_manager/css/photo_import.css b/chrome/browser/resources/file_manager/css/photo_import.css index 91d4cc0..f38182f 100644 --- a/chrome/browser/resources/file_manager/css/photo_import.css +++ b/chrome/browser/resources/file_manager/css/photo_import.css @@ -182,29 +182,35 @@ button.import { /* Importing dialog styles */ .importing-dialog .cr-dialog-frame { - -webkit-box-align: center; -webkit-box-orient: horizontal; - display: -webkit-box; - padding: 10px 10px; + padding: 14px; } .importing-dialog .cr-dialog-frame .progress-container { -webkit-box-flex: 1; -webkit-box-orient: vertical; display: -webkit-box; - padding: 0 0 32px 10px; -} - -.importing-dialog .cr-dialog-text { - margin: 15px 0; } .importing-dialog .img-container { + display: -webkit-box; height: 120px; overflow: hidden; width: 120px; } +.importing-dialog .content { + -webkit-box-flex: 1; + -webkit-box-orient: vertical; + -webkit-margin-before: 14px; + -webkit-margin-start: 15px; + display: -webkit-box; +} + +.importing-dialog .cr-dialog-title { + display: none; +} + .importing-dialog .img-container[state=success]::after { background: -webkit-image-set( url('../images/common/check_circled.png') 1x, @@ -229,16 +235,3 @@ button.import { top: 0; width: 120px; } - -.importing-dialog button { - bottom: 10px; - font-size: 90%; - min-height: 26px; - min-width: 87px; - position: absolute; - right: 10px; -} - -.importing-dialog .progress-bar { - -webkit-box-flex: 1; -} diff --git a/chrome/browser/resources/file_manager/js/file_manager_commands.js b/chrome/browser/resources/file_manager/js/file_manager_commands.js index 5bfe9a5..e7fa055aa 100644 --- a/chrome/browser/resources/file_manager/js/file_manager_commands.js +++ b/chrome/browser/resources/file_manager/js/file_manager_commands.js @@ -174,11 +174,15 @@ Commands.formatCommand = { Commands.importCommand = { execute: function(event, rootsList) { var root = CommandUtil.getCommandRoot(event, rootsList); - - if (root) { - chrome.windows.create({url: chrome.extension.getURL('photo_import.html') + - '#' + PathUtil.getRootPath(root.fullPath), type: 'popup'}); - } + if (!root) + return; + + chrome.windows.getCurrent(undefined, function(window) { + chrome.windows.create( + { url: chrome.extension.getURL('photo_import.html') + + '?' + window.id + '#' + PathUtil.getRootPath(root.fullPath), + type: 'popup' }); + }.bind(this)); }, canExecute: function(event, rootsList) { event.canExecute = diff --git a/chrome/browser/resources/file_manager/js/photo/importing_dialog.js b/chrome/browser/resources/file_manager/js/photo/importing_dialog.js index 34098c3..d21f707 100644 --- a/chrome/browser/resources/file_manager/js/photo/importing_dialog.js +++ b/chrome/browser/resources/file_manager/js/photo/importing_dialog.js @@ -2,16 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - /** * ImportingDialog manages the import process (which is really a copying). * @param {HTMLElement} parentNode Node to be parent for this dialog. * @param {FileCopyManager} copyManager Copy manager isntance. * @param {MetadataCache} metadataCache Metadata cache. + * @param {number=} opt_parentWindowId Id of the parent window. * @constructor */ -function ImportingDialog(parentNode, copyManager, metadataCache) { +function ImportingDialog( + parentNode, copyManager, metadataCache, opt_parentWindowId) { cr.ui.dialogs.BaseDialog.call(this, parentNode); + this.parentWindowId_ = opt_parentWindowId; this.copyManager_ = copyManager; this.metadataCache_ = metadataCache; this.onCopyProgressBound_ = this.onCopyProgress_.bind(this); @@ -29,39 +31,53 @@ ImportingDialog.prototype.initDom_ = function() { cr.ui.dialogs.BaseDialog.prototype.initDom_.call(this); this.container_.classList.add('importing-dialog'); - this.frame_.textContent = ''; + + this.content_ = util.createChild(this.frame_, 'content'); + this.frame_.insertBefore(this.content_, this.frame_.firstChild); + this.content_.appendChild(this.text_); this.imageBox_ = util.createChild(this.frame_, 'img-container'); this.imageBox_.setAttribute('state', 'progress'); + this.frame_.insertBefore(this.imageBox_, this.frame_.firstChild); - var progressContainer = util.createChild(this.frame_, 'progress-container'); - progressContainer.appendChild(this.text_); - + var progressContainer = util.createChild(this.content_, 'progress-container'); this.progress_ = util.createChild(progressContainer, 'progress-bar'); util.createChild(this.progress_, 'progress-track smoothed'); + this.buttons_ = this.frame_.querySelector('.cr-dialog-buttons'); + this.content_.appendChild(this.buttons_); + + this.viewButton_ = util.createChild( + this.buttons_, 'cr-dialog-view', 'button'); + this.viewButton_.addEventListener('click', + this.onViewClick_.bind(this)); + this.buttons_.insertBefore(this.viewButton_, this.buttons_.firstChild); + + this.viewButton_.textContent = + loadTimeData.getString('VIEW_LABEL'); + this.viewButton_.hidden = true; this.cancelButton_.textContent = loadTimeData.getString('PHOTO_IMPORT_CANCEL_BUTTON'); - this.frame_.appendChild(this.cancelButton_); - this.okButton_.textContent = loadTimeData.getString('OK_LABEL'); + this.okButton_.hidden = true; }; /** * Shows dialog. * @param {Array.<FileEntry>} entries Entries to import. - * @param {DirectoryEntry} dir Directory to import to. + * @param {DirectoryEntry} destination Directory to import to. * @param {boolean} move Whether to move files instead of copying them. */ -ImportingDialog.prototype.show = function(entries, dir, move) { +ImportingDialog.prototype.show = function(entries, destination, move) { var message = loadTimeData.getString('PHOTO_IMPORT_IMPORTING'); cr.ui.dialogs.BaseDialog.prototype.show.call(this, message, null, null, null); this.error_ = false; this.entries_ = entries; - this.progress_.querySelector('.progress-track').style.width = '0'; + this.destination_ = destination; + this.progress_.querySelector('.progress-track').style.width = '0'; this.copyManager_.addEventListener('copy-progress', this.onCopyProgressBound_); @@ -70,12 +86,13 @@ ImportingDialog.prototype.show = function(entries, dir, move) { var files = entries.map(function(e) { return e.fullPath }).join('\n'); var operationInfo = { isCut: move ? 'true' : 'false', - isOnGData: PathUtil.getRootType(entries[0].fullPath) == RootType.GDATA, + isOnDrive: PathUtil.getRootType(entries[0].fullPath) == RootType.DRIVE, sourceDir: null, directories: '', files: files }; - this.copyManager_.paste(operationInfo, dir.fullPath, true); + this.copyManager_.paste(operationInfo, destination.fullPath, true); + }; /** @@ -124,6 +141,23 @@ ImportingDialog.prototype.onOkClick_ = function() { }; /** + * View button click event handler. Invokes the mosaic view. + * @private + */ +ImportingDialog.prototype.onViewClick_ = function() { + var url = util.platform.getURL('main.html') + + '?{%22gallery%22:%22mosaic%22}#' + this.destination_.fullPath; + if (!this.parentWindowId_ || + !util.redirectMainWindow(this.parentWindowId_, url)) { + // The parent window hasn't been found. Launch the url as a new window. + // TODO(mtomasz): Change it to chrome.fileBrowserPrivate.openNewWindow. + util.platform.createWindow(url); + } + this.hide(); + window.close(); +}; + +/** * Event handler for keydown event. * @param {Event} event The event. * @private @@ -157,8 +191,9 @@ ImportingDialog.prototype.onCopyProgress_ = function(event) { this.text_.textContent = loadTimeData.getString('PHOTO_IMPORT_IMPORT_COMPLETE'); this.imageBox_.setAttribute('state', 'success'); - this.frame_.removeChild(this.cancelButton_); - this.frame_.appendChild(this.okButton_); + this.cancelButton_.hidden = true; + this.viewButton_.hidden = false; + this.okButton_.hidden = false; break; case 'CANCELLED': @@ -170,8 +205,9 @@ ImportingDialog.prototype.onCopyProgress_ = function(event) { this.text_.textContent = loadTimeData.getString('PHOTO_IMPORT_IMPORTING_ERROR'); this.imageBox_.setAttribute('state', 'error'); - this.frame_.removeChild(this.cancelButton_); - this.frame_.appendChild(this.okButton_); + this.cancelButton_.hidden = true; + this.viewButton_.hidden = true; + this.okButton_.hidden = false; break; default: diff --git a/chrome/browser/resources/file_manager/js/photo/photo_import.js b/chrome/browser/resources/file_manager/js/photo/photo_import.js index ca4f127..42f3705 100644 --- a/chrome/browser/resources/file_manager/js/photo/photo_import.js +++ b/chrome/browser/resources/file_manager/js/photo/photo_import.js @@ -23,6 +23,7 @@ function PhotoImport(dom, filesystem, params) { this.mediaFilesList_ = null; this.destination_ = null; this.myPhotosDirectory_ = null; + this.parentWindowId_ = params.parentWindowId; this.initDom_(); this.initMyPhotos_(); @@ -51,8 +52,10 @@ PhotoImport.load = function(opt_filesystem, opt_params) { ImageUtil.metrics = metrics; var hash = location.hash ? location.hash.substr(1) : ''; + var query = location.search ? location.search.substr(1) : ''; var params = opt_params || {}; if (!params.source) params.source = hash; + if (!params.parentWindowId && query) params.parentWindowId = query; if (!params.metadataCache) params.metadataCache = MetadataCache.createFull(); function onFilesystem(filesystem) { @@ -111,7 +114,7 @@ PhotoImport.prototype.initDom_ = function() { this.onSelectionChanged_(); this.importingDialog_ = new ImportingDialog(this.dom_, this.copyManager_, - this.metadataCache_); + this.metadataCache_, this.parentWindowId_); var dialogs = cr.ui.dialogs; dialogs.BaseDialog.OK_LABEL = str('OK_LABEL'); diff --git a/chrome/browser/resources/file_manager/js/util.js b/chrome/browser/resources/file_manager/js/util.js index 3879358..693edc10 100644 --- a/chrome/browser/resources/file_manager/js/util.js +++ b/chrome/browser/resources/file_manager/js/util.js @@ -1262,3 +1262,18 @@ util.disableBrowserShortcutKeys = function(element) { } }); }; + +/** + * Makes a redirect to the specified Files.app's window from another window. + * @param {number} id Window id. + * @param {string} url Target url. + * @return {boolean} True if the window has been found. False otherwise. + */ +util.redirectMainWindow = function(id, url) { + var windowViews = chrome.extension.getViews({ windowId: parseInt(id) }); + if (!windowViews || windowViews.length === 0) + return false; + + windowViews[0].location.href = url; + return true; +}; |