search_result_page_dialog_controller.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_APP_LIST_VIEWS_SEARCH_RESULT_PAGE_DIALOG_CONTROLLER_H_
  5. #define ASH_APP_LIST_VIEWS_SEARCH_RESULT_PAGE_DIALOG_CONTROLLER_H_
  6. #include <memory>
  7. namespace views {
  8. class WidgetDelegate;
  9. class View;
  10. } // namespace views
  11. namespace ash {
  12. class SearchResultPageAnchoredDialog;
  13. // Controller that can be used to show a dialog anchored within the app list
  14. // search UI.
  15. class SearchResultPageDialogController {
  16. public:
  17. explicit SearchResultPageDialogController(views::View* host_view);
  18. SearchResultPageDialogController(const SearchResultPageDialogController&) =
  19. delete;
  20. SearchResultPageDialogController& operator=(
  21. const SearchResultPageDialogController&) = delete;
  22. ~SearchResultPageDialogController();
  23. // Shows a search results page dialog with contents `dialog_contents`.
  24. // No-op if not enabled.
  25. void Show(std::unique_ptr<views::WidgetDelegate> dialog_contents);
  26. // Sets whether search result page dialogs are enabled. It closes the
  27. // current dialog if it exists.
  28. void Reset(bool enabled);
  29. SearchResultPageAnchoredDialog* dialog() { return dialog_.get(); }
  30. private:
  31. // Called when the search result page dialog gets closed.
  32. void OnAnchoredDialogClosed();
  33. views::View* const host_view_;
  34. // Whether search result page dialogs are allowed. If false, calls to `Show()`
  35. // will be no-op.
  36. bool enabled_ = false;
  37. // Currently shown dialog - null when no dialog is shown.
  38. std::unique_ptr<SearchResultPageAnchoredDialog> dialog_;
  39. };
  40. } // namespace ash
  41. #endif // ASH_APP_LIST_VIEWS_SEARCH_RESULT_PAGE_DIALOG_CONTROLLER_H_