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

Unified Diff: ui/file_manager/file_manager/common/js/util.js

Issue 946543002: Update LocationLine without IO. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/file_manager/common/js/util.js
diff --git a/ui/file_manager/file_manager/common/js/util.js b/ui/file_manager/file_manager/common/js/util.js
index a4d26f112487217fe0d2689bdd719728090434eb..3f80fde304b05b22c32eddc6532a80c36b0d296c 100644
--- a/ui/file_manager/file_manager/common/js/util.js
+++ b/ui/file_manager/file_manager/common/js/util.js
@@ -924,6 +924,36 @@ util.splitExtension = function(path) {
};
/**
+ * Returns the localized name of the root type.
+ * @param {!EntryLocation} locationInfo Location info.
+ * @return {string} The localized name.
+ */
+util.getRootTypeLabel = function(locationInfo) {
+ switch (locationInfo.rootType) {
+ case VolumeManagerCommon.RootType.DOWNLOADS:
+ return str('DOWNLOADS_DIRECTORY_LABEL');
+ case VolumeManagerCommon.RootType.DRIVE:
+ return str('DRIVE_MY_DRIVE_LABEL');
+ case VolumeManagerCommon.RootType.DRIVE_OFFLINE:
+ return str('DRIVE_OFFLINE_COLLECTION_LABEL');
+ case VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME:
+ return str('DRIVE_SHARED_WITH_ME_COLLECTION_LABEL');
+ case VolumeManagerCommon.RootType.DRIVE_RECENT:
+ return str('DRIVE_RECENT_COLLECTION_LABEL');
+ case VolumeManagerCommon.RootType.DRIVE_OTHER:
+ case VolumeManagerCommon.RootType.DOWNLOADS:
+ case VolumeManagerCommon.RootType.ARCHIVE:
+ case VolumeManagerCommon.RootType.REMOVABLE:
+ case VolumeManagerCommon.RootType.MTP:
+ case VolumeManagerCommon.RootType.PROVIDED:
+ return locationInfo.volumeInfo.label;
+ default:
+ console.error('Unsupported root type: ' + locationInfo.rootType);
+ return locationInfo.volumeInfo.label;
+ }
+}
+
+/**
* Returns the localized name of the entry.
*
* @param {EntryLocation} locationInfo
@@ -931,32 +961,10 @@ util.splitExtension = function(path) {
* @return {?string} The localized name.
*/
util.getEntryLabel = function(locationInfo, entry) {
- if (locationInfo && locationInfo.isRootEntry) {
- switch (locationInfo.rootType) {
- case VolumeManagerCommon.RootType.DOWNLOADS:
- return str('DOWNLOADS_DIRECTORY_LABEL');
- case VolumeManagerCommon.RootType.DRIVE:
- return str('DRIVE_MY_DRIVE_LABEL');
- case VolumeManagerCommon.RootType.DRIVE_OFFLINE:
- return str('DRIVE_OFFLINE_COLLECTION_LABEL');
- case VolumeManagerCommon.RootType.DRIVE_SHARED_WITH_ME:
- return str('DRIVE_SHARED_WITH_ME_COLLECTION_LABEL');
- case VolumeManagerCommon.RootType.DRIVE_RECENT:
- return str('DRIVE_RECENT_COLLECTION_LABEL');
- case VolumeManagerCommon.RootType.DRIVE_OTHER:
- case VolumeManagerCommon.RootType.DOWNLOADS:
- case VolumeManagerCommon.RootType.ARCHIVE:
- case VolumeManagerCommon.RootType.REMOVABLE:
- case VolumeManagerCommon.RootType.MTP:
- case VolumeManagerCommon.RootType.PROVIDED:
- return locationInfo.volumeInfo.label;
- default:
- console.error('Unsupported root type: ' + locationInfo.rootType);
- return locationInfo.volumeInfo.label;
- }
- }
-
- return entry.name;
+ if (locationInfo && locationInfo.isRootEntry)
+ return util.getRootTypeLabel(locationInfo);
+ else
+ return entry.name;
};
/**

Powered by Google App Engine
This is Rietveld 408576698