| Index: chrome/browser/resources/file_manager/js/util.js
|
| diff --git a/chrome/browser/resources/file_manager/js/util.js b/chrome/browser/resources/file_manager/js/util.js
|
| index c279c95c95e40b6435f1a700c9498623175b28d3..d83985e56bd9a78ea122511b42d730dbf9fc3f1c 100644
|
| --- a/chrome/browser/resources/file_manager/js/util.js
|
| +++ b/chrome/browser/resources/file_manager/js/util.js
|
| @@ -514,5 +514,52 @@ var util = {
|
| */
|
| isOffline: function() {
|
| return !navigator.onLine;
|
| + },
|
| +
|
| + /**
|
| + * Tests if the given path is a gdata search result path, and if it is,
|
| + * returns file's fileName in virtual search file system, its gdata resourceId
|
| + * and the display name that should be used when the file is shown in file
|
| + * browser.
|
| + *
|
| + * @param {string} path The potential gdata search result path.
|
| + * @return {object.<string, stringi, string>} Object that will contain file's
|
| + * fileName, displayName and resourceId; or null if the path is not gdata
|
| + * search result path.
|
| + */
|
| + getFileAndDisplayNameForGDataSearchResult: function(path) {
|
| + // Nothing to do if the path is not under gdata search root path.
|
| + if (path.search(DirectoryModel.GDATA_SEARCH_ROOT_PATH) != 0)
|
| + return null;
|
| +
|
| + var pathComponents = path.split('/');
|
| +
|
| + // Search result should be formatted like:
|
| + // gdataSearchRoot/query/result
|
| + if (pathComponents.length !=
|
| + DirectoryModel.GDATA_SEARCH_ROOT_COMPONENTS.length + 2)
|
| + return null;
|
| + for (var i = 0;
|
| + i < DirectoryModel.GDATA_SEARCH_ROOT_COMPONENTS.length;
|
| + i++) {
|
| + if (pathComponents[i] != DirectoryModel.GDATA_SEARCH_ROOT_COMPONENTS[i])
|
| + return null;
|
| + }
|
| +
|
| + // Search result file name should be formatted like:
|
| + // resource_id.referenced_file_name
|
| + // We should display referenced file name only.
|
| + var result = {};
|
| + result.fileName = pathComponents.pop();
|
| + result.displayName =
|
| + result.fileName.slice(result.fileName.indexOf('.') + 1);
|
| + result.resourceId =
|
| + result.fileName.substr(0, result.fileName.indexOf('.'));
|
| +
|
| + if (result.fileName.length > 0 && result.displayName.length > 0) {
|
| + return result;
|
| + } else {
|
| + return null;
|
| + }
|
| }
|
| };
|
|
|