Commit 41185a2d authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

DLP: Show toast when printing is blocked.

Shows a toast when scripted printing is blocked due to
Data Leak Prevention configuration.

Bug: 1124651
Change-Id: I0cfd0c81fff0ca924a212ab988de3bc869bc53f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421515
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarAya Elsayed <ayaelattar@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810506}
parent 8f301d90
...@@ -2076,6 +2076,8 @@ source_set("chromeos") { ...@@ -2076,6 +2076,8 @@ source_set("chromeos") {
"policy/dlp/dlp_content_restriction_set.h", "policy/dlp/dlp_content_restriction_set.h",
"policy/dlp/dlp_content_tab_helper.cc", "policy/dlp/dlp_content_tab_helper.cc",
"policy/dlp/dlp_content_tab_helper.h", "policy/dlp/dlp_content_tab_helper.h",
"policy/dlp/dlp_notification_helper.cc",
"policy/dlp/dlp_notification_helper.h",
"policy/dlp/dlp_rules_manager.cc", "policy/dlp/dlp_rules_manager.cc",
"policy/dlp/dlp_rules_manager.h", "policy/dlp/dlp_rules_manager.h",
"policy/dlp/enterprise_clipboard_dlp_controller.cc", "policy/dlp/enterprise_clipboard_dlp_controller.cc",
......
// Copyright 2020 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.
#include "chrome/browser/chromeos/policy/dlp/dlp_notification_helper.h"
#include "ash/public/cpp/toast_data.h"
#include "ash/public/cpp/toast_manager.h"
#include "base/optional.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
namespace policy {
namespace {
const char kPrintToastId[] = "print_dlp_blocked";
constexpr int kPrintToastDurationMs = 2500;
} // namespace
void ShowDlpPrintDisabledToast() {
ash::ToastData toast(
kPrintToastId, l10n_util::GetStringUTF16(IDS_POLICY_DLP_PRINTING_BLOCKED),
kPrintToastDurationMs, base::nullopt);
ash::ToastManager::Get()->Show(toast);
}
} // namespace policy
// Copyright 2020 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.
#ifndef CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_NOTIFICATION_HELPER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_NOTIFICATION_HELPER_H_
namespace policy {
// Shows a notification that printing is not allowed due to DLP rules.
void ShowDlpPrintDisabledToast();
} // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_NOTIFICATION_HELPER_H_
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/policy/dlp/dlp_content_manager.h" #include "chrome/browser/chromeos/policy/dlp/dlp_content_manager.h"
#include "chrome/browser/chromeos/policy/dlp/dlp_notification_helper.h"
#endif #endif
using content::BrowserThread; using content::BrowserThread;
...@@ -186,6 +187,9 @@ bool PrintViewManager::RejectPrintPreviewRequestIfRestricted( ...@@ -186,6 +187,9 @@ bool PrintViewManager::RejectPrintPreviewRequestIfRestricted(
if (!IsPrintingRestricted()) if (!IsPrintingRestricted())
return false; return false;
GetPrintRenderFrame(rfh)->OnPrintPreviewDialogClosed(); GetPrintRenderFrame(rfh)->OnPrintPreviewDialogClosed();
#if defined(OS_CHROMEOS)
policy::ShowDlpPrintDisabledToast();
#endif
return true; return true;
} }
...@@ -219,8 +223,12 @@ bool PrintViewManager::PrintPreview( ...@@ -219,8 +223,12 @@ bool PrintViewManager::PrintPreview(
if (IsCrashed()) if (IsCrashed())
return false; return false;
if (IsPrintingRestricted()) if (IsPrintingRestricted()) {
#if defined(OS_CHROMEOS)
policy::ShowDlpPrintDisabledToast();
#endif
return false; return false;
}
GetPrintRenderFrame(rfh)->InitiatePrintPreview(std::move(print_renderer), GetPrintRenderFrame(rfh)->InitiatePrintPreview(std::move(print_renderer),
has_selection); has_selection);
......
...@@ -569,7 +569,7 @@ Additional details: ...@@ -569,7 +569,7 @@ Additional details:
This application has been blocked by your administrator This application has been blocked by your administrator
</message> </message>
<!-- Strings for Data Leak Prevetion --> <!-- 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 to this location is blocked by your administrator
</message> </message>
...@@ -579,5 +579,8 @@ Additional details: ...@@ -579,5 +579,8 @@ Additional details:
<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 this content to <ph name="VM_NAME_1">$1<ex>Linux</ex></ph> and <ph name="VM_NAME_2">$2<ex>Parallels</ex></ph>
</message> </message>
<message name="IDS_POLICY_DLP_PRINTING_BLOCKED" desc="A toast informing the user that printing is blocked.">
Printing of this content is blocked by your administrator
</message>
</grit-part> </grit-part>
e36454c13cd9e034b5a9b21abffdfa0e369a8632
\ 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