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

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

Issue 148193002: Removed most of path utility functions in Files app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 10 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/common/js/path_util.js » ('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) 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 * Represents each volume, such as "drive", "download directory", each "USB 8 * Represents each volume, such as "drive", "download directory", each "USB
9 * flush storage", or "mounted zip archive" etc. 9 * flush storage", or "mounted zip archive" etc.
10 * 10 *
(...skipping 24 matching lines...) Expand all
35 this.mountPath_ = mountPath; 35 this.mountPath_ = mountPath;
36 this.volumeId_ = volumeId; 36 this.volumeId_ = volumeId;
37 this.root_ = root; 37 this.root_ = root;
38 this.displayRoot_ = null; 38 this.displayRoot_ = null;
39 this.fakeEntries_ = {}; 39 this.fakeEntries_ = {};
40 this.displayRoot_ = null; 40 this.displayRoot_ = null;
41 this.displayRootPromise_ = null; 41 this.displayRootPromise_ = null;
42 42
43 if (volumeType === util.VolumeType.DRIVE) { 43 if (volumeType === util.VolumeType.DRIVE) {
44 this.fakeEntries[RootType.DRIVE_OFFLINE] = { 44 this.fakeEntries[RootType.DRIVE_OFFLINE] = {
45 fullPath: RootDirectory.DRIVE_OFFLINE, 45 fullPath: '/drive_offline',
46 isDirectory: true, 46 isDirectory: true,
47 rootType: RootType.DRIVE_OFFLINE, 47 rootType: RootType.DRIVE_OFFLINE,
48 toURL: function() { return 'fake-entry://' + this.fullPath; } 48 toURL: function() { return 'fake-entry://' + this.fullPath; }
49 }; 49 };
50 this.fakeEntries[RootType.DRIVE_SHARED_WITH_ME] = { 50 this.fakeEntries[RootType.DRIVE_SHARED_WITH_ME] = {
51 fullPath: RootDirectory.DRIVE_SHARED_WITH_ME, 51 fullPath: '/drive_shared_with_me',
52 isDirectory: true, 52 isDirectory: true,
53 rootType: RootType.DRIVE_SHARED_WITH_ME, 53 rootType: RootType.DRIVE_SHARED_WITH_ME,
54 toURL: function() { return 'fake-entry://' + this.fullPath; } 54 toURL: function() { return 'fake-entry://' + this.fullPath; }
55 }; 55 };
56 this.fakeEntries[RootType.DRIVE_RECENT] = { 56 this.fakeEntries[RootType.DRIVE_RECENT] = {
57 fullPath: RootDirectory.DRIVE_RECENT, 57 fullPath: '/drive_recent',
58 isDirectory: true, 58 isDirectory: true,
59 rootType: RootType.DRIVE_RECENT, 59 rootType: RootType.DRIVE_RECENT,
60 toURL: function() { return 'fake-entry://' + this.fullPath; } 60 toURL: function() { return 'fake-entry://' + this.fullPath; }
61 }; 61 };
62 } 62 }
63 63
64 // Note: This represents if the mounting of the volume is successfully done 64 // Note: This represents if the mounting of the volume is successfully done
65 // or not. (If error is empty string, the mount is successfully done). 65 // or not. (If error is empty string, the mount is successfully done).
66 // TODO(hidehiko): Rename to make this more understandable. 66 // TODO(hidehiko): Rename to make this more understandable.
67 this.error = error; 67 this.error = error;
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 VolumeManager.prototype.unmount = function(volumeInfo, 623 VolumeManager.prototype.unmount = function(volumeInfo,
624 successCallback, 624 successCallback,
625 errorCallback) { 625 errorCallback) {
626 chrome.fileBrowserPrivate.removeMount( 626 chrome.fileBrowserPrivate.removeMount(
627 util.makeFilesystemUrl(volumeInfo.mountPath)); 627 util.makeFilesystemUrl(volumeInfo.mountPath));
628 var requestKey = this.makeRequestKey_('unmount', volumeInfo.mountPath); 628 var requestKey = this.makeRequestKey_('unmount', volumeInfo.mountPath);
629 this.startRequest_(requestKey, successCallback, errorCallback); 629 this.startRequest_(requestKey, successCallback, errorCallback);
630 }; 630 };
631 631
632 /** 632 /**
633 * Resolves the absolute path to its entry. Shouldn't be used outside of the
634 * Files app's initialization.
635 * @param {string} path The path to be resolved.
636 * @param {function(Entry)} successCallback Called with the resolved entry on
637 * success.
638 * @param {function(FileError)} errorCallback Called on error.
639 */
640 VolumeManager.prototype.resolveAbsolutePath = function(
641 path, successCallback, errorCallback) {
642 // Make sure the path is in the mounted volume.
643 var volumeInfo = this.getVolumeInfo(path);
644 if (!volumeInfo || !volumeInfo.root) {
645 errorCallback(util.createDOMError(util.FileError.NOT_FOUND_ERR));
646 return;
647 }
648
649 webkitResolveLocalFileSystemURL(
650 util.makeFilesystemUrl(path), successCallback, errorCallback);
651 };
652
653 /**
654 * Obtains the information of the volume that containing an entry pointed by the 633 * Obtains the information of the volume that containing an entry pointed by the
655 * specified path. 634 * specified path.
656 * TODO(hirono): Stop to use path to get a volume info. 635 * TODO(hirono): Stop to use path to get a volume info.
657 * 636 *
658 * @param {string|Entry} target Path or Entry pointing anywhere on a volume. 637 * @param {string|Entry} target Path or Entry pointing anywhere on a volume.
659 * @return {VolumeInfo} The data about the volume. 638 * @return {VolumeInfo} The data about the volume.
660 */ 639 */
661 VolumeManager.prototype.getVolumeInfo = function(target) { 640 VolumeManager.prototype.getVolumeInfo = function(target) {
662 if (typeof target === 'string') 641 if (typeof target === 'string')
663 return this.volumeInfoList.findByPath(target); 642 return this.volumeInfoList.findByPath(target);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 this.isDriveBased; 865 this.isDriveBased;
887 866
888 /** 867 /**
889 * Whether the entry is read only or not. 868 * Whether the entry is read only or not.
890 * @type {boolean} 869 * @type {boolean}
891 */ 870 */
892 this.isReadOnly = isReadOnly; 871 this.isReadOnly = isReadOnly;
893 872
894 Object.freeze(this); 873 Object.freeze(this);
895 } 874 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/common/js/path_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698