| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This object encapsulates everything related to tasks execution. | 8 * This object encapsulates everything related to tasks execution. |
| 9 * | 9 * |
| 10 * @param {FileManager} fileManager FileManager instance. | 10 * @param {FileManager} fileManager FileManager instance. |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 true /* replace */, null /* keep path */, '' /* remove search. */); | 500 true /* replace */, null /* keep path */, '' /* remove search. */); |
| 501 } | 501 } |
| 502 | 502 |
| 503 var savedAppState = window.appState; | 503 var savedAppState = window.appState; |
| 504 var savedTitle = document.title; | 504 var savedTitle = document.title; |
| 505 | 505 |
| 506 // Push a temporary state which will be replaced every time the selection | 506 // Push a temporary state which will be replaced every time the selection |
| 507 // changes in the Gallery and popped when the Gallery is closed. | 507 // changes in the Gallery and popped when the Gallery is closed. |
| 508 util.updateAppState(false /*push*/); | 508 util.updateAppState(false /*push*/); |
| 509 | 509 |
| 510 var onClose = function(selectedUrls) { | 510 var onBack = function(selectedUrls) { |
| 511 fm.directoryModel_.selectUrls(selectedUrls); | 511 fm.directoryModel_.selectUrls(selectedUrls); |
| 512 if (util.platform.v2()) { | 512 if (util.platform.v2()) { |
| 513 fm.closeFilePopup_(); // Will call Gallery.unload. | 513 fm.closeFilePopup_(); // Will call Gallery.unload. |
| 514 window.appState = savedAppState; | 514 window.appState = savedAppState; |
| 515 util.saveAppState(); | 515 util.saveAppState(); |
| 516 document.title = savedTitle; | 516 document.title = savedTitle; |
| 517 } else { | 517 } else { |
| 518 window.history.back(1); // This will restore document.title. | 518 window.history.back(1); // This will restore document.title. |
| 519 } | 519 } |
| 520 }; | 520 }; |
| 521 | 521 |
| 522 var onClose = function() { |
| 523 fm.onClose(); |
| 524 }; |
| 525 |
| 526 var onMaximize = function() { |
| 527 fm.onMaximize(); |
| 528 }; |
| 529 |
| 522 galleryFrame.onload = function() { | 530 galleryFrame.onload = function() { |
| 523 fm.show_(); | 531 fm.show_(); |
| 524 galleryFrame.contentWindow.ImageUtil.metrics = metrics; | 532 galleryFrame.contentWindow.ImageUtil.metrics = metrics; |
| 525 window.galleryTestAPI = galleryFrame.contentWindow.galleryTestAPI; | 533 window.galleryTestAPI = galleryFrame.contentWindow.galleryTestAPI; |
| 526 | 534 |
| 527 // TODO(haruki): isOnReadonlyDirectory() only checks the permission for the | 535 // TODO(haruki): isOnReadonlyDirectory() only checks the permission for the |
| 528 // root. We should check more granular permission to know whether the file | 536 // root. We should check more granular permission to know whether the file |
| 529 // is writable or not. | 537 // is writable or not. |
| 530 var readonly = fm.isOnReadonlyDirectory(); | 538 var readonly = fm.isOnReadonlyDirectory(); |
| 531 var currentDir = fm.directoryModel_.getCurrentDirEntry(); | 539 var currentDir = fm.directoryModel_.getCurrentDirEntry(); |
| 532 var downloadsDir = fm.directoryModel_.getRootsList().item(0); | 540 var downloadsDir = fm.directoryModel_.getRootsList().item(0); |
| 533 var readonlyDirName = null; | 541 var readonlyDirName = null; |
| 534 if (readonly) { | 542 if (readonly) { |
| 535 readonlyDirName = fm.isOnDrive() ? | 543 readonlyDirName = fm.isOnDrive() ? |
| 536 PathUtil.getRootLabel(PathUtil.getRootPath(currentDir.fullPath)) : | 544 PathUtil.getRootLabel(PathUtil.getRootPath(currentDir.fullPath)) : |
| 537 fm.directoryModel_.getCurrentRootName(); | 545 fm.directoryModel_.getCurrentRootName(); |
| 538 } | 546 } |
| 539 | 547 |
| 540 var context = { | 548 var context = { |
| 541 // We show the root label in readonly warning (e.g. archive name). | 549 // We show the root label in readonly warning (e.g. archive name). |
| 542 readonlyDirName: readonlyDirName, | 550 readonlyDirName: readonlyDirName, |
| 543 curDirEntry: currentDir, | 551 curDirEntry: currentDir, |
| 544 saveDirEntry: readonly ? downloadsDir : null, | 552 saveDirEntry: readonly ? downloadsDir : null, |
| 545 searchResults: fm.directoryModel_.isSearching(), | 553 searchResults: fm.directoryModel_.isSearching(), |
| 546 metadataCache: fm.metadataCache_, | 554 metadataCache: fm.metadataCache_, |
| 547 pageState: this.params_, | 555 pageState: this.params_, |
| 556 onBack: onBack, |
| 548 onClose: onClose, | 557 onClose: onClose, |
| 558 onMaximize: onMaximize, |
| 549 onThumbnailError: function(imageURL) { | 559 onThumbnailError: function(imageURL) { |
| 550 fm.metadataCache_.refreshFileMetadata(imageURL); | 560 fm.metadataCache_.refreshFileMetadata(imageURL); |
| 551 }, | 561 }, |
| 552 displayStringFunction: strf | 562 displayStringFunction: strf |
| 553 }; | 563 }; |
| 554 galleryFrame.contentWindow.Gallery.open(context, allUrls, urls); | 564 galleryFrame.contentWindow.Gallery.open(context, allUrls, urls); |
| 555 }.bind(this); | 565 }.bind(this); |
| 556 | 566 |
| 557 galleryFrame.src = 'gallery.html'; | 567 galleryFrame.src = 'gallery.html'; |
| 558 fm.openFilePopup_(galleryFrame, fm.updateTitle_.bind(fm)); | 568 fm.openFilePopup_(galleryFrame, fm.updateTitle_.bind(fm)); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 items, defaultIdx, | 702 items, defaultIdx, |
| 693 function(item) { | 703 function(item) { |
| 694 onSuccess(item.task); | 704 onSuccess(item.task); |
| 695 }); | 705 }); |
| 696 }; | 706 }; |
| 697 | 707 |
| 698 FileTasks.decorate('display'); | 708 FileTasks.decorate('display'); |
| 699 FileTasks.decorate('updateMenuItem'); | 709 FileTasks.decorate('updateMenuItem'); |
| 700 FileTasks.decorate('execute'); | 710 FileTasks.decorate('execute'); |
| 701 FileTasks.decorate('executeDefault'); | 711 FileTasks.decorate('executeDefault'); |
| OLD | NEW |