Commit a5a8696e authored by Aya ElAttar's avatar Aya ElAttar Committed by Commit Bot

Init Clipboard DLP controller only if not existing

Avoided the recreating of EnterpriseClipboardDlpController
every time on policy update by creating a new instance
only if there's not any instance running.

Bug: 1135480
Change-Id: I65b17ab262ceb1572b104dbc2a4456c1c4b55663
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450280Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarDarwin Huang <huangdarwin@chromium.org>
Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@chromium.org>
Commit-Queue: Aya Elsayed <ayaelattar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814574}
parent 1f7f93cd
...@@ -34,7 +34,8 @@ constexpr int kToastDurationMs = 2500; ...@@ -34,7 +34,8 @@ constexpr int kToastDurationMs = 2500;
// static // static
void EnterpriseClipboardDlpController::Init() { void EnterpriseClipboardDlpController::Init() {
new EnterpriseClipboardDlpController(); if (!HasInstance())
new EnterpriseClipboardDlpController();
} }
bool EnterpriseClipboardDlpController::IsDataReadAllowed( bool EnterpriseClipboardDlpController::IsDataReadAllowed(
......
...@@ -11,6 +11,11 @@ ClipboardDlpController* ClipboardDlpController::Get() { ...@@ -11,6 +11,11 @@ ClipboardDlpController* ClipboardDlpController::Get() {
return g_clipboard_dlp_controller_; return g_clipboard_dlp_controller_;
} }
// static
bool ClipboardDlpController::HasInstance() {
return g_clipboard_dlp_controller_ != nullptr;
}
// static // static
void ClipboardDlpController::DeleteInstance() { void ClipboardDlpController::DeleteInstance() {
if (!g_clipboard_dlp_controller_) if (!g_clipboard_dlp_controller_)
......
...@@ -19,6 +19,9 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD) ClipboardDlpController { ...@@ -19,6 +19,9 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD) ClipboardDlpController {
// Returns a pointer to the existing instance of the class. // Returns a pointer to the existing instance of the class.
static ClipboardDlpController* Get(); static ClipboardDlpController* Get();
// Returns true if an instance exists, without forcing an initialization.
static bool HasInstance();
// Deletes the existing instance of the class if it's already created. // Deletes the existing instance of the class if it's already created.
// Indicates that restricting clipboard content is no longer required. // Indicates that restricting clipboard content is no longer required.
static void DeleteInstance(); static void DeleteInstance();
......
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