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

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

Issue 807583003: Revert of Include MTP devices in Cloud Import happiness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/importer_common.js
diff --git a/ui/file_manager/file_manager/common/js/importer_common.js b/ui/file_manager/file_manager/common/js/importer_common.js
index f65c5d21f67d4868773ad64225541aa4726a78c3..ea6faa2a75434a4b01675b081b757e1764ddfb25 100644
--- a/ui/file_manager/file_manager/common/js/importer_common.js
+++ b/ui/file_manager/file_manager/common/js/importer_common.js
@@ -6,43 +6,10 @@
var importer = importer || {};
/**
- * Volume types eligible for the affections of Cloud Import.
- * @private @const {!Array.<!VolumeManagerCommon.VolumeType>}
- */
-importer.ELIGIBLE_VOLUME_TYPES_ = [
- VolumeManagerCommon.VolumeType.MTP,
- VolumeManagerCommon.VolumeType.REMOVABLE
-];
-
-/**
* @enum {string}
*/
importer.Destination = {
GOOGLE_DRIVE: 'google-drive'
-};
-
-/**
- * Returns true if the entry is a media file (and a descendant of a DCIM dir).
- *
- * @param {Entry} entry
- * @return {boolean}
- */
-importer.isMediaEntry = function(entry) {
- return !!entry &&
- entry.isFile &&
- FileType.isImageOrVideo(entry) &&
- entry.fullPath.toUpperCase().indexOf('/DCIM/') === 0;
-};
-
-/**
- * Returns true if the volume is eligible for Cloud Import.
- *
- * @param {VolumeInfo} volumeInfo
- * @return {boolean}
- */
-importer.isEligibleVolume = function(volumeInfo) {
- return !!volumeInfo &&
- importer.ELIGIBLE_VOLUME_TYPES_.indexOf(volumeInfo.volumeType) !== -1;
};
/**
@@ -53,17 +20,20 @@
* @return {boolean}
*/
importer.isEligibleEntry = function(volumeInfoProvider, entry) {
- console.assert(volumeInfoProvider !== null);
- if (importer.isMediaEntry(entry)) {
+ assert(volumeInfoProvider != null);
+ if (entry && entry.isFile && FileType.isImageOrVideo(entry)) {
var volumeInfo = volumeInfoProvider.getVolumeInfo(entry);
- return importer.isEligibleVolume(volumeInfo);
+ if (volumeInfo &&
+ volumeInfo.volumeType == VolumeManagerCommon.VolumeType.REMOVABLE) {
+ return entry.fullPath.indexOf('/DCIM/') === 0;
+ }
}
return false;
};
/**
* Returns true if the entry represents a media directory for the purposes
- * of Cloud Import.
+ * of cloud import.
*
* @param {Entry} entry
* @param {VolumeManagerCommon.VolumeInfoProvider} volumeInfoProvider
@@ -74,14 +44,15 @@
return false;
}
- var fullPath = entry.fullPath.toUpperCase();
- if (fullPath !== '/DCIM' && fullPath !== '/DCIM/') {
+ if (entry.fullPath !== '/DCIM') {
return false;
}
- console.assert(volumeInfoProvider !== null);
+ assert(volumeInfoProvider != null);
var volumeInfo = volumeInfoProvider.getVolumeInfo(entry);
- return importer.isEligibleVolume(volumeInfo);
+ return !!volumeInfo &&
+ volumeInfo.isType(VolumeManagerCommon.VolumeType.REMOVABLE) &&
+ volumeInfo.hasMedia;
};
/**
@@ -89,11 +60,15 @@
* is enabled.
*/
importer.importEnabled = function() {
+ // TODO(smckay): Also verify that Drive is enabled and we're
+ // not running in guest mode.
return new Promise(
function(resolve, reject) {
chrome.commandLinePrivate.hasSwitch(
'enable-cloud-backup',
- /** @param {boolean} enabled */
+ /**
+ * @param {boolean} enabled
+ */
function(enabled) {
importer.lastKnownImportEnabled = enabled;
resolve(enabled);

Powered by Google App Engine
This is Rietveld 408576698