Commit 36a4d8a7 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Remove MultiProfileShareDialog

This dialog was only relevant to the legacy drive sync client, so remove
it.

Bug: 1003238
Change-Id: I0df8b043f585916684f019af62bfd0c9ca238a5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1819287Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700148}
parent 07990632
...@@ -134,12 +134,6 @@ void AddStringsForDrive(base::DictionaryValue* dict) { ...@@ -134,12 +134,6 @@ void AddStringsForDrive(base::DictionaryValue* dict) {
IDS_FILE_BROWSER_DRIVE_RECENT_COLLECTION_LABEL); IDS_FILE_BROWSER_DRIVE_RECENT_COLLECTION_LABEL);
SET_STRING("DRIVE_SHARED_WITH_ME_COLLECTION_LABEL", SET_STRING("DRIVE_SHARED_WITH_ME_COLLECTION_LABEL",
IDS_FILE_BROWSER_DRIVE_SHARED_WITH_ME_COLLECTION_LABEL); IDS_FILE_BROWSER_DRIVE_SHARED_WITH_ME_COLLECTION_LABEL);
SET_STRING("DRIVE_SHARE_TYPE_CAN_COMMENT",
IDS_FILE_BROWSER_DRIVE_SHARE_TYPE_CAN_COMMENT);
SET_STRING("DRIVE_SHARE_TYPE_CAN_EDIT",
IDS_FILE_BROWSER_DRIVE_SHARE_TYPE_CAN_EDIT);
SET_STRING("DRIVE_SHARE_TYPE_CAN_VIEW",
IDS_FILE_BROWSER_DRIVE_SHARE_TYPE_CAN_VIEW);
SET_STRING("DRIVE_SPACE_AVAILABLE_LONG", SET_STRING("DRIVE_SPACE_AVAILABLE_LONG",
IDS_FILE_BROWSER_DRIVE_SPACE_AVAILABLE_LONG); IDS_FILE_BROWSER_DRIVE_SPACE_AVAILABLE_LONG);
SET_STRING("DRIVE_VISIT_DRIVE_GOOGLE_COM", SET_STRING("DRIVE_VISIT_DRIVE_GOOGLE_COM",
...@@ -664,14 +658,6 @@ std::unique_ptr<base::DictionaryValue> GetFileManagerStrings() { ...@@ -664,14 +658,6 @@ std::unique_ptr<base::DictionaryValue> GetFileManagerStrings() {
IDS_MULTIPART_DEVICE_UNSUPPORTED_DEFAULT_MESSAGE); IDS_MULTIPART_DEVICE_UNSUPPORTED_DEFAULT_MESSAGE);
SET_STRING("MULTIPART_DEVICE_UNSUPPORTED_MESSAGE", SET_STRING("MULTIPART_DEVICE_UNSUPPORTED_MESSAGE",
IDS_MULTIPART_DEVICE_UNSUPPORTED_MESSAGE); IDS_MULTIPART_DEVICE_UNSUPPORTED_MESSAGE);
SET_STRING("MULTI_PROFILE_SHARE_DIALOG_MESSAGE",
IDS_FILE_BROWSER_MULTI_PROFILE_SHARE_DIALOG_MESSAGE);
SET_STRING("MULTI_PROFILE_SHARE_DIALOG_MESSAGE_PLURAL",
IDS_FILE_BROWSER_MULTI_PROFILE_SHARE_DIALOG_MESSAGE_PLURAL);
SET_STRING("MULTI_PROFILE_SHARE_DIALOG_TITLE",
IDS_FILE_BROWSER_MULTI_PROFILE_SHARE_DIALOG_TITLE);
SET_STRING("MULTI_PROFILE_SHARE_DIALOG_TITLE_PLURAL",
IDS_FILE_BROWSER_MULTI_PROFILE_SHARE_DIALOG_TITLE_PLURAL);
SET_STRING("NAME_COLUMN_LABEL", IDS_FILE_BROWSER_NAME_COLUMN_LABEL); SET_STRING("NAME_COLUMN_LABEL", IDS_FILE_BROWSER_NAME_COLUMN_LABEL);
SET_STRING("EMPTY_FOLDER", IDS_FILE_BROWSER_EMPTY_FOLDER); SET_STRING("EMPTY_FOLDER", IDS_FILE_BROWSER_EMPTY_FOLDER);
SET_STRING("NEW_FOLDER_BUTTON_LABEL", SET_STRING("NEW_FOLDER_BUTTON_LABEL",
......
...@@ -1083,27 +1083,6 @@ ...@@ -1083,27 +1083,6 @@
<message name="IDS_FILE_BROWSER_OPEN_IN_OTHER_DESKTOP_MESSAGE_PLURAL" desc="Prural verson of the message of an alert dialog that is shown when a user opens a file in a desktop of another profile but the file is opened in the original desktop."> <message name="IDS_FILE_BROWSER_OPEN_IN_OTHER_DESKTOP_MESSAGE_PLURAL" desc="Prural verson of the message of an alert dialog that is shown when a user opens a file in a desktop of another profile but the file is opened in the original desktop.">
These files opened on a different desktop. Move to <ph name="USER_NAME">$1<ex>John Doe</ex></ph> (<ph name="MAIL_ADDRESS">$2<ex>xxxxxx@gmail.com</ex></ph>) to view it. These files opened on a different desktop. Move to <ph name="USER_NAME">$1<ex>John Doe</ex></ph> (<ph name="MAIL_ADDRESS">$2<ex>xxxxxx@gmail.com</ex></ph>) to view it.
</message> </message>
<message name="IDS_FILE_BROWSER_MULTI_PROFILE_SHARE_DIALOG_TITLE" desc="Title of a dialog to request drive share for files that come from other profiles during file transfering.">
This Drive file isn't shared yet
</message>
<message name="IDS_FILE_BROWSER_MULTI_PROFILE_SHARE_DIALOG_TITLE_PLURAL" desc="Title of a dialog to request drive share for files that come from other profiles during file transfering.">
These Drive files aren't shared yet
</message>
<message name="IDS_FILE_BROWSER_MULTI_PROFILE_SHARE_DIALOG_MESSAGE" desc="Message of a dialog to request drive share for files that come from other profiles during file transfering. Below the message, there are the e-mail address of the account to be shared with the file, and a drop down list to select a share type.">
Change how this file is shared
</message>
<message name="IDS_FILE_BROWSER_MULTI_PROFILE_SHARE_DIALOG_MESSAGE_PLURAL" desc="Message of a dialog to request drive share for files that come from other profiles during file transfering. Below the message, there are the e-mail address of the account to be shared with the file, and a drop down list to select a share type.">
Change how these files are shared
</message>
<message name="IDS_FILE_BROWSER_DRIVE_SHARE_TYPE_CAN_EDIT" desc="Label text of 'Can edit' share type. Please use the same string with Google Drive.">
Can edit
</message>
<message name="IDS_FILE_BROWSER_DRIVE_SHARE_TYPE_CAN_COMMENT" desc="Label text of 'Can comment' share type. Please use the same string with Google Drive.">
Can comment
</message>
<message name="IDS_FILE_BROWSER_DRIVE_SHARE_TYPE_CAN_VIEW" desc="Label text of 'Can view' share type. Please use the same string with Google Drive.">
Can view
</message>
<message name="IDS_FILE_BROWSER_DRIVE_MOBILE_CONNECTION_OPTION" desc="Option that determines if we will allow Google Drive content sync over mobile connections."> <message name="IDS_FILE_BROWSER_DRIVE_MOBILE_CONNECTION_OPTION" desc="Option that determines if we will allow Google Drive content sync over mobile connections.">
Do not use mobile data for sync Do not use mobile data for sync
</message> </message>
......
...@@ -438,7 +438,6 @@ js_library("file_transfer_controller") { ...@@ -438,7 +438,6 @@ js_library("file_transfer_controller") {
"ui:directory_tree", "ui:directory_tree",
"ui:file_manager_ui", "ui:file_manager_ui",
"ui:list_container", "ui:list_container",
"ui:multi_profile_share_dialog",
"ui:progress_center_panel", "ui:progress_center_panel",
"//ui/file_manager/file_manager/common/js:progress_center_common", "//ui/file_manager/file_manager/common/js:progress_center_common",
] ]
......
...@@ -642,7 +642,7 @@ class FileManager extends cr.EventTarget { ...@@ -642,7 +642,7 @@ class FileManager extends cr.EventTarget {
this.fileTransferController_ = new FileTransferController( this.fileTransferController_ = new FileTransferController(
assert(this.document_), assert(this.ui_.listContainer), assert(this.document_), assert(this.ui_.listContainer),
assert(this.ui_.directoryTree), this.ui_.multiProfileShareDialog, assert(this.ui_.directoryTree),
this.ui_.showConfirmationDialog.bind(this.ui_), this.ui_.showConfirmationDialog.bind(this.ui_),
assert(this.fileBrowserBackground_.progressCenter), assert(this.fileBrowserBackground_.progressCenter),
assert(this.fileOperationManager_), assert(this.metadataModel_), assert(this.fileOperationManager_), assert(this.metadataModel_),
......
...@@ -20,8 +20,6 @@ class FileTransferController { ...@@ -20,8 +20,6 @@ class FileTransferController {
* @param {!Document} doc Owning document. * @param {!Document} doc Owning document.
* @param {!ListContainer} listContainer List container. * @param {!ListContainer} listContainer List container.
* @param {!DirectoryTree} directoryTree Directory tree. * @param {!DirectoryTree} directoryTree Directory tree.
* @param {!MultiProfileShareDialog} multiProfileShareDialog Share dialog to
* be used to share files from another profile.
* @param {function(boolean, !Array<string>): !Promise<boolean>} * @param {function(boolean, !Array<string>): !Promise<boolean>}
* confirmationCallback called when operation requires user's * confirmationCallback called when operation requires user's
* confirmation. The operation will be executed if the return value * confirmation. The operation will be executed if the return value
...@@ -36,9 +34,9 @@ class FileTransferController { ...@@ -36,9 +34,9 @@ class FileTransferController {
* @param {!FileSelectionHandler} selectionHandler Selection handler. * @param {!FileSelectionHandler} selectionHandler Selection handler.
*/ */
constructor( constructor(
doc, listContainer, directoryTree, multiProfileShareDialog, doc, listContainer, directoryTree, confirmationCallback, progressCenter,
confirmationCallback, progressCenter, fileOperationManager, metadataModel, fileOperationManager, metadataModel, thumbnailModel, directoryModel,
thumbnailModel, directoryModel, volumeManager, selectionHandler) { volumeManager, selectionHandler) {
/** /**
* @private {!Document} * @private {!Document}
* @const * @const
...@@ -87,12 +85,6 @@ class FileTransferController { ...@@ -87,12 +85,6 @@ class FileTransferController {
*/ */
this.selectionHandler_ = selectionHandler; this.selectionHandler_ = selectionHandler;
/**
* @private {!MultiProfileShareDialog}
* @const
*/
this.multiProfileShareDialog_ = multiProfileShareDialog;
/** /**
* @private {function(boolean, !Array<string>): * @private {function(boolean, !Array<string>):
* Promise<boolean>} * Promise<boolean>}
...@@ -413,84 +405,6 @@ class FileTransferController { ...@@ -413,84 +405,6 @@ class FileTransferController {
return data === 'true'; return data === 'true';
} }
/**
* Obtains entries that need to share with me.
* The method also observers child entries of the given entries.
* @param {Array<Entry>} entries Entries.
* @return {!Promise<Array<Entry>>} Promise to be fulfilled with the entries
* that need to share.
* @private
*/
getMultiProfileShareEntries_(entries) {
// Utility function to concat arrays.
const concatArrays = arrays => {
return Array.prototype.concat.apply([], arrays);
};
// Call processEntry for each item of entries.
const processEntries = entries => {
const files = entries.filter(entry => {
return entry.isFile;
});
const dirs = entries.filter(entry => {
return !entry.isFile;
});
const promises = dirs.map(processDirectoryEntry);
if (files.length > 0) {
promises.push(processFileEntries(files));
}
return Promise.all(promises).then(concatArrays);
};
// Check all file entries and keeps only those need sharing operation.
const processFileEntries = entries => {
return new Promise(callback => {
// Do not use metadata cache here because the urls come from the
// different profile.
chrome.fileManagerPrivate.getEntryProperties(
entries, ['hosted', 'sharedWithMe'], callback);
})
.then(metadatas => {
return entries.filter((entry, i) => {
const metadata = metadatas[i];
return metadata && metadata.hosted && !metadata.sharedWithMe;
});
});
};
// Check child entries.
const processDirectoryEntry = entry => {
return readEntries(entry.createReader());
};
// Read entries from DirectoryReader and call processEntries for the chunk
// of entries.
const readEntries = reader => {
return new Promise(reader.readEntries.bind(reader))
.then(
entries => {
if (entries.length > 0) {
return Promise
.all([processEntries(entries), readEntries(reader)])
.then(concatArrays);
} else {
return [];
}
},
error => {
console.warn('Error happens while reading directory.', error);
return [];
});
};
// Filter entries that is owned by the current user, and call
// processEntries.
return processEntries(entries.filter(entry => {
// If the volumeInfo is found, the entry belongs to the current user.
return !this.volumeManager_.getVolumeInfo(/** @type {!Entry} */ (entry));
}));
}
/** /**
* Collects parameters of paste operation by the given command and the current * Collects parameters of paste operation by the given command and the current
* system clipboard. * system clipboard.
...@@ -619,7 +533,6 @@ class FileTransferController { ...@@ -619,7 +533,6 @@ class FileTransferController {
}) })
.then(/** .then(/**
* @param {!Array<Entry>} filteredEntries * @param {!Array<Entry>} filteredEntries
* @return {!Promise<Array<Entry>>}
*/ */
filteredEntries => { filteredEntries => {
entries = filteredEntries; entries = filteredEntries;
...@@ -661,56 +574,12 @@ class FileTransferController { ...@@ -661,56 +574,12 @@ class FileTransferController {
item.subMessage = item.subMessage =
strf('TO_FOLDER_NAME', item.destinationMessage); strf('TO_FOLDER_NAME', item.destinationMessage);
this.progressCenter_.updateItem(item); this.progressCenter_.updateItem(item);
// Check if cross share is needed or not.
return this.getMultiProfileShareEntries_(entries); // Start the pasting operation.
}) this.fileOperationManager_.paste(
.then(/** entries, destinationEntry, toMove, taskId);
* @param {Array<Entry>} inShareEntries this.pendingTaskIds.splice(
* @return {!Promise<Array<Entry>>|!Promise<null>} this.pendingTaskIds.indexOf(taskId), 1);
*/
inShareEntries => {
shareEntries = inShareEntries;
if (shareEntries.length === 0) {
return Promise.resolve(null);
}
return this.multiProfileShareDialog_
.showMultiProfileShareDialog(shareEntries.length > 1);
})
.then(
/**
* @param {?string} dialogResult
* @return {!Promise<undefined>|undefined}
*/
dialogResult => {
if (dialogResult === null) {
return;
} // No dialog was shown, skip this step.
if (dialogResult === 'cancel') {
return Promise.reject('ABORT');
}
// Do cross share.
// TODO(hirono): Make the loop cancellable.
const requestDriveShare = index => {
if (index >= shareEntries.length) {
return;
}
return new Promise(fulfill => {
chrome.fileManagerPrivate.requestDriveShare(
shareEntries[index], assert(dialogResult), () => {
// TODO(hirono): Check chrome.runtime.lastError
// here.
fulfill();
});
})
.then(requestDriveShare.bind(null, index + 1));
};
return requestDriveShare(0);
})
.then(() => {
// Start the pasting operation.
this.fileOperationManager_.paste(
entries, destinationEntry, toMove, taskId);
this.pendingTaskIds.splice(this.pendingTaskIds.indexOf(taskId), 1);
}) })
.catch(error => { .catch(error => {
if (error !== 'ABORT') { if (error !== 'ABORT') {
......
...@@ -66,10 +66,6 @@ function setUp() { ...@@ -66,10 +66,6 @@ function setUp() {
// Initialize cr.ui.Command with the <command>s. // Initialize cr.ui.Command with the <command>s.
cr.ui.decorate('command', cr.ui.Command); cr.ui.decorate('command', cr.ui.Command);
// Setup MultiProfileShareDialog.
const multiProfileShareDialog =
new MultiProfileShareDialog(queryRequiredElement('#dialog'));
// Fake confirmation callback. // Fake confirmation callback.
const confirmationDialog = (isMove, messages) => Promise.resolve(true); const confirmationDialog = (isMove, messages) => Promise.resolve(true);
...@@ -139,7 +135,6 @@ function setUp() { ...@@ -139,7 +135,6 @@ function setUp() {
document, document,
listContainer, listContainer,
directoryTree, directoryTree,
multiProfileShareDialog,
confirmationDialog, confirmationDialog,
progressCenter, progressCenter,
fileOperationManager, fileOperationManager,
......
...@@ -173,7 +173,6 @@ ...@@ -173,7 +173,6 @@
// <include src="ui/import_crostini_image_dialog.js"> // <include src="ui/import_crostini_image_dialog.js">
// <include src="ui/list_container.js"> // <include src="ui/list_container.js">
// <include src="ui/location_line.js"> // <include src="ui/location_line.js">
// <include src="ui/multi_profile_share_dialog.js">
// <include src="ui/multi_menu.js"> // <include src="ui/multi_menu.js">
// <include src="ui/progress_center_panel.js"> // <include src="ui/progress_center_panel.js">
// <include src="ui/providers_menu.js"> // <include src="ui/providers_menu.js">
......
...@@ -47,7 +47,6 @@ js_type_check("closure_compile_module") { ...@@ -47,7 +47,6 @@ js_type_check("closure_compile_module") {
":list_container", ":list_container",
":location_line", ":location_line",
":multi_menu", ":multi_menu",
":multi_profile_share_dialog",
":progress_center_panel", ":progress_center_panel",
":providers_menu", ":providers_menu",
":search_box", ":search_box",
...@@ -257,7 +256,6 @@ js_library("file_manager_ui") { ...@@ -257,7 +256,6 @@ js_library("file_manager_ui") {
":list_container", ":list_container",
":location_line", ":location_line",
":multi_menu", ":multi_menu",
":multi_profile_share_dialog",
":progress_center_panel", ":progress_center_panel",
":providers_menu", ":providers_menu",
":search_box", ":search_box",
...@@ -428,13 +426,6 @@ js_unittest("multi_menu_unittest") { ...@@ -428,13 +426,6 @@ js_unittest("multi_menu_unittest") {
] ]
} }
js_library("multi_profile_share_dialog") {
deps = [
":file_manager_dialog_base",
"//ui/file_manager/file_manager/common/js:util",
]
}
js_library("progress_center_panel") { js_library("progress_center_panel") {
# The progress_center on the background page maintains a list of panels. # The progress_center on the background page maintains a list of panels.
visibility += [ "//ui/file_manager/file_manager/background/*" ] visibility += [ "//ui/file_manager/file_manager/background/*" ]
......
...@@ -80,13 +80,6 @@ class FileManagerUI { ...@@ -80,13 +80,6 @@ class FileManagerUI {
this.copyConfirmDialog = new FilesConfirmDialog(this.element); this.copyConfirmDialog = new FilesConfirmDialog(this.element);
this.copyConfirmDialog.setOkLabel(str('CONFIRM_COPY_BUTTON_LABEL')); this.copyConfirmDialog.setOkLabel(str('CONFIRM_COPY_BUTTON_LABEL'));
/**
* Multi-profile share dialog.
* @type {!MultiProfileShareDialog}
* @const
*/
this.multiProfileShareDialog = new MultiProfileShareDialog(this.element);
/** /**
* Default task picker. * Default task picker.
* @type {!cr.filebrowser.DefaultTaskDialog} * @type {!cr.filebrowser.DefaultTaskDialog}
......
// Copyright 2013 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.
/**
* Dialog to confirm the share between profiles.
*
*/
class MultiProfileShareDialog extends FileManagerDialogBase {
/**
* @param {HTMLElement} parentNode Node to be parent for this dialog.
*/
constructor(parentNode) {
super(parentNode);
this.mailLabel_ = parentNode.ownerDocument.createElement('label');
this.mailLabel_.className = 'mail-label';
const canEdit = parentNode.ownerDocument.createElement('option');
canEdit.textContent = str('DRIVE_SHARE_TYPE_CAN_EDIT');
canEdit.value = MultiProfileShareDialog.Result.CAN_EDIT;
const canComment = parentNode.ownerDocument.createElement('option');
canComment.textContent = str('DRIVE_SHARE_TYPE_CAN_COMMENT');
canComment.value = MultiProfileShareDialog.Result.CAN_COMMET;
const canView = parentNode.ownerDocument.createElement('option');
canView.textContent = str('DRIVE_SHARE_TYPE_CAN_VIEW');
canView.value = MultiProfileShareDialog.Result.CAN_VIEW;
this.shareTypeSelect_ = parentNode.ownerDocument.createElement('select');
this.shareTypeSelect_.setAttribute('size', 1);
this.shareTypeSelect_.appendChild(canEdit);
this.shareTypeSelect_.appendChild(canComment);
this.shareTypeSelect_.appendChild(canView);
const shareLine = parentNode.ownerDocument.createElement('div');
shareLine.className = 'share-line';
shareLine.appendChild(this.mailLabel_);
shareLine.appendChild(this.shareTypeSelect_);
this.frame.insertBefore(shareLine, this.buttons);
this.frame.id = 'multi-profile-share-dialog';
this.currentProfileId_ = new Promise(callback => {
chrome.fileManagerPrivate.getProfiles(
(profiles, currentId, displayedId) => {
callback(currentId);
});
});
}
/**
* Shows the dialog.
* @param {boolean} plural Whether to use message of plural or not.
* @return {!Promise} Promise fulfilled with the result of dialog. If the
* dialog is already opened, it returns null.
*/
showMultiProfileShareDialog(plural) {
return this.currentProfileId_.then(currentProfileId => {
return new Promise((fulfill, reject) => {
this.shareTypeSelect_.selectedIndex = 0;
this.mailLabel_.textContent = currentProfileId;
const result = super.showOkCancelDialog(
str(plural ? 'MULTI_PROFILE_SHARE_DIALOG_TITLE_PLURAL' :
'MULTI_PROFILE_SHARE_DIALOG_TITLE'),
str(plural ? 'MULTI_PROFILE_SHARE_DIALOG_MESSAGE_PLURAL' :
'MULTI_PROFILE_SHARE_DIALOG_MESSAGE'),
() => {
fulfill(this.shareTypeSelect_.value);
},
() => {
fulfill(MultiProfileShareDialog.Result.CANCEL);
});
if (!result) {
reject(new Error('Another dialog has already shown.'));
}
});
});
}
}
/**
* Result of the dialog box.
* @enum {string}
* @const
*/
MultiProfileShareDialog.Result = {
CAN_EDIT: 'can_edit',
CAN_COMMET: 'can_comment',
CAN_VIEW: 'can_view',
CANCEL: 'cancel'
};
Object.freeze(MultiProfileShareDialog.Result);
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