Commit bc2d6383 authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

DLP: Show notification when video screen capture is interrupted.

According to the latest UX mocks, when the running video screen capture
is interrupted due to confidential content that appears in the captured area
a corresponding notification should be shown to the user.
See mocks: https://docs.google.com/presentation/d/1v0GM-lwHCznFJ6hnZlUH37eBOuAkJMw5Q6UnSkcKOgA/edit?hl=en#slide=id.ga41d6e7481_4_0

Bug: 1133324
Change-Id: Ibde37d0d5980b2ebe67f5b69cc2ab3f96e4fab99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502341
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821684}
parent 29708db4
...@@ -2955,12 +2955,18 @@ Here are some things you can try to get started. ...@@ -2955,12 +2955,18 @@ Here are some things you can try to get started.
<message name="IDS_ASH_SCREEN_CAPTURE_FAILURE_TITLE" desc="The title of the notification when capture mode fails."> <message name="IDS_ASH_SCREEN_CAPTURE_FAILURE_TITLE" desc="The title of the notification when capture mode fails.">
An error occurred An error occurred
</message> </message>
<message name="IDS_ASH_SCREEN_CAPTURE_STOPPED_TITLE" desc="The title of the notification when video capture is stopped.">
Screen recording stopped
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_DISABLED_MESSAGE" desc="The text of the notification when capture mode is disabled."> <message name="IDS_ASH_SCREEN_CAPTURE_DISABLED_MESSAGE" desc="The text of the notification when capture mode is disabled.">
The ability to screen capture has been disabled by your administrator. The ability to screen capture has been disabled by your administrator.
</message> </message>
<message name="IDS_ASH_SCREEN_CAPTURE_FAILURE_MESSAGE" desc="The text of the notification when capture mode fails."> <message name="IDS_ASH_SCREEN_CAPTURE_FAILURE_MESSAGE" desc="The text of the notification when capture mode fails.">
Failed to capture screen Failed to capture screen
</message> </message>
<message name="IDS_ASH_SCREEN_CAPTURE_STOPPED_MESSAGE" desc="The text of the notification when video capture is stopped.">
Screen recording stopped due to confidential content on your screen.
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_DISPLAY_SOURCE" desc="The name that is the display source of the screen capture notification."> <message name="IDS_ASH_SCREEN_CAPTURE_DISPLAY_SOURCE" desc="The name that is the display source of the screen capture notification.">
Screen capture Screen capture
</message> </message>
......
feb4ffe52e5331898d157388837de87b11285126
\ No newline at end of file
feb4ffe52e5331898d157388837de87b11285126
\ No newline at end of file
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/clipboard/clipboard_data.h" #include "ui/base/clipboard/clipboard_data.h"
#include "ui/base/clipboard/clipboard_non_backed.h" #include "ui/base/clipboard/clipboard_non_backed.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -48,6 +49,8 @@ namespace { ...@@ -48,6 +49,8 @@ namespace {
CaptureModeController* g_instance = nullptr; CaptureModeController* g_instance = nullptr;
constexpr char kScreenCaptureNotificationId[] = "capture_mode_notification"; constexpr char kScreenCaptureNotificationId[] = "capture_mode_notification";
constexpr char kScreenCaptureStoppedNotificationId[] =
"capture_mode_stopped_notification";
constexpr char kScreenCaptureNotifierId[] = "ash.capture_mode_controller"; constexpr char kScreenCaptureNotifierId[] = "ash.capture_mode_controller";
// The format strings of the file names of captured images. // The format strings of the file names of captured images.
...@@ -182,6 +185,25 @@ void ShowFailureNotification() { ...@@ -182,6 +185,25 @@ void ShowFailureNotification() {
/*optional_fields=*/{}, /*delegate=*/nullptr); /*optional_fields=*/{}, /*delegate=*/nullptr);
} }
// Shows a notification informing the user that video recording was stopped.
void ShowVideoRecordingStoppedNotification() {
std::unique_ptr<message_center::Notification> notification =
CreateSystemNotification(
message_center::NOTIFICATION_TYPE_SIMPLE,
kScreenCaptureStoppedNotificationId,
l10n_util::GetStringUTF16(IDS_ASH_SCREEN_CAPTURE_STOPPED_TITLE),
l10n_util::GetStringUTF16(IDS_ASH_SCREEN_CAPTURE_STOPPED_MESSAGE),
/*display_source=*/base::string16(), GURL(),
message_center::NotifierId(
message_center::NotifierType::SYSTEM_COMPONENT,
kScreenCaptureNotifierId),
/*optional_fields=*/{}, /*delegate=*/nullptr,
vector_icons::kBusinessIcon,
message_center::SystemNotificationWarningLevel::CRITICAL_WARNING);
message_center::MessageCenter::Get()->AddNotification(
std::move(notification));
}
// Copies the bitmap representation of the given |image| to the clipboard. // Copies the bitmap representation of the given |image| to the clipboard.
void CopyImageToClipboard(const gfx::Image& image) { void CopyImageToClipboard(const gfx::Image& image) {
auto* clipboard = ui::ClipboardNonBacked::GetForCurrentThread(); auto* clipboard = ui::ClipboardNonBacked::GetForCurrentThread();
...@@ -586,10 +608,15 @@ void CaptureModeController::OnVideoRecordCountDownFinished() { ...@@ -586,10 +608,15 @@ void CaptureModeController::OnVideoRecordCountDownFinished() {
delegate_->StartObservingRestrictedContent( delegate_->StartObservingRestrictedContent(
capture_params->window, capture_params->bounds, capture_params->window, capture_params->bounds,
base::BindOnce(&CaptureModeController::EndVideoRecording, base::BindOnce(&CaptureModeController::InterruptVideoRecording,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
ShowStopRecordingButton(capture_params->window->GetRootWindow()); ShowStopRecordingButton(capture_params->window->GetRootWindow());
} }
void CaptureModeController::InterruptVideoRecording() {
ShowVideoRecordingStoppedNotification();
EndVideoRecording();
}
} // namespace ash } // namespace ash
...@@ -154,6 +154,10 @@ class ASH_EXPORT CaptureModeController { ...@@ -154,6 +154,10 @@ class ASH_EXPORT CaptureModeController {
// Called when the video record 3-seconds count down finishes. // Called when the video record 3-seconds count down finishes.
void OnVideoRecordCountDownFinished(); void OnVideoRecordCountDownFinished();
// Called to interrupt the ongoing video recording because it's not anymore
// allowed to be captured.
void InterruptVideoRecording();
std::unique_ptr<CaptureModeDelegate> delegate_; std::unique_ptr<CaptureModeDelegate> delegate_;
CaptureModeType type_ = CaptureModeType::kImage; CaptureModeType type_ = CaptureModeType::kImage;
......
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