Commit b26c69c1 authored by Aya ElAttar's avatar Aya ElAttar Committed by Chromium LUCI CQ

Changed notification helper to observe clipboard

- Changed notification helper to observe the
clipboard, and close the bubble if the clipboard
got changed.
- Refactored Bubble & Button classes to
base and derived classed, so it'd be easier
to support warning mode later.
- Moved some of the needed bubble constants
to a separate file.

Bug: 1167228
Change-Id: I103ef1c95e1036ba28d3c449ed801688d12d2868
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2632673Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Commit-Queue: Aya Elsayed <ayaelattar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844518}
parent a9499454
......@@ -2258,6 +2258,7 @@ source_set("chromeos") {
"policy/display_settings_handler.h",
"policy/dlp/data_transfer_dlp_controller.cc",
"policy/dlp/data_transfer_dlp_controller.h",
"policy/dlp/dlp_clipboard_bubble_constants.h",
"policy/dlp/dlp_clipboard_notification_helper.cc",
"policy/dlp/dlp_clipboard_notification_helper.h",
"policy/dlp/dlp_content_manager.cc",
......
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_CLIPBOARD_BUBBLE_CONSTANTS_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_CLIPBOARD_BUBBLE_CONSTANTS_H_
namespace policy {
// Clipboard ARC toast ID.
constexpr char kClipboardDlpArcToastId[] = "clipboard_dlp_block_arc";
// Clipboard Crostini toast ID.
constexpr char kClipboardDlpCrostiniToastId[] = "clipboard_dlp_block_crostini";
// Clipboard Plugin VM toast ID.
constexpr char kClipboardDlpPluginVmToastId[] = "clipboard_dlp_block_plugin_vm";
// The duration of the clipboard toast.
constexpr int kClipboardDlpToastDurationMs = 2500;
} // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_CLIPBOARD_BUBBLE_CONSTANTS_H_
......@@ -6,6 +6,7 @@
#define CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_CLIPBOARD_NOTIFICATION_HELPER_H_
#include "base/strings/string16.h"
#include "ui/base/clipboard/clipboard_observer.h"
#include "ui/base/data_transfer_policy/data_transfer_endpoint.h"
#include "ui/views/widget/unique_widget_ptr.h"
#include "ui/views/widget/widget.h"
......@@ -17,10 +18,11 @@ class DataTransferEndpoint;
namespace policy {
class DlpClipboardNotificationHelper : public views::WidgetObserver {
class DlpClipboardNotificationHelper : public views::WidgetObserver,
public ui::ClipboardObserver {
public:
DlpClipboardNotificationHelper() = default;
~DlpClipboardNotificationHelper() override = default;
DlpClipboardNotificationHelper();
~DlpClipboardNotificationHelper() override;
DlpClipboardNotificationHelper(const DlpClipboardNotificationHelper&) =
delete;
......@@ -41,6 +43,9 @@ class DlpClipboardNotificationHelper : public views::WidgetObserver {
void OnWidgetClosing(views::Widget* widget) override;
void OnWidgetDestroyed(views::Widget* widget) override;
// ui::ClipboardObserver
void OnClipboardDataChanged() override;
views::UniqueWidgetPtr widget_;
};
......
......@@ -9,6 +9,7 @@
#include "base/optional.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/policy/dlp/dlp_clipboard_bubble_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
......@@ -105,13 +106,13 @@ INSTANTIATE_TEST_SUITE_P(
DlpClipboard,
DlpClipboardToastTest,
::testing::Values(ToastTest(ui::EndpointType::kCrostini,
"clipboard_dlp_block_crostini",
kClipboardDlpCrostiniToastId,
IDS_CROSTINI_LINUX),
ToastTest(ui::EndpointType::kPluginVm,
"clipboard_dlp_block_plugin_vm",
kClipboardDlpPluginVmToastId,
IDS_PLUGIN_VM_APP_NAME),
ToastTest(ui::EndpointType::kArc,
"clipboard_dlp_block_arc",
kClipboardDlpArcToastId,
IDS_POLICY_DLP_ANDROID_APPS)));
} // namespace policy
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