Commit 4aedc0e7 authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

DLP: Don't start Capture Mode if restricted content is visible.

According to the latest UX mocks, Capture Mode shouldn't be started
if confidential content is currently visible on the screen.
So, it needs to be checked upfront while starting it.
However, it's still possible that a user will choose restricted area
for already initiated Capture Mode session, so the existing checks
should also be left.
See https://docs.google.com/presentation/d/1v0GM-lwHCznFJ6hnZlUH37eBOuAkJMw5Q6UnSkcKOgA/edit?hl=en#slide=id.g9ea2b2eb9f_9_256 for mocks.

Bug: 1133324
Change-Id: Iec4594b92118bf1e206bfafcadefd1e30fd070c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2501743
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822115}
parent 4bcce19e
......@@ -288,6 +288,11 @@ void CaptureModeController::Start() {
if (capture_mode_session_)
return;
if (delegate_->IsCaptureModeInitRestricted()) {
ShowDisabledNotification();
return;
}
capture_mode_session_ = std::make_unique<CaptureModeSession>(this);
}
......
......@@ -23,6 +23,10 @@ bool TestCaptureModeDelegate::Uses24HourFormat() const {
return false;
}
bool TestCaptureModeDelegate::IsCaptureModeInitRestricted() const {
return false;
}
bool TestCaptureModeDelegate::IsCaptureAllowed(const aura::Window* window,
const gfx::Rect& bounds,
bool for_video) const {
......
......@@ -22,6 +22,7 @@ class TestCaptureModeDelegate : public CaptureModeDelegate {
void ShowScreenCaptureItemInFolder(const base::FilePath& file_path) override;
void OpenScreenshotInImageEditor(const base::FilePath& file_path) override;
bool Uses24HourFormat() const override;
bool IsCaptureModeInitRestricted() const override;
bool IsCaptureAllowed(const aura::Window* window,
const gfx::Rect& bounds,
bool for_video) const override;
......
......@@ -45,6 +45,10 @@ class ASH_PUBLIC_EXPORT CaptureModeDelegate {
// video.
virtual bool Uses24HourFormat() const = 0;
// Returns whether initiation of capture mode is restricted because of
// currently visible restricted content.
virtual bool IsCaptureModeInitRestricted() const = 0;
// Returns whether capture of the region defined by |window| and |bounds|
// is currently allowed or not.
virtual bool IsCaptureAllowed(const aura::Window* window,
......
......@@ -125,6 +125,13 @@ void DlpContentManager::OnVideoCaptureStopped() {
running_video_capture_.reset();
}
bool DlpContentManager::IsCaptureModeInitRestricted() const {
return GetOnScreenPresentRestrictions().HasRestriction(
DlpContentRestriction::kScreenshot) ||
GetOnScreenPresentRestrictions().HasRestriction(
DlpContentRestriction::kVideoCapture);
}
/* static */
void DlpContentManager::SetDlpContentManagerForTesting(
DlpContentManager* dlp_content_manager) {
......
......@@ -73,6 +73,10 @@ class DlpContentManager : public DlpWindowObserver::Delegate {
// Called when video capturing is stopped.
void OnVideoCaptureStopped();
// Returns whether initiation of capture mode should be restricted because
// any restricted content is currently visible.
bool IsCaptureModeInitRestricted() const;
// The caller (test) should manage |dlp_content_manager| lifetime.
// Reset doesn't delete the object.
static void SetDlpContentManagerForTesting(
......
......@@ -79,6 +79,10 @@ bool ChromeCaptureModeDelegate::Uses24HourFormat() const {
return base::GetHourClockType() == base::k24HourClock;
}
bool ChromeCaptureModeDelegate::IsCaptureModeInitRestricted() const {
return policy::DlpContentManager::Get()->IsCaptureModeInitRestricted();
}
bool ChromeCaptureModeDelegate::IsCaptureAllowed(const aura::Window* window,
const gfx::Rect& bounds,
bool for_video) const {
......
......@@ -23,6 +23,7 @@ class ChromeCaptureModeDelegate : public ash::CaptureModeDelegate {
void ShowScreenCaptureItemInFolder(const base::FilePath& file_path) override;
void OpenScreenshotInImageEditor(const base::FilePath& file_path) override;
bool Uses24HourFormat() const override;
bool IsCaptureModeInitRestricted() const override;
bool IsCaptureAllowed(const aura::Window* window,
const gfx::Rect& bounds,
bool for_video) const override;
......
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