-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dlp: Split block and warn files dialogs
Splits FilesPolicyDialog into two subclasses for warning and block restriction levels, i.e. warning or error dialogs. The warning dialog can only be shown for a single policy at a time, while the error dialog can combine blocked files from both DLP and Enterprise Connectors. Currently only the constructors and some methods are extracted to the child classes, but in the future more of the setup will be moved from the base, which will only handle setting up the views etc, as the text used in the dialog should depend on its type. R=ayaelattar@chromium.org Fixed: b:284287312 Change-Id: If2df288f0fed7b10b227afe77ec3dc58ba684eef Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4570510 Reviewed-by: Aya Elsayed <ayaelattar@chromium.org> Commit-Queue: Aya Elsayed <ayaelattar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1150522}
- Loading branch information
Aida Zolic
authored and
Chromium LUCI CQ
committed
May 30, 2023
1 parent
dfa0a85
commit ba37e3c
Showing
9 changed files
with
250 additions
and
114 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
56 changes: 56 additions & 0 deletions
56
chrome/browser/chromeos/policy/dlp/dialogs/files_policy_error_dialog.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,56 @@ | ||
// 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/chromeos/policy/dlp/dialogs/files_policy_error_dialog.h" | ||
|
||
#include "base/functional/callback_helpers.h" | ||
#include "chrome/browser/chromeos/policy/dlp/dialogs/files_policy_dialog.h" | ||
#include "chrome/browser/chromeos/policy/dlp/dlp_files_utils.h" | ||
#include "ui/base/metadata/metadata_impl_macros.h" | ||
|
||
namespace policy { | ||
FilesPolicyErrorDialog::FilesPolicyErrorDialog( | ||
std::map<DlpConfidentialFile, Policy> files, | ||
DlpFileDestination destination, | ||
dlp::FileAction action, | ||
gfx::NativeWindow modal_parent) | ||
: FilesPolicyDialog(files.size(), | ||
std::move(destination), | ||
action, | ||
modal_parent), | ||
files_(std::move(files)) { | ||
SetAcceptCallback(base::BindOnce(&FilesPolicyErrorDialog::Dismiss, | ||
weak_factory_.GetWeakPtr())); | ||
SetCancelCallback(base::BindOnce(&FilesPolicyErrorDialog::OpenHelpPage, | ||
weak_factory_.GetWeakPtr())); | ||
MaybeAddConfidentialRows(); | ||
} | ||
|
||
FilesPolicyErrorDialog::~FilesPolicyErrorDialog() = default; | ||
|
||
void FilesPolicyErrorDialog::MaybeAddConfidentialRows() { | ||
if (files_.empty()) { | ||
return; | ||
} | ||
|
||
SetupScrollView(); | ||
for (const auto& file : files_) { | ||
// TODO(aidazolic): Add errors. | ||
AddConfidentialRow(file.first.icon, file.first.title); | ||
} | ||
} | ||
|
||
void FilesPolicyErrorDialog::OpenHelpPage() { | ||
// TODO(b/283786134): Implementation. | ||
} | ||
|
||
void FilesPolicyErrorDialog::Dismiss() { | ||
GetWidget()->CloseWithReason( | ||
views::Widget::ClosedReason::kCloseButtonClicked); | ||
} | ||
|
||
BEGIN_METADATA(FilesPolicyErrorDialog, FilesPolicyDialog) | ||
END_METADATA | ||
|
||
} // namespace policy |
55 changes: 55 additions & 0 deletions
55
chrome/browser/chromeos/policy/dlp/dialogs/files_policy_error_dialog.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,55 @@ | ||
// 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_CHROMEOS_POLICY_DLP_DIALOGS_FILES_POLICY_ERROR_DIALOG_H_ | ||
#define CHROME_BROWSER_CHROMEOS_POLICY_DLP_DIALOGS_FILES_POLICY_ERROR_DIALOG_H_ | ||
|
||
#include <map> | ||
|
||
#include "base/memory/weak_ptr.h" | ||
#include "chrome/browser/chromeos/policy/dlp/dialogs/files_policy_dialog.h" | ||
#include "chrome/browser/chromeos/policy/dlp/dlp_confidential_file.h" | ||
#include "chrome/browser/chromeos/policy/dlp/dlp_files_utils.h" | ||
#include "ui/base/metadata/metadata_impl_macros.h" | ||
#include "ui/gfx/native_widget_types.h" | ||
|
||
namespace policy { | ||
|
||
// FilesPolicyErrorDialog is a window modal dialog used to show detailed | ||
// overview of files blocked by data protection policies. | ||
class FilesPolicyErrorDialog : public FilesPolicyDialog { | ||
public: | ||
METADATA_HEADER(FilesPolicyErrorDialog); | ||
|
||
FilesPolicyErrorDialog() = delete; | ||
FilesPolicyErrorDialog(std::map<DlpConfidentialFile, Policy> files, | ||
DlpFileDestination destination, | ||
dlp::FileAction action, | ||
gfx::NativeWindow modal_parent); | ||
FilesPolicyErrorDialog(const FilesPolicyErrorDialog&) = delete; | ||
FilesPolicyErrorDialog(FilesPolicyErrorDialog&&) = delete; | ||
FilesPolicyErrorDialog& operator=(const FilesPolicyErrorDialog&) = delete; | ||
FilesPolicyErrorDialog& operator=(FilesPolicyErrorDialog&&) = delete; | ||
~FilesPolicyErrorDialog() override; | ||
|
||
private: | ||
// PolicyDialogBase overrides: | ||
void MaybeAddConfidentialRows() override; | ||
|
||
// Called from the dialog's "Cancel" button. | ||
// Opens the help page for policy/-ies that blocked the file action. | ||
void OpenHelpPage(); | ||
|
||
// Called from the dialog's "OK" button. | ||
// Dismisses the dialog. | ||
void Dismiss(); | ||
|
||
std::map<DlpConfidentialFile, Policy> files_; | ||
|
||
base::WeakPtrFactory<FilesPolicyErrorDialog> weak_factory_{this}; | ||
}; | ||
|
||
} // namespace policy | ||
|
||
#endif // CHROME_BROWSER_CHROMEOS_POLICY_DLP_DIALOGS_FILES_POLICY_ERROR_DIALOG_H_ |
Oops, something went wrong.