Skip to content

Commit

Permalink
DLP: Handle open file warnings
Browse files Browse the repository at this point in the history
Added the correct strings for warnings shown
during files open or share.

Bug: 1382063

Change-Id: I5520feab38d83595e038e2dc614be2c3d2612dde
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4013549
Auto-Submit: Aya Elsayed <ayaelattar@chromium.org>
Reviewed-by: Sergey Poromov <poromov@chromium.org>
Reviewed-by: Aida Zolic <aidazolic@chromium.org>
Quick-Run: Aya Elsayed <ayaelattar@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1070566}
  • Loading branch information
ayamahmod authored and Chromium LUCI CQ committed Nov 11, 2022
1 parent be687e7 commit 6ba0dc9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 50 deletions.
100 changes: 50 additions & 50 deletions chrome/browser/chromeos/policy/dlp/dlp_warn_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,13 @@ const std::u16string GetDialogButtonOkLabelForFiles(
case DlpFilesController::FileAction::kMove:
return l10n_util::GetStringUTF16(
IDS_POLICY_DLP_FILES_MOVE_WARN_CONTINUE_BUTTON);
case DlpFilesController::FileAction::kTransfer:
case DlpFilesController::FileAction::kOpen:
// TODO(crbug.com/1382063): Add the correct string.
case DlpFilesController::FileAction::kShare:
// TODO(crbug.com/1382063): Add the correct string.
case DlpFilesController::FileAction::kUnknown: // TODO(crbug.com/1361900)
// Set proper text when file
// action is unknown
return l10n_util::GetStringUTF16(
IDS_POLICY_DLP_FILES_OPEN_WARN_CONTINUE_BUTTON);
case DlpFilesController::FileAction::kTransfer:
case DlpFilesController::FileAction::kUnknown:
// TODO(crbug.com/1361900): Set proper text when file action is unknown.
return l10n_util::GetStringUTF16(
IDS_POLICY_DLP_FILES_TRANSFER_WARN_CONTINUE_BUTTON);
}
Expand All @@ -153,11 +152,11 @@ const std::u16string GetTitleForFiles(
case DlpFilesController::FileAction::kMove:
return l10n_util::GetPluralStringFUTF16(
IDS_POLICY_DLP_FILES_MOVE_WARN_TITLE, files_number);
case DlpFilesController::FileAction::kTransfer:
case DlpFilesController::FileAction::kOpen:
// TODO(crbug.com/1382063): Add the correct string.
case DlpFilesController::FileAction::kShare:
// TODO(crbug.com/1382063): Add the correct string.
return l10n_util::GetPluralStringFUTF16(
IDS_POLICY_DLP_FILES_OPEN_WARN_TITLE, files_number);
case DlpFilesController::FileAction::kTransfer:
case DlpFilesController::FileAction::kUnknown: // TODO(crbug.com/1361900)
// Set proper text when file
// action is unknown
Expand All @@ -170,65 +169,66 @@ const std::u16string GetTitleForFiles(
const std::u16string GetMessageForFiles(
const DlpWarnDialog::DlpWarnDialogOptions& options) {
DCHECK(options.files_action.has_value());

std::u16string destination;
int num_files;
int message_id;
switch (options.files_action.value()) {
case DlpFilesController::FileAction::kDownload:
return base::ReplaceStringPlaceholders(
l10n_util::GetPluralStringFUTF16(
// Download action is only allowed for one file.
IDS_POLICY_DLP_FILES_DOWNLOAD_WARN_MESSAGE, 1),
GetDestinationComponentForFiles(
options.destination_component.value()),
/*offset=*/nullptr);
DCHECK(options.destination_component.has_value());
destination = GetDestinationComponentForFiles(
options.destination_component.value());
num_files = 1; // Download action is only for one file.
message_id = IDS_POLICY_DLP_FILES_DOWNLOAD_WARN_MESSAGE;
break;
case DlpFilesController::FileAction::kUpload:
DCHECK(!options.destination_pattern->empty());
return base::ReplaceStringPlaceholders(
l10n_util::GetPluralStringFUTF16(
IDS_POLICY_DLP_FILES_UPLOAD_WARN_MESSAGE,
options.confidential_files.size()),
base::UTF8ToUTF16(options.destination_pattern.value()),
/*offset=*/nullptr);
destination = base::UTF8ToUTF16(options.destination_pattern.value());
num_files = options.confidential_files.size();
message_id = IDS_POLICY_DLP_FILES_UPLOAD_WARN_MESSAGE;
break;
case DlpFilesController::FileAction::kCopy:
DCHECK(!options.destination_pattern->empty());
return base::ReplaceStringPlaceholders(
l10n_util::GetPluralStringFUTF16(
IDS_POLICY_DLP_FILES_COPY_WARN_MESSAGE,
options.confidential_files.size()),
GetDestinationComponentForFiles(
options.destination_component.value()),
/*offset=*/nullptr);
destination = GetDestinationComponentForFiles(
options.destination_component.value());
num_files = options.confidential_files.size();
message_id = IDS_POLICY_DLP_FILES_COPY_WARN_MESSAGE;
break;
case DlpFilesController::FileAction::kMove:
DCHECK(!options.destination_pattern->empty());
return base::ReplaceStringPlaceholders(
l10n_util::GetPluralStringFUTF16(
IDS_POLICY_DLP_FILES_MOVE_WARN_MESSAGE,
options.confidential_files.size()),
GetDestinationComponentForFiles(
options.destination_component.value()),
/*offset=*/nullptr);
case DlpFilesController::FileAction::kTransfer:
destination = GetDestinationComponentForFiles(
options.destination_component.value());
num_files = options.confidential_files.size();
message_id = IDS_POLICY_DLP_FILES_MOVE_WARN_MESSAGE;
break;
case DlpFilesController::FileAction::kOpen:
// TODO(crbug.com/1382063): Add the correct string.
case DlpFilesController::FileAction::kShare:
// TODO(crbug.com/1382063): Add the correct string.
case DlpFilesController::FileAction::kUnknown: // TODO(crbug.com/1361900)
// Set proper text when file
// action is unknown
std::u16string destination;
if (options.destination_component.has_value()) {
destination = GetDestinationComponentForFiles(
options.destination_component.value());
} else {
DCHECK(!options.destination_pattern->empty());
destination = base::UTF8ToUTF16(options.destination_pattern.value());
}
return base::ReplaceStringPlaceholders(
l10n_util::GetPluralStringFUTF16(
IDS_POLICY_DLP_FILES_TRANSFER_WARN_MESSAGE,
options.confidential_files.size()),
destination,
/*offset=*/nullptr);
num_files = options.confidential_files.size();
message_id = IDS_POLICY_DLP_FILES_OPEN_WARN_MESSAGE;
break;
case DlpFilesController::FileAction::kTransfer:
case DlpFilesController::FileAction::kUnknown:
// TODO(crbug.com/1361900): Set proper text when file action is unknown
if (options.destination_component.has_value()) {
destination = GetDestinationComponentForFiles(
options.destination_component.value());
} else {
DCHECK(!options.destination_pattern->empty());
destination = base::UTF8ToUTF16(options.destination_pattern.value());
}
num_files = options.confidential_files.size();
message_id = IDS_POLICY_DLP_FILES_TRANSFER_WARN_MESSAGE;
break;
}
return base::ReplaceStringPlaceholders(
l10n_util::GetPluralStringFUTF16(message_id, num_files), destination,
/*offset=*/nullptr);
}

// Returns the OK button label for |restriction|.
Expand Down
13 changes: 13 additions & 0 deletions components/policy_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,11 @@ Additional details:
=1 {Copy confidential file?}
other {Copy confidential files?}}
</message>
<message name="IDS_POLICY_DLP_FILES_OPEN_WARN_TITLE" desc="The title for notification informing the user that opening selected files is not recommended.">
{0, plural,
=1 {Open confidential file?}
other {Open confidential files?}}
</message>
<message name="IDS_POLICY_DLP_FILES_DOWNLOAD_WARN_MESSAGE" desc="The message for notification informing the user that downloading 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>}
Expand All @@ -860,6 +865,11 @@ Additional details:
=1 {Administrator policy doesn’t recommend copying this file to <ph name="DESTINATION_NAME">$1<ex>External storage</ex></ph>}
other {Administrator policy doesn’t recommend copying these files to <ph name="DESTINATION_NAME">$1<ex>External storage</ex></ph>}}
</message>
<message name="IDS_POLICY_DLP_FILES_OPEN_WARN_MESSAGE" desc="The message for notification informing the user that opening files is not recommended.">
{0, plural,
=1 {Administrator policy doesn’t recommend opening this file in <ph name="DESTINATION_NAME">$1<ex>External storage</ex></ph>}
other {Administrator policy doesn’t recommend opening these files in <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 downloading files.">
Download anyway
</message>
Expand All @@ -875,6 +885,9 @@ Additional details:
<message name="IDS_POLICY_DLP_FILES_COPY_WARN_CONTINUE_BUTTON" desc="Continue dialog button label for warning before copying files.">
Copy anyway
</message>
<message name="IDS_POLICY_DLP_FILES_OPEN_WARN_CONTINUE_BUTTON" desc="Continue dialog button label for warning before opening files.">
Open anyway
</message>
<message name="IDS_POLICY_DLP_FILES_DESTINATION_REMOVABLE_STORAGE" desc="A label for the 'Removable storage' files transfer destination.">
Removable storage
</message>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b624a6b5dd9b12bea77c72a81af8b2990023fe7a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
816ad6acfad76e9f7a244f232e7ce70b4691312f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
816ad6acfad76e9f7a244f232e7ce70b4691312f

0 comments on commit 6ba0dc9

Please sign in to comment.