Commit 1d30ab7e authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

DLP: Show a notification instead of a toast for blocked printing.

According to the latest mocks we need to show a notification instead
of a toast when printing is blocked due to Data Leak Prevention
configuration.
See mocks: https://docs.google.com/presentation/d/1v0GM-lwHCznFJ6hnZlUH37eBOuAkJMw5Q6UnSkcKOgA/edit?hl=en#slide=id.ga3a0b63111_0_321

Bug: 1124651
Change-Id: I3bf1f73610d2f2723f75b9801bb131c7b2bf77b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505790Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822106}
parent d4f7e3d5
......@@ -4,28 +4,47 @@
#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 "ash/public/cpp/notification_utils.h"
#include "chrome/browser/notifications/notification_display_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/public/cpp/notification.h"
#include "ui/message_center/public/cpp/notification_types.h"
#include "ui/message_center/public/cpp/notifier_id.h"
#include "url/gurl.h"
namespace policy {
namespace {
const char kPrintToastId[] = "print_dlp_blocked";
constexpr int kPrintToastDurationMs = 2500;
constexpr char kPrintBlockedNotificationId[] = "print_dlp_blocked";
constexpr char kDlpPolicyNotifierId[] = "policy.dlp";
} // namespace
void ShowDlpPrintDisabledToast() {
ash::ToastData toast(
kPrintToastId, l10n_util::GetStringUTF16(IDS_POLICY_DLP_PRINTING_BLOCKED),
kPrintToastDurationMs, base::nullopt);
toast.is_managed = true;
ash::ToastManager::Get()->Show(toast);
void ShowDlpPrintDisabledNotification() {
std::unique_ptr<message_center::Notification> notification =
ash::CreateSystemNotification(
message_center::NOTIFICATION_TYPE_SIMPLE, kPrintBlockedNotificationId,
l10n_util::GetStringUTF16(IDS_POLICY_DLP_PRINTING_BLOCKED_TITLE),
l10n_util::GetStringUTF16(IDS_POLICY_DLP_PRINTING_BLOCKED_MESSAGE),
/*display_source=*/base::string16(), GURL(),
message_center::NotifierId(
message_center::NotifierType::SYSTEM_COMPONENT,
kDlpPolicyNotifierId),
message_center::RichNotificationData(),
base::MakeRefCounted<message_center::NotificationDelegate>(),
vector_icons::kBusinessIcon,
message_center::SystemNotificationWarningLevel::CRITICAL_WARNING);
notification->set_renotify(true);
NotificationDisplayService::GetForProfile(
ProfileManager::GetActiveUserProfile())
->Display(NotificationHandler::Type::TRANSIENT, *notification,
/*metadata=*/nullptr);
}
} // namespace policy
......@@ -8,7 +8,7 @@
namespace policy {
// Shows a notification that printing is not allowed due to DLP rules.
void ShowDlpPrintDisabledToast();
void ShowDlpPrintDisabledNotification();
} // namespace policy
......
......@@ -188,7 +188,7 @@ bool PrintViewManager::RejectPrintPreviewRequestIfRestricted(
return false;
GetPrintRenderFrame(rfh)->OnPrintPreviewDialogClosed();
#if defined(OS_CHROMEOS)
policy::ShowDlpPrintDisabledToast();
policy::ShowDlpPrintDisabledNotification();
#endif
return true;
}
......@@ -225,7 +225,7 @@ bool PrintViewManager::PrintPreview(
if (IsPrintingRestricted()) {
#if defined(OS_CHROMEOS)
policy::ShowDlpPrintDisabledToast();
policy::ShowDlpPrintDisabledNotification();
#endif
return false;
}
......
......@@ -585,8 +585,11 @@ Additional details:
<message name="IDS_POLICY_DLP_ANDROID_APPS" desc="Name shown for ARC in data leak prevention toasts.">
Android apps
</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 name="IDS_POLICY_DLP_PRINTING_BLOCKED_TITLE" desc="The title for notification informing the user that printing is blocked.">
Printing is blocked
</message>
<message name="IDS_POLICY_DLP_PRINTING_BLOCKED_MESSAGE" desc="The message for notification informing the user that printing is blocked.">
Printing of this content is blocked by your administrator.
</message>
</grit-part>
e36454c13cd9e034b5a9b21abffdfa0e369a8632
\ No newline at end of file
9cc120d3ece536d600e37f93fbc265f5e5600c5d
\ No newline at end of file
9cc120d3ece536d600e37f93fbc265f5e5600c5d
\ 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