capture_mode: Pass local_state to ChromeCaptureModeDelegate
Bug: b:403153896 Change-Id: Idcbff455b93a17087def82096620d08cbee05a1e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6440718 Reviewed-by: Mitsuru Oshima <oshima@chromium.org> Commit-Queue: Jun Ishiguro <junis@google.com> Cr-Commit-Position: refs/heads/main@{#1444525}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
95c9f3f237
commit
43d490acb9
ash
chrome/browser/ui/ash
@ -1345,7 +1345,7 @@ void Shell::Init(
|
||||
window_cycle_controller_ = std::make_unique<WindowCycleController>();
|
||||
|
||||
capture_mode_controller_ = std::make_unique<CaptureModeController>(
|
||||
shell_delegate_->CreateCaptureModeDelegate());
|
||||
shell_delegate_->CreateCaptureModeDelegate(local_state));
|
||||
|
||||
// Accelerometer file reader starts listening to tablet mode controller.
|
||||
AccelerometerReader::GetInstance()->StartListenToTabletModeController();
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "url/gurl.h"
|
||||
|
||||
class AccountId;
|
||||
class PrefService;
|
||||
|
||||
namespace aura {
|
||||
class Window;
|
||||
}
|
||||
@ -76,8 +78,8 @@ class ASH_EXPORT ShellDelegate {
|
||||
virtual bool CanShowWindowForUser(const aura::Window* window) const = 0;
|
||||
|
||||
// Creates and returns the delegate of the Capture Mode feature.
|
||||
virtual std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate()
|
||||
const = 0;
|
||||
virtual std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate(
|
||||
PrefService* local_state) const = 0;
|
||||
|
||||
// Creates and returns the delegate of the clipboard history feature.
|
||||
virtual std::unique_ptr<ClipboardHistoryControllerDelegate>
|
||||
|
@ -48,7 +48,7 @@ bool TestShellDelegate::CanShowWindowForUser(const aura::Window* window) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<CaptureModeDelegate>
|
||||
TestShellDelegate::CreateCaptureModeDelegate() const {
|
||||
TestShellDelegate::CreateCaptureModeDelegate(PrefService* local_state) const {
|
||||
return std::make_unique<TestCaptureModeDelegate>();
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "services/network/test/test_shared_url_loader_factory.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
class PrefService;
|
||||
|
||||
namespace ash {
|
||||
|
||||
class UserEducationDelegate;
|
||||
@ -72,8 +74,8 @@ class TestShellDelegate : public ShellDelegate {
|
||||
|
||||
// Overridden from ShellDelegate:
|
||||
bool CanShowWindowForUser(const aura::Window* window) const override;
|
||||
std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate()
|
||||
const override;
|
||||
std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate(
|
||||
PrefService* local_state) const override;
|
||||
std::unique_ptr<ClipboardHistoryControllerDelegate>
|
||||
CreateClipboardHistoryControllerDelegate() const override;
|
||||
std::unique_ptr<CoralDelegate> CreateCoralDelegate() const override;
|
||||
|
@ -20,12 +20,14 @@
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "base/cancelable_callback.h"
|
||||
#include "base/check.h"
|
||||
#include "base/check_deref.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/i18n/time_formatting.h"
|
||||
#include "base/memory/raw_ref.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@ -44,7 +46,6 @@
|
||||
#include "chrome/browser/ash/policy/skyvault/odfs_skyvault_uploader.h"
|
||||
#include "chrome/browser/ash/policy/skyvault/skyvault_capture_upload_notification.h"
|
||||
#include "chrome/browser/ash/video_conference/video_conference_manager_ash.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/download/download_prefs.h"
|
||||
#include "chrome/browser/platform_util.h"
|
||||
#include "chrome/browser/policy/system_features_disable_list_policy_handler.h"
|
||||
@ -194,9 +195,8 @@ ScreenshotArea ConvertToScreenshotArea(const aura::Window* window,
|
||||
: ScreenshotArea::CreateForWindow(window);
|
||||
}
|
||||
|
||||
bool IsScreenCaptureDisabledByPolicy() {
|
||||
return g_browser_process->local_state()->GetBoolean(
|
||||
prefs::kDisableScreenshots);
|
||||
bool IsScreenCaptureDisabledByPolicy(PrefService& local_state) {
|
||||
return local_state.GetBoolean(prefs::kDisableScreenshots);
|
||||
}
|
||||
|
||||
void CaptureFileFinalized(
|
||||
@ -393,7 +393,8 @@ bool ParseQueryFormulationMetadataResponse(
|
||||
|
||||
} // namespace
|
||||
|
||||
ChromeCaptureModeDelegate::ChromeCaptureModeDelegate() {
|
||||
ChromeCaptureModeDelegate::ChromeCaptureModeDelegate(PrefService* local_state)
|
||||
: local_state_(CHECK_DEREF(local_state)) {
|
||||
DCHECK_EQ(g_instance, nullptr);
|
||||
g_instance = this;
|
||||
|
||||
@ -521,7 +522,8 @@ void ChromeCaptureModeDelegate::CheckCaptureOperationRestrictionByDlp(
|
||||
}
|
||||
|
||||
bool ChromeCaptureModeDelegate::IsCaptureAllowedByPolicy() const {
|
||||
return !is_screen_capture_locked_ && !IsScreenCaptureDisabledByPolicy();
|
||||
return !is_screen_capture_locked_ &&
|
||||
!IsScreenCaptureDisabledByPolicy(local_state_.get());
|
||||
}
|
||||
|
||||
void ChromeCaptureModeDelegate::StartObservingRestrictedContent(
|
||||
@ -664,7 +666,7 @@ void ChromeCaptureModeDelegate::GetDriveFsFreeSpaceBytes(
|
||||
bool ChromeCaptureModeDelegate::IsCameraDisabledByPolicy() const {
|
||||
return policy::SystemFeaturesDisableListPolicyHandler::
|
||||
IsSystemFeatureDisabled(policy::SystemFeature::kCamera,
|
||||
g_browser_process->local_state());
|
||||
&local_state_.get());
|
||||
}
|
||||
|
||||
bool ChromeCaptureModeDelegate::IsAudioCaptureDisabledByPolicy() const {
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "third_party/lens_server_proto/lens_overlay_service_deps.pb.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
class PrefService;
|
||||
|
||||
namespace screen_ai {
|
||||
class OpticalCharacterRecognizer;
|
||||
} // namespace screen_ai
|
||||
@ -40,7 +42,8 @@ class LensOverlayQueryController;
|
||||
// in Chrome.
|
||||
class ChromeCaptureModeDelegate : public ash::CaptureModeDelegate {
|
||||
public:
|
||||
ChromeCaptureModeDelegate();
|
||||
// `local_state` must not be null and must outlive `this`.
|
||||
explicit ChromeCaptureModeDelegate(PrefService* local_state);
|
||||
ChromeCaptureModeDelegate(const ChromeCaptureModeDelegate&) = delete;
|
||||
ChromeCaptureModeDelegate& operator=(const ChromeCaptureModeDelegate&) =
|
||||
delete;
|
||||
@ -215,6 +218,8 @@ class ChromeCaptureModeDelegate : public ash::CaptureModeDelegate {
|
||||
// is received and the response body has been decoded.
|
||||
void OnJsonParsed(data_decoder::DataDecoder::ValueOrError result);
|
||||
|
||||
const raw_ref<PrefService> local_state_;
|
||||
|
||||
// Used to temporarily disable capture mode in certain cases for which neither
|
||||
// a device policy, nor DLP will be triggered. For example, Some extension
|
||||
// APIs can request that a tab operate in a locked fullscreen mode, and in
|
||||
|
@ -158,8 +158,8 @@ bool ChromeShellDelegate::CanShowWindowForUser(
|
||||
}
|
||||
|
||||
std::unique_ptr<ash::CaptureModeDelegate>
|
||||
ChromeShellDelegate::CreateCaptureModeDelegate() const {
|
||||
return std::make_unique<ChromeCaptureModeDelegate>();
|
||||
ChromeShellDelegate::CreateCaptureModeDelegate(PrefService* local_state) const {
|
||||
return std::make_unique<ChromeCaptureModeDelegate>(local_state);
|
||||
}
|
||||
|
||||
std::unique_ptr<ash::ClipboardHistoryControllerDelegate>
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
class PrefService;
|
||||
|
||||
namespace ash {
|
||||
class WindowState;
|
||||
}
|
||||
@ -29,8 +31,8 @@ class ChromeShellDelegate : public ash::ShellDelegate {
|
||||
|
||||
// ash::ShellDelegate:
|
||||
bool CanShowWindowForUser(const aura::Window* window) const override;
|
||||
std::unique_ptr<ash::CaptureModeDelegate> CreateCaptureModeDelegate()
|
||||
const override;
|
||||
std::unique_ptr<ash::CaptureModeDelegate> CreateCaptureModeDelegate(
|
||||
PrefService* local_state) const override;
|
||||
std::unique_ptr<ash::ClipboardHistoryControllerDelegate>
|
||||
CreateClipboardHistoryControllerDelegate() const override;
|
||||
std::unique_ptr<ash::CoralDelegate> CreateCoralDelegate() const override;
|
||||
|
Reference in New Issue
Block a user