search_result_page_dialog_controller.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include "ash/app_list/views/search_result_page_dialog_controller.h"
  5. #include <utility>
  6. #include "ash/app_list/views/search_result_page_anchored_dialog.h"
  7. #include "ui/views/widget/widget.h"
  8. #include "ui/views/window/dialog_delegate.h"
  9. namespace ash {
  10. SearchResultPageDialogController::SearchResultPageDialogController(
  11. views::View* host_view)
  12. : host_view_(host_view) {}
  13. SearchResultPageDialogController::~SearchResultPageDialogController() = default;
  14. void SearchResultPageDialogController::Show(
  15. std::unique_ptr<views::WidgetDelegate> dialog) {
  16. if (!enabled_)
  17. return;
  18. dialog_ = std::make_unique<SearchResultPageAnchoredDialog>(
  19. std::move(dialog), host_view_,
  20. base::BindOnce(&SearchResultPageDialogController::OnAnchoredDialogClosed,
  21. base::Unretained(this)));
  22. dialog_->UpdateBounds();
  23. dialog_->widget()->Show();
  24. }
  25. void SearchResultPageDialogController::Reset(bool enabled) {
  26. enabled_ = enabled;
  27. dialog_.reset();
  28. }
  29. void SearchResultPageDialogController::OnAnchoredDialogClosed() {
  30. dialog_.reset();
  31. }
  32. } // namespace ash