Commit 721d71b3 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

cbuiv nativefs: use unconditional dialog closures

Switch the native fs usage bubble to use the DialogDelegate
closure callbacks rather than overriding Close/Cancel/Accept.

Bug: 1011446
Change-Id: Iec30886dbe1d53f9d4a40f33eb4082f17f73d68c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2047404Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740288}
parent 91e33bab
......@@ -304,6 +304,9 @@ NativeFileSystemUsageBubbleView::NativeFileSystemUsageBubbleView(
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(IDS_NATIVE_FILE_SYSTEM_USAGE_REMOVE_ACCESS));
DialogDelegate::set_cancel_callback(
base::BindOnce(&NativeFileSystemUsageBubbleView::OnDialogCancelled,
base::Unretained(this)));
}
NativeFileSystemUsageBubbleView::~NativeFileSystemUsageBubbleView() = default;
......@@ -383,27 +386,22 @@ void NativeFileSystemUsageBubbleView::Init() {
}
}
bool NativeFileSystemUsageBubbleView::Cancel() {
void NativeFileSystemUsageBubbleView::OnDialogCancelled() {
base::RecordAction(
base::UserMetricsAction("NativeFileSystemAPI.RevokePermissions"));
if (!web_contents())
return true;
return;
content::BrowserContext* profile = web_contents()->GetBrowserContext();
auto* context =
NativeFileSystemPermissionContextFactory::GetForProfileIfExists(profile);
if (!context)
return true;
return;
context->RevokeGrants(origin_,
web_contents()->GetMainFrame()->GetProcess()->GetID(),
web_contents()->GetMainFrame()->GetRoutingID());
return true;
}
bool NativeFileSystemUsageBubbleView::Close() {
return true; // Do not revoke permissions via Cancel() when closing normally.
}
void NativeFileSystemUsageBubbleView::WindowClosing() {
......
......@@ -64,13 +64,13 @@ class NativeFileSystemUsageBubbleView : public LocationBarBubbleDelegateView {
base::string16 GetAccessibleWindowTitle() const override;
bool ShouldShowCloseButton() const override;
void Init() override;
bool Cancel() override;
bool Close() override;
void WindowClosing() override;
void CloseBubble() override;
gfx::Size CalculatePreferredSize() const override;
void ChildPreferredSizeChanged(views::View* child) override;
void OnDialogCancelled();
// Singleton instance of the bubble. The bubble can only be shown on the
// active browser window, so there is no case in which it will be shown
// twice at the same time.
......
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