Commit 455f193f authored by samuong's avatar samuong Committed by Commit bot

Revert of Include MTP devices in Cloud Import happiness. (patchset #9...

Revert of Include MTP devices in Cloud Import happiness. (patchset #9 id:160001 of https://codereview.chromium.org/778123006/)

Reason for revert:
seems to be causing crashes on chrome os:

https://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%281%29/builds/53530
https://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%281%29/builds/35254

Original issue's description:
> Include MTP devices in Cloud Import happiness.
> Nuke "VolumeManager.isType".
> Add test coverage of importer_common methods.
> Make all "DCIM" dir-name matching case-insensitive.
>
> BUG=420680
> TEST=browser_test: FileManagerJsTest.*
>
> Committed: https://crrev.com/15d1aae4da7783607df3fac2d38198e817cf6fa0
> Cr-Commit-Position: refs/heads/master@{#308414}

TBR=mtomasz@chromium.org,smckay@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=420680

Review URL: https://codereview.chromium.org/807583003

Cr-Commit-Position: refs/heads/master@{#308442}
parent 8f495287
......@@ -64,11 +64,6 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileOperationManagerTest) {
FILE_PATH_LITERAL("background/js/file_operation_manager_unittest.html")));
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImporterCommonTest) {
RunTest(base::FilePath(
FILE_PATH_LITERAL("common/js/importer_common_unittest.html")));
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportHistoryTest) {
RunTest(base::FilePath(
FILE_PATH_LITERAL("background/js/import_history_unittest.html")));
......
......@@ -19,10 +19,10 @@
'../../common/js/error_util.js',
'../../common/js/async_util.js',
'../../common/js/file_type.js',
'../../common/js/importer_common.js',
'../../common/js/progress_center_common.js',
'../../common/js/util.js',
'../../common/js/volume_manager_common.js',
'../../common/js/importer_common.js',
'../../foreground/js/ui/progress_center_panel.js',
'../../foreground/js/progress_center_item_group.js',
'../../foreground/js/metadata/byte_reader.js',
......
......@@ -13,7 +13,6 @@
<!-- Need to load async_util.js before device_handler.js -->
<script src="../../common/js/async_util.js"></script>
<script src="../../common/js/volume_manager_common.js"></script>
<script src="../../common/js/importer_common.js"></script>
<script src="../../common/js/util.js"></script>
<script src="device_handler.js"></script>
......
......@@ -162,6 +162,15 @@ VolumeInfo.prototype = {
}
};
/**
* Provides short hand checking of volume type.
* @param {VolumeManagerCommon.VolumeType} type
* @return {boolean} True if the volume is of the specified type.
*/
VolumeInfo.prototype.isType = function(type) {
return type === this.volumeType_;
};
/**
* Starts resolving the display root and obtains it. It may take long time for
* Drive. Once resolved, it is cached.
......
......@@ -5,15 +5,6 @@
// Shared cloud importer namespace
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}
*/
......@@ -21,30 +12,6 @@ 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;
};
/**
* Returns true if the entry is cloud import eligible.
*
......@@ -53,17 +20,20 @@ importer.isEligibleVolume = function(volumeInfo) {
* @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 @@ importer.isMediaDirectory = function(entry, volumeInfoProvider) {
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 @@ importer.isMediaDirectory = function(entry, volumeInfoProvider) {
* 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);
......
<!DOCTYPE html>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.
-->
<html>
<body>
<script src="../../../../../ui/webui/resources/js/cr.js"></script>
<script src="../../../../../ui/webui/resources/js/cr/event_target.js"></script>
<script src="../../../../../ui/webui/resources/js/cr/ui/array_data_model.js"></script>
<script src="../../../../../ui/webui/resources/js/load_time_data.js"></script>
<script src="volume_manager_common.js"></script>
<script src="../../background/js/volume_manager.js"></script>
<script src="../../background/js/mock_file_operation_manager.js"></script>
<script src="../../background/js/mock_volume_manager.js"></script>
<script src="../../background/js/mock_media_scanner.js"></script>
<script src="mock_entry.js"></script>
<script src="async_util.js"></script>
<script src="file_type.js"></script>
<script src="util.js"></script>
<script src="importer_common.js"></script>
<script src="importer_common_unittest.js"></script>
</body>
</html>
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** @type {!MockVolumeManager} */
var volumeManager;
/** @type {!VolumeInfo} */
var cameraVolume;
/** @type {!VolumeInfo} */
var sdVolume;
/** @type {!VolumeInfo} */
var driveVolume;
/** @type {!MockFileEntry} */
var cameraFileEntry;
/** @type {!MockFileEntry} */
var sdFileEntry;
/** @type {!MockFileEntry} */
var driveFileEntry;
// Set up the test components.
function setUp() {
// Sadly, boilerplate setup necessary to include test support classes.
loadTimeData.data = {
DRIVE_DIRECTORY_LABEL: 'My Drive',
DOWNLOADS_DIRECTORY_LABEL: 'Downloads'
};
var cameraFileSystem = new MockFileSystem(
'camera-fs', 'filesystem:camera-123');
var sdFileSystem = new MockFileSystem(
'sd-fs', 'filesystem:sd-123');
cameraVolume = MockVolumeManager.createMockVolumeInfo(
VolumeManagerCommon.VolumeType.MTP,
'camera-fs',
'Some Camera');
sdVolume = MockVolumeManager.createMockVolumeInfo(
VolumeManagerCommon.VolumeType.REMOVABLE,
'sd-fs',
'Some SD Card');
volumeManager = new MockVolumeManager();
volumeManager.volumeInfoList.push(cameraVolume);
volumeManager.volumeInfoList.push(sdVolume);
driveVolume = volumeManager.getCurrentProfileVolumeInfo(
VolumeManagerCommon.VolumeType.DRIVE);
cameraFileEntry = createFileEntry(cameraVolume, '/DCIM/poodles.jpg');
sdFileEntry = createFileEntry(sdVolume, '/dcim/a-z/IMG1234.jpg');
driveFileEntry = createFileEntry(driveVolume, '/someotherfile.jpg');
}
function testIsMediaEntry() {
assertTrue(importer.isMediaEntry(cameraFileEntry));
assertFalse(importer.isMediaEntry(driveFileEntry));
}
function testIsEligibleVolume() {
assertTrue(importer.isEligibleVolume(cameraVolume));
assertTrue(importer.isEligibleVolume(sdVolume));
assertFalse(importer.isEligibleVolume(driveVolume));
}
function testIsEligibleEntry() {
assertTrue(importer.isEligibleEntry(volumeManager, cameraFileEntry));
assertTrue(importer.isEligibleEntry(volumeManager, sdFileEntry));
assertFalse(importer.isEligibleEntry(volumeManager, driveFileEntry));
}
function testIsMediaDirectory() {
['/DCIM', '/DCIM/', '/dcim', '/dcim/' ].forEach(
assertIsMediaDir);
['/blabbity/DCIM', '/blabbity/dcim', '/blabbity-blab'].forEach(
assertIsNotMediaDir);
}
/** @param {string} path */
function assertIsMediaDir(path) {
var dir = createDirectoryEntry(sdVolume, path);
assertTrue(importer.isMediaDirectory(dir, volumeManager));
}
/** @param {string} path */
function assertIsNotMediaDir(path) {
var dir = createDirectoryEntry(sdVolume, path);
assertFalse(importer.isMediaDirectory(dir, volumeManager));
}
function createFileEntry(volume, path) {
var entry = new MockFileEntry(
volume.fileSystem,
path, {
size: 1234,
modificationTime: new Date().toString()
});
// Ensure the file entry has a volumeID...necessary for lookups
// via the VolumeManager.
entry.volumeId = volume.volumeId;
return entry;
}
function createDirectoryEntry(volume, path) {
var entry = new MockDirectoryEntry(volume.fileSystem, path);
// Ensure the file entry has a volumeID...necessary for lookups
// via the VolumeManager.
entry.volumeId = volume.volumeId;
return entry;
}
......@@ -42,8 +42,8 @@
'../../common/js/error_util.js',
'../../common/js/async_util.js',
'../../common/js/file_type.js',
'../../common/js/volume_manager_common.js',
'../../common/js/importer_common.js',
'../../common/js/volume_manager_common.js',
'../../common/js/util.js',
'../../common/js/progress_center_common.js',
'../../common/js/lru_cache.js',
......
......@@ -74,10 +74,10 @@
//
//<include src="../../common/js/async_util.js">
//<include src="../../common/js/file_type.js">
//<include src="../../common/js/importer_common.js">
//<include src="../../common/js/volume_manager_common.js">
//<include src="../../common/js/util.js">
//<include src="../../common/js/progress_center_common.js">
//<include src="../../common/js/importer_common.js">
//
//<include src="ui/combobutton.js">
//<include src="ui/commandbutton.js">
......
......@@ -87,8 +87,8 @@
<script src="common/js/async_util.js"></script>
<script src="common/js/file_type.js"></script>
<script src="common/js/volume_manager_common.js"></script>
<script src="common/js/importer_common.js"></script>
<script src="common/js/volume_manager_common.js"></script>
<script src="common/js/util.js"></script>
<script src="common/js/progress_center_common.js"></script>
......
......@@ -171,10 +171,10 @@
"chrome://resources/js/cr/ui/array_data_model.js",
"common/js/async_util.js",
"common/js/file_type.js",
"common/js/importer_common.js",
"common/js/progress_center_common.js",
"common/js/util.js",
"common/js/volume_manager_common.js",
"common/js/importer_common.js",
"background/js/app_window_wrapper.js",
"background/js/background_base.js",
"background/js/device_handler.js",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment