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

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

Issue 132453007: Migrate fullPaths to URLs in appState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
OLDNEW
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 * Number of runtime errors catched in the background page. 8 * Number of runtime errors catched in the background page.
9 * @type {number} 9 * @type {number}
10 */ 10 */
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 for (var key in background.appWindows) { 526 for (var key in background.appWindows) {
527 if (!key.match(FILES_ID_PATTERN)) 527 if (!key.match(FILES_ID_PATTERN))
528 continue; 528 continue;
529 529
530 var contentWindow = background.appWindows[key].contentWindow; 530 var contentWindow = background.appWindows[key].contentWindow;
531 if (!contentWindow.appState) 531 if (!contentWindow.appState)
532 continue; 532 continue;
533 533
534 // Different current directories. 534 // Different current directories.
535 if (opt_appState.currentDirectoryPath !== 535 if (opt_appState.currentDirectoryPath !==
536 contentWindow.appState.currentDirectoryPath) { 536 contentWindow.appState.currentDirectoryPath) {
hirono 2014/01/27 05:39:56 currentDirectoryURL?
mtomasz 2014/01/27 06:12:52 Done.
537 continue; 537 continue;
538 } 538 }
539 539
540 // Selection path specified, and it is different. 540 // Selection path specified, and it is different.
541 if (opt_appState.selectionPath && 541 if (opt_appState.selectionURL &&
542 opt_appState.selectionPath !== 542 opt_appState.selectionURL !==
543 contentWindow.appState.selectionPath) { 543 contentWindow.appState.selectionURL) {
544 continue; 544 continue;
545 } 545 }
546 546
547 background.appWindows[key].focus(); 547 background.appWindows[key].focus();
548 if (opt_callback) 548 if (opt_callback)
549 opt_callback(key); 549 opt_callback(key);
550 onTaskCompleted(); 550 onTaskCompleted();
551 return; 551 return;
552 } 552 }
553 } 553 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 return; 662 return;
663 } 663 }
664 664
665 // Every other action opens a Files app window. 665 // Every other action opens a Files app window.
666 var appState = { 666 var appState = {
667 params: { 667 params: {
668 action: action 668 action: action
669 }, 669 },
670 // It is not allowed to call getParent() here, since there may be 670 // It is not allowed to call getParent() here, since there may be
671 // no permissions to access it at this stage. Therefore we are passing 671 // no permissions to access it at this stage. Therefore we are passing
672 // the selectionPath only, and the currentDirectory will be resolved 672 // the selectionURL only, and the currentDirectory will be resolved
673 // later. 673 // later.
674 selectionPath: details.entries[0].fullPath 674 selectionURL: details.entries[0].toURL()
675 }; 675 };
676 // For mounted devices just focus any Files.app window. The mounted 676 // For mounted devices just focus any Files.app window. The mounted
677 // volume will appear on the navigation list. 677 // volume will appear on the navigation list.
678 var type = action == 'auto-open' ? LaunchType.FOCUS_ANY_OR_CREATE : 678 var type = action == 'auto-open' ? LaunchType.FOCUS_ANY_OR_CREATE :
679 LaunchType.FOCUS_SAME_OR_CREATE; 679 LaunchType.FOCUS_SAME_OR_CREATE;
680 launchFileManager(appState, /* App ID */ undefined, type, nextStep); 680 launchFileManager(appState, /* App ID */ undefined, type, nextStep);
681 }); 681 });
682 break; 682 break;
683 } 683 }
684 }; 684 };
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 */ 774 */
775 Background.prototype.onContextMenuClicked_ = function(info) { 775 Background.prototype.onContextMenuClicked_ = function(info) {
776 if (info.menuItemId == 'new-window') { 776 if (info.menuItemId == 'new-window') {
777 // Find the focused window (if any) and use it's current path for the 777 // Find the focused window (if any) and use it's current path for the
778 // new window. If not found, then launch with the default path. 778 // new window. If not found, then launch with the default path.
779 for (var key in background.appWindows) { 779 for (var key in background.appWindows) {
780 try { 780 try {
781 if (background.appWindows[key].contentWindow.isFocused()) { 781 if (background.appWindows[key].contentWindow.isFocused()) {
782 var appState = { 782 var appState = {
783 // Do not clone the selection path, only the current directory. 783 // Do not clone the selection path, only the current directory.
784 currentDirectoryPath: background.appWindows[key].contentWindow. 784 currentDirectoryPath: background.appWindows[key].contentWindow.
hirono 2014/01/27 05:39:56 ditto.
mtomasz 2014/01/27 06:12:52 Done.
785 appState.currentDirectoryPath 785 appState.currentDirectoryPath
786 }; 786 };
787 launchFileManager(appState); 787 launchFileManager(appState);
788 return; 788 return;
789 } 789 }
790 } catch (ignore) { 790 } catch (ignore) {
791 // The isFocused method may not be defined during initialization. 791 // The isFocused method may not be defined during initialization.
792 // Therefore, wrapped with a try-catch block. 792 // Therefore, wrapped with a try-catch block.
793 } 793 }
794 } 794 }
(...skipping 19 matching lines...) Expand all
814 contexts: ['launcher'], 814 contexts: ['launcher'],
815 title: str('NEW_WINDOW_BUTTON_LABEL') 815 title: str('NEW_WINDOW_BUTTON_LABEL')
816 }); 816 });
817 }; 817 };
818 818
819 /** 819 /**
820 * Singleton instance of Background. 820 * Singleton instance of Background.
821 * @type {Background} 821 * @type {Background}
822 */ 822 */
823 window.background = new Background(); 823 window.background = new Background();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698