blob: 7f656c15be99e66eaad18c491f53e82b43786a7c [file] [log] [blame]
// Copyright (c) 2019 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.
#include "ash/app_list/views/contents_view.h"
#include "base/callback.h"
#include "ui/views/window/dialog_delegate.h"
namespace ash {
// RemoveQueryConfirmationDialog displays the confirmation dialog for removing
// a recent query suggestion.
class RemoveQueryConfirmationDialog
: public views::DialogDelegateView,
public ContentsView::SearchBoxUpdateObserver {
// Callback to notify user's confirmation for removing the zero state
// suggestion query. Invoked with true if user confirms removing query
// suggestion; and false for declining the removal. The second parameter is
// the event flags of user action for invoking the removal action on the
// associated result.
using RemovalConfirmationCallback = base::OnceCallback<void(bool, int)>;
RemoveQueryConfirmationDialog(const base::string16& query,
RemovalConfirmationCallback callback,
int event_flags,
ContentsView* contents_view);
~RemoveQueryConfirmationDialog() override;
// Shows the dialog with |parent|.
void Show(gfx::NativeWindow parent);
// views::View:
const char* GetClassName() const override;
// views::WidgetDelegate:
base::string16 GetWindowTitle() const override;
ui::ModalType GetModalType() const override;
bool ShouldShowCloseButton() const override;
// views::View:
gfx::Size CalculatePreferredSize() const override;
// ContentsView::SearchBoxUpdateObserver
void OnSearchBoxBoundsUpdated() override;
void OnSearchBoxClearAndDeactivated() override;
void UpdateBounds();
RemovalConfirmationCallback confirm_callback_;
int event_flags_;
ContentsView* const contents_view_; // Owned by the views hierarchy
} // namespace ash