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