-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a screenshot remote command browsertest for kiosk.
This browser test uses a fake screenshot delegate to skip a screenshot upload job. Test: browser_tests --gtest_filter=*ScreenshotWithRemoteCommand Bug: b:268321006 Change-Id: Ic6735f1731e6248ad60ffa48f4d8298cb3ccae3f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4240560 Commit-Queue: Sergii Bykov <sbykov@google.com> Reviewed-by: Polina Bondarenko <pbond@chromium.org> Reviewed-by: Pavol Marko <pmarko@chromium.org> Cr-Commit-Position: refs/heads/main@{#1106126}
- Loading branch information
Showing
8 changed files
with
176 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
chrome/browser/ash/policy/remote_commands/fake_screenshot_delegate.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ash/policy/remote_commands/fake_screenshot_delegate.h" | ||
|
||
#include <string> | ||
|
||
#include "base/check.h" | ||
#include "chrome/browser/ash/policy/uploading/upload_job.h" | ||
|
||
namespace policy { | ||
|
||
namespace { | ||
class FakeUploadJob : public policy::UploadJob { | ||
public: | ||
explicit FakeUploadJob(UploadJob::Delegate* delegate) : delegate_(delegate) { | ||
DCHECK(delegate_); | ||
} | ||
|
||
~FakeUploadJob() override = default; | ||
FakeUploadJob(const FakeUploadJob&) = delete; | ||
FakeUploadJob& operator=(const FakeUploadJob&) = delete; | ||
|
||
void AddDataSegment(const std::string& name, | ||
const std::string& filename, | ||
const std::map<std::string, std::string>& header_entries, | ||
std::unique_ptr<std::string> data) override { | ||
// ignore data segments | ||
return; | ||
} | ||
|
||
void Start() override { | ||
// just call OnSuccess to complete a remote command | ||
delegate_->OnSuccess(); | ||
} | ||
|
||
private: | ||
UploadJob::Delegate* delegate_; | ||
}; | ||
} // namespace | ||
|
||
bool FakeScreenshotDelegate::IsScreenshotAllowed() { | ||
return true; | ||
} | ||
|
||
void FakeScreenshotDelegate::TakeSnapshot( | ||
gfx::NativeWindow window, | ||
const gfx::Rect& source_rect, | ||
policy::OnScreenshotTakenCallback callback) { | ||
std::move(callback).Run(nullptr); | ||
} | ||
|
||
std::unique_ptr<policy::UploadJob> FakeScreenshotDelegate::CreateUploadJob( | ||
const GURL&, | ||
policy::UploadJob::Delegate* delegate) { | ||
return std::make_unique<FakeUploadJob>(delegate); | ||
} | ||
|
||
} // namespace policy |
33 changes: 33 additions & 0 deletions
33
chrome/browser/ash/policy/remote_commands/fake_screenshot_delegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_ASH_POLICY_REMOTE_COMMANDS_FAKE_SCREENSHOT_DELEGATE_H_ | ||
#define CHROME_BROWSER_ASH_POLICY_REMOTE_COMMANDS_FAKE_SCREENSHOT_DELEGATE_H_ | ||
|
||
#include "chrome/browser/ash/policy/remote_commands/device_command_screenshot_job.h" | ||
|
||
namespace policy { | ||
|
||
class FakeScreenshotDelegate | ||
: public policy::DeviceCommandScreenshotJob::Delegate { | ||
public: | ||
FakeScreenshotDelegate() = default; | ||
~FakeScreenshotDelegate() override = default; | ||
FakeScreenshotDelegate(const FakeScreenshotDelegate&) = delete; | ||
FakeScreenshotDelegate& operator=(const FakeScreenshotDelegate&) = delete; | ||
|
||
bool IsScreenshotAllowed() override; | ||
|
||
void TakeSnapshot(gfx::NativeWindow window, | ||
const gfx::Rect& source_rect, | ||
policy::OnScreenshotTakenCallback callback) override; | ||
|
||
std::unique_ptr<policy::UploadJob> CreateUploadJob( | ||
const GURL&, | ||
policy::UploadJob::Delegate*) override; | ||
}; | ||
|
||
} // namespace policy | ||
|
||
#endif // CHROME_BROWSER_ASH_POLICY_REMOTE_COMMANDS_FAKE_SCREENSHOT_DELEGATE_H_ |