#ifndef CHROME_BROWSER_ASH_FILE_MANAGER_OFFICE_FILE_TASKS_H_
#define CHROME_BROWSER_ASH_FILE_MANAGER_OFFICE_FILE_TASKS_H_
#include <set>
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/time/time.h"
#include "chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_util.h"
#include "chrome/browser/ui/webui/ash/office_fallback/office_fallback_dialog.h"
class Profile;
namespace ash::cloud_upload {
class CloudOpenMetrics;
}
namespace storage {
class FileSystemURL;
}
namespace user_prefs {
class PrefRegistrySyncable;
}
namespace file_manager::file_tasks {
struct TaskDescriptor;
inline constexpr char kActionIdQuickOffice[] = "/views/app.html";
inline constexpr char kActionIdWebDriveOfficeWord[] =
"open-web-drive-office-word";
inline constexpr char kActionIdWebDriveOfficeExcel[] =
"open-web-drive-office-excel";
inline constexpr char kActionIdWebDriveOfficePowerPoint[] =
"open-web-drive-office-powerpoint";
inline constexpr char kActionIdOpenInOffice[] = "open-in-office";
inline constexpr char kUseOutsideDriveMetricName[] =
"FileBrowser.OfficeFiles.UseOutsideDrive";
enum class OfficeFilesUseOutsideDriveHook {
FILE_PICKER_SELECTION = 0,
COPY = 1,
MOVE = 2,
ZIP = 3,
OPEN_FROM_FILES_APP = 4,
kMaxValue = OPEN_FROM_FILES_APP,
};
inline constexpr char kOfficeOpenExtensionDriveMetricName[] =
"FileBrowser.OfficeFiles.Open.FileType.GoogleDrive";
inline constexpr char kOfficeOpenExtensionOneDriveMetricName[] =
"FileBrowser.OfficeFiles.Open.FileType.OneDrive";
enum class OfficeOpenExtensions {
kOther,
kDoc,
kDocm,
kDocx,
kDotm,
kDotx,
kOdp,
kOds,
kOdt,
kPot,
kPotm,
kPotx,
kPpam,
kPps,
kPpsm,
kPpsx,
kPpt,
kPptm,
kPptx,
kXls,
kXlsb,
kXlsm,
kXlsx,
kMaxValue = kXlsx,
};
void RegisterOfficeProfilePrefs(user_prefs::PrefRegistrySyncable*);
void RecordOfficeOpenExtensionDriveMetric(
const storage::FileSystemURL& file_url);
void RecordOfficeOpenExtensionOneDriveMetric(
const storage::FileSystemURL& file_url);
bool ExecuteWebDriveOfficeTask(
Profile* profile,
const TaskDescriptor& task,
const std::vector<storage::FileSystemURL>& file_urls,
std::unique_ptr<ash::cloud_upload::CloudOpenMetrics> cloud_open_metrics);
bool ExecuteOpenInOfficeTask(
Profile* profile,
const TaskDescriptor& task,
const std::vector<storage::FileSystemURL>& file_urls,
std::unique_ptr<ash::cloud_upload::CloudOpenMetrics> cloud_open_metrics);
void LaunchQuickOffice(Profile* profile,
const std::vector<storage::FileSystemURL>& file_urls);
void LogOneDriveMetricsAfterFallback(
ash::office_fallback::FallbackReason fallback_reason,
ash::cloud_upload::OfficeTaskResult task_result,
std::unique_ptr<ash::cloud_upload::CloudOpenMetrics> cloud_open_metrics);
void LogGoogleDriveMetricsAfterFallback(
ash::office_fallback::FallbackReason fallback_reason,
ash::cloud_upload::OfficeTaskResult task_result,
std::unique_ptr<ash::cloud_upload::CloudOpenMetrics> cloud_open_metrics);
void OnDialogChoiceReceived(
Profile* profile,
const TaskDescriptor& task,
const std::vector<storage::FileSystemURL>& file_urls,
ash::office_fallback::FallbackReason fallback_reason,
std::unique_ptr<ash::cloud_upload::CloudOpenMetrics> cloud_open_metrics,
std::optional<const std::string> choice);
bool GetUserFallbackChoice(Profile* profile,
const TaskDescriptor& task,
const std::vector<storage::FileSystemURL>& file_urls,
ash::office_fallback::FallbackReason failure_reason,
ash::office_fallback::DialogChoiceCallback callback);
bool IsWebDriveOfficeTask(const TaskDescriptor& task);
bool IsOpenInOfficeTask(const TaskDescriptor& task);
bool IsQuickOfficeInstalled(Profile* profile);
bool IsOfficeFile(const base::FilePath& path);
bool IsOfficeFileMimeType(const std::string& mime_type);
std::set<std::string> WordGroupExtensions();
std::set<std::string> ExcelGroupExtensions();
std::set<std::string> PowerPointGroupExtensions();
std::set<std::string> WordGroupMimeTypes();
std::set<std::string> ExcelGroupMimeTypes();
std::set<std::string> PowerPointGroupMimeTypes();
void SetWordFileHandler(Profile* profile,
const TaskDescriptor& task,
bool replace_existing = true);
void SetExcelFileHandler(Profile* profile,
const TaskDescriptor& task,
bool replace_existing = true);
void SetPowerPointFileHandler(Profile* profile,
const TaskDescriptor& task,
bool replace_existing = true);
bool HasExplicitDefaultFileHandler(Profile* profile,
const std::string& extension);
void SetWordFileHandlerToFilesSWA(Profile* profile,
const std::string& action_id,
bool replace_existing = true);
void SetExcelFileHandlerToFilesSWA(Profile* profile,
const std::string& action_id,
bool replace_existing = true);
void SetPowerPointFileHandlerToFilesSWA(Profile* profile,
const std::string& action_id,
bool replace_existing = true);
void RemoveFilesSWAWordFileHandler(Profile* profile,
const std::string& action_id);
void RemoveFilesSWAExcelFileHandler(Profile* profile,
const std::string& action_id);
void RemoveFilesSWAPowerPointFileHandler(Profile* profile,
const std::string& action_id);
void SetAlwaysMoveOfficeFilesToDrive(Profile* profile, bool complete = true);
bool GetAlwaysMoveOfficeFilesToDrive(Profile* profile);
void SetAlwaysMoveOfficeFilesToOneDrive(Profile* profile, bool complete = true);
bool GetAlwaysMoveOfficeFilesToOneDrive(Profile* profile);
void SetOfficeMoveConfirmationShownForDrive(Profile* profile, bool complete);
bool GetOfficeMoveConfirmationShownForDrive(Profile* profile);
void SetOfficeMoveConfirmationShownForOneDrive(Profile* profile, bool complete);
bool GetOfficeMoveConfirmationShownForOneDrive(Profile* profile);
void SetOfficeMoveConfirmationShownForLocalToDrive(Profile* profile,
bool shown);
bool GetOfficeMoveConfirmationShownForLocalToDrive(Profile* profile);
void SetOfficeMoveConfirmationShownForLocalToOneDrive(Profile* profile,
bool shown);
bool GetOfficeMoveConfirmationShownForLocalToOneDrive(Profile* profile);
void SetOfficeMoveConfirmationShownForCloudToDrive(Profile* profile,
bool shown);
bool GetOfficeMoveConfirmationShownForCloudToDrive(Profile* profile);
void SetOfficeMoveConfirmationShownForCloudToOneDrive(Profile* profile,
bool shown);
bool GetOfficeMoveConfirmationShownForCloudToOneDrive(Profile* profile);
void SetOfficeFileMovedToOneDrive(Profile* profile, base::Time moved);
void SetOfficeFileMovedToGoogleDrive(Profile* profile, base::Time moved);
}
#endif