DLP: Pass upload file action to the warning dialog
Pass the kUpload file action to IsFilesTransferRestricted function and
show the proper string in the dialog.
Bug: 1365281
Change-Id: I105549667366122a109310a3587d741536f848d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3905645
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Aida Zolic <aidazolic@chromium.org>
Reviewed-by: Sergey Poromov <poromov@chromium.org>
Commit-Queue: Anna Ibatullina <annaib@google.com>
Cr-Commit-Position: refs/heads/main@{#1049551}
diff --git a/chrome/browser/ash/dbus/dlp_files_policy_service_provider.cc b/chrome/browser/ash/dbus/dlp_files_policy_service_provider.cc
index 2c568c2..261eeed 100644
--- a/chrome/browser/ash/dbus/dlp_files_policy_service_provider.cc
+++ b/chrome/browser/ash/dbus/dlp_files_policy_service_provider.cc
@@ -30,7 +30,7 @@
dlp::FileAction file_action) {
switch (file_action) {
case dlp::FileAction::UPLOAD:
- // TODO(crbug.com/1356109): Return upload FileAction.
+ return policy::DlpFilesController::FileAction::kUpload;
case dlp::FileAction::OPEN:
// TODO(crbug.com/1356109): Return open FileAction.
case dlp::FileAction::TRANSFER:
diff --git a/chrome/browser/ash/policy/dlp/dlp_files_controller.h b/chrome/browser/ash/policy/dlp/dlp_files_controller.h
index c3cecc91..63d7087 100644
--- a/chrome/browser/ash/policy/dlp/dlp_files_controller.h
+++ b/chrome/browser/ash/policy/dlp/dlp_files_controller.h
@@ -37,7 +37,8 @@
kUnknown = 0,
kDownload = 1,
kTransfer = 2,
- kMaxValue = kTransfer
+ kUpload = 3,
+ kMaxValue = kUpload
};
// DlpFileMetadata keeps metadata about a file, such as whether it's managed
diff --git a/chrome/browser/ash/policy/dlp/dlp_files_controller_unittest.cc b/chrome/browser/ash/policy/dlp/dlp_files_controller_unittest.cc
index d44d083..d3e7028 100644
--- a/chrome/browser/ash/policy/dlp/dlp_files_controller_unittest.cc
+++ b/chrome/browser/ash/policy/dlp/dlp_files_controller_unittest.cc
@@ -970,6 +970,15 @@
std::vector<ino_t>({kInode1, kInode2}),
std::vector<std::string>({kExampleUrl1,
kExampleUrl2}),
+ std::vector<std::string>({kFilePath1, kFilePath2})),
+ FilesTransferInfo(policy::DlpFilesController::FileAction::kUpload,
+ std::vector<ino_t>({kInode1}),
+ std::vector<std::string>({kExampleUrl1}),
+ std::vector<std::string>({kFilePath1})),
+ FilesTransferInfo(policy::DlpFilesController::FileAction::kUpload,
+ std::vector<ino_t>({kInode1, kInode2}),
+ std::vector<std::string>({kExampleUrl1,
+ kExampleUrl2}),
std::vector<std::string>({kFilePath1, kFilePath2}))));
TEST_P(DlpFilesWarningDialogContentTest,
diff --git a/chrome/browser/chromeos/policy/dlp/dlp_warn_dialog.cc b/chrome/browser/chromeos/policy/dlp/dlp_warn_dialog.cc
index c81e27fb..43ed0d7 100644
--- a/chrome/browser/chromeos/policy/dlp/dlp_warn_dialog.cc
+++ b/chrome/browser/chromeos/policy/dlp/dlp_warn_dialog.cc
@@ -112,6 +112,9 @@
case DlpFilesController::FileAction::kDownload:
return l10n_util::GetStringUTF16(
IDS_POLICY_DLP_FILES_DOWNLOAD_WARN_CONTINUE_BUTTON);
+ case DlpFilesController::FileAction::kUpload:
+ return l10n_util::GetStringUTF16(
+ IDS_POLICY_DLP_FILES_UPLOAD_WARN_CONTINUE_BUTTON);
case DlpFilesController::FileAction::kTransfer:
case DlpFilesController::FileAction::kUnknown: // TODO(crbug.com/1361900)
// Set proper text when file
@@ -130,6 +133,9 @@
return l10n_util::GetPluralStringFUTF16(
// Download action is only allowed for one file.
IDS_POLICY_DLP_FILES_DOWNLOAD_WARN_TITLE, 1);
+ case DlpFilesController::FileAction::kUpload:
+ return l10n_util::GetPluralStringFUTF16(
+ IDS_POLICY_DLP_FILES_UPLOAD_WARN_TITLE, files_number);
case DlpFilesController::FileAction::kTransfer:
case DlpFilesController::FileAction::kUnknown: // TODO(crbug.com/1361900)
// Set proper text when file
@@ -143,6 +149,7 @@
const std::u16string GetMessageForFiles(
const DlpWarnDialog::DlpWarnDialogOptions& options) {
DCHECK(options.files_action.has_value());
+
switch (options.files_action.value()) {
case DlpFilesController::FileAction::kDownload:
return base::ReplaceStringPlaceholders(
@@ -151,6 +158,14 @@
IDS_POLICY_DLP_FILES_DOWNLOAD_WARN_MESSAGE, 1),
GetDestinationForFiles(options.destination_component.value()),
/*offset=*/nullptr);
+ case DlpFilesController::FileAction::kUpload:
+ DCHECK(!options.destination_pattern->empty());
+ return base::ReplaceStringPlaceholders(
+ l10n_util::GetPluralStringFUTF16(
+ IDS_POLICY_DLP_FILES_UPLOAD_WARN_MESSAGE,
+ options.confidential_contents.GetContents().size()),
+ base::UTF8ToUTF16(options.destination_pattern.value()),
+ /*offset=*/nullptr);
case DlpFilesController::FileAction::kTransfer:
case DlpFilesController::FileAction::kUnknown: // TODO(crbug.com/1361900)
// Set proper text when file
diff --git a/components/policy_strings.grdp b/components/policy_strings.grdp
index 9b4a94ca..7d5dd17 100644
--- a/components/policy_strings.grdp
+++ b/components/policy_strings.grdp
@@ -806,6 +806,11 @@
=1 {Transfer confidential file?}
other {Transfer confidential files?}}
</message>
+ <message name="IDS_POLICY_DLP_FILES_UPLOAD_WARN_TITLE" desc="The title for notification informing the user that action on selected files is not recommended.">
+ {0, plural,
+ =1 {Upload confidential file?}
+ other {Upload confidential files?}}
+ </message>
<message name="IDS_POLICY_DLP_FILES_DOWNLOAD_WARN_MESSAGE" desc="The message for notification informing the user that action on files is not recommended.">
{0, plural,
=1 {Administrator policy doesn’t recommend downloading this file to <ph name="DESTINATION_NAME">$1<ex>External storage</ex></ph>}
@@ -816,12 +821,20 @@
=1 {Administrator policy doesn’t recommend transferring this file to <ph name="DESTINATION_NAME">$1<ex>External storage</ex></ph>}
other {Administrator policy doesn’t recommend transferring these files to <ph name="DESTINATION_NAME">$1<ex>External storage</ex></ph>}}
</message>
+ <message name="IDS_POLICY_DLP_FILES_UPLOAD_WARN_MESSAGE" desc="The message for notification informing the user that action on files is not recommended.">
+ {0, plural,
+ =1 {Administrator policy doesn’t recommend uploading this file to <ph name="DESTINATION_NAME">$1<ex>External storage</ex></ph>}
+ other {Administrator policy doesn’t recommend uploading these files to <ph name="DESTINATION_NAME">$1<ex>External storage</ex></ph>}}
+ </message>
<message name="IDS_POLICY_DLP_FILES_DOWNLOAD_WARN_CONTINUE_BUTTON" desc="Continue dialog button label for warning before action on files.">
Download anyway
</message>
<message name="IDS_POLICY_DLP_FILES_TRANSFER_WARN_CONTINUE_BUTTON" desc="Continue dialog button label for warning before action on files.">
Transfer anyway
</message>
+ <message name="IDS_POLICY_DLP_FILES_UPLOAD_WARN_CONTINUE_BUTTON" desc="Continue dialog button label for warning before action on files.">
+ Upload anyway
+ </message>
<message name="IDS_POLICY_DLP_FILES_DESTINATION_REMOVABLE_STORAGE" desc="A label for the 'Removable storage' files transfer destination.">
Removable storage
</message>
diff --git a/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_CONTINUE_BUTTON.png.sha1 b/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_CONTINUE_BUTTON.png.sha1
new file mode 100644
index 0000000..37949ff
--- /dev/null
+++ b/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_CONTINUE_BUTTON.png.sha1
@@ -0,0 +1 @@
+98d66fb62916d82bfac474841292dc5119af6035
\ No newline at end of file
diff --git a/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_MESSAGE.png.sha1 b/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_MESSAGE.png.sha1
new file mode 100644
index 0000000..002b745
--- /dev/null
+++ b/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_MESSAGE.png.sha1
@@ -0,0 +1 @@
+39cc8772303d1126f5cf651ad7d1fbbc9f939013
\ No newline at end of file
diff --git a/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_TITLE.png.sha1 b/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_TITLE.png.sha1
new file mode 100644
index 0000000..3dbc788
--- /dev/null
+++ b/components/policy_strings_grdp/IDS_POLICY_DLP_FILES_UPLOAD_WARN_TITLE.png.sha1
@@ -0,0 +1 @@
+0a43dd665113092ede6b40f07e82efd66c54201b
\ No newline at end of file