Commit 683f89ee authored by Aya ElAttar's avatar Aya ElAttar Committed by Commit Bot

DLP: Change clipboard toast strings to include origin

- Changed the strings of toasts shown on clipboard data access
failure to include the hostname of the source of the clipboard
data.

Bug: 1096461
Change-Id: If86451d115b41da99d4d897b2dec9e1f327924d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436729
Commit-Queue: Aya Elsayed <ayaelattar@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811712}
parent 3fb4216e
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/public/cpp/toast_manager.h" #include "ash/public/cpp/toast_manager.h"
#include "base/notreached.h" #include "base/notreached.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h" #include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h" #include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
...@@ -70,7 +71,7 @@ bool EnterpriseClipboardDlpController::IsDataReadAllowed( ...@@ -70,7 +71,7 @@ bool EnterpriseClipboardDlpController::IsDataReadAllowed(
} }
if (level == DlpRulesManager::Level::kBlock) { if (level == DlpRulesManager::Level::kBlock) {
ShowBlockToast(GetToastText(data_dst)); ShowBlockToast(GetToastText(data_src, data_dst));
} }
return level == DlpRulesManager::Level::kAllow; return level == DlpRulesManager::Level::kAllow;
...@@ -85,7 +86,12 @@ void EnterpriseClipboardDlpController::ShowBlockToast( ...@@ -85,7 +86,12 @@ void EnterpriseClipboardDlpController::ShowBlockToast(
} }
base::string16 EnterpriseClipboardDlpController::GetToastText( base::string16 EnterpriseClipboardDlpController::GetToastText(
const ui::ClipboardDataEndpoint* const data_src,
const ui::ClipboardDataEndpoint* const data_dst) const { const ui::ClipboardDataEndpoint* const data_dst) const {
DCHECK(data_src);
DCHECK(data_src->origin());
base::string16 host_name = base::UTF8ToUTF16(data_src->origin()->host());
if (data_dst && data_dst->type() == ui::EndpointType::kGuestOs) { if (data_dst && data_dst->type() == ui::EndpointType::kGuestOs) {
ProfileManager* profile_manager = g_browser_process->profile_manager(); ProfileManager* profile_manager = g_browser_process->profile_manager();
Profile* profile = Profile* profile =
...@@ -96,16 +102,16 @@ base::string16 EnterpriseClipboardDlpController::GetToastText( ...@@ -96,16 +102,16 @@ base::string16 EnterpriseClipboardDlpController::GetToastText(
if (is_crostini_running && is_plugin_vm_running) { if (is_crostini_running && is_plugin_vm_running) {
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_TWO_VMS, IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_TWO_VMS, host_name,
l10n_util::GetStringUTF16(IDS_CROSTINI_LINUX), l10n_util::GetStringUTF16(IDS_CROSTINI_LINUX),
l10n_util::GetStringUTF16(IDS_PLUGIN_VM_APP_NAME)); l10n_util::GetStringUTF16(IDS_PLUGIN_VM_APP_NAME));
} else if (is_crostini_running) { } else if (is_crostini_running) {
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM, IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM, host_name,
l10n_util::GetStringUTF16(IDS_CROSTINI_LINUX)); l10n_util::GetStringUTF16(IDS_CROSTINI_LINUX));
} else if (is_plugin_vm_running) { } else if (is_plugin_vm_running) {
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM, IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM, host_name,
l10n_util::GetStringUTF16(IDS_PLUGIN_VM_APP_NAME)); l10n_util::GetStringUTF16(IDS_PLUGIN_VM_APP_NAME));
} else { } else {
NOTREACHED(); NOTREACHED();
...@@ -114,11 +120,12 @@ base::string16 EnterpriseClipboardDlpController::GetToastText( ...@@ -114,11 +120,12 @@ base::string16 EnterpriseClipboardDlpController::GetToastText(
if (data_dst && data_dst->type() == ui::EndpointType::kArc) { if (data_dst && data_dst->type() == ui::EndpointType::kArc) {
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM, IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM, host_name,
l10n_util::GetStringUTF16(IDS_POLICY_DLP_ANDROID_APPS)); l10n_util::GetStringUTF16(IDS_POLICY_DLP_ANDROID_APPS));
} }
return l10n_util::GetStringUTF16(IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_PASTE); return l10n_util::GetStringFUTF16(IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_PASTE,
host_name);
} }
} // namespace policy } // namespace policy
...@@ -40,6 +40,7 @@ class EnterpriseClipboardDlpController : public ui::ClipboardDlpController { ...@@ -40,6 +40,7 @@ class EnterpriseClipboardDlpController : public ui::ClipboardDlpController {
// The text will be different if the clipboard data is shared with Crostini // The text will be different if the clipboard data is shared with Crostini
// or Parallels or ARC. // or Parallels or ARC.
base::string16 GetToastText( base::string16 GetToastText(
const ui::ClipboardDataEndpoint* const data_src,
const ui::ClipboardDataEndpoint* const data_dst) const; const ui::ClipboardDataEndpoint* const data_dst) const;
}; };
......
...@@ -571,13 +571,13 @@ Additional details: ...@@ -571,13 +571,13 @@ Additional details:
<!-- Strings for Data Leak Prevention --> <!-- Strings for Data Leak Prevention -->
<message name="IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_PASTE" desc="A toast informing the user that paste is blocked."> <message name="IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_PASTE" desc="A toast informing the user that paste is blocked.">
Pasting to this location is blocked by your administrator Pasting from <ph name="ORIGIN_NAME">$1<ex>corp.google.com</ex></ph> to this location is blocked by your administrator
</message> </message>
<message name="IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM" desc="A toast informing the user that sharing clipboard data to VMs is blocked."> <message name="IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM" desc="A toast informing the user that sharing clipboard data to VMs is blocked.">
Your administrator has blocked sharing this content to <ph name="VM_NAME">$1<ex>Linux</ex></ph> Your administrator has blocked sharing from <ph name="ORIGIN_NAME">$1<ex>corp.google.com</ex></ph> to <ph name="VM_NAME">$2<ex>Linux</ex></ph>
</message> </message>
<message name="IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_TWO_VMS" desc="A toast informing the user that sharing clipboard data to VMs is blocked."> <message name="IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_TWO_VMS" desc="A toast informing the user that sharing clipboard data to VMs is blocked.">
Your administrator has blocked sharing this content to <ph name="VM_NAME_1">$1<ex>Linux</ex></ph> and <ph name="VM_NAME_2">$2<ex>Parallels</ex></ph> Your administrator has blocked sharing from <ph name="ORIGIN_NAME">$1<ex>corp.google.com</ex></ph> to <ph name="VM_NAME_1">$2<ex>Linux</ex></ph> and <ph name="VM_NAME_2">$3<ex>Parallels</ex></ph>
</message> </message>
<message name="IDS_POLICY_DLP_ANDROID_APPS" desc="Name shown for ARC in data leak prevention toasts."> <message name="IDS_POLICY_DLP_ANDROID_APPS" desc="Name shown for ARC in data leak prevention toasts.">
Android apps Android apps
......
ba7801e163005f543316c314426956e16845fc59 022ba1ffbe4205b99e454b5f24bbef05ba3d7d9e
\ No newline at end of file \ No newline at end of file
4515755cb0f170f6853402d1950084b03ddd0af2 dc8420bbab243a1ccc2442778128a5ff7ae2fa9c
\ No newline at end of file \ No newline at end of file
dafd5167bf4927eefb41f21f0457e9b1591f78de 311127f5b9c8e964067c9805ae7f86d559ec2a6d
\ No newline at end of file \ No newline at end of file
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