Commit c8801d5d authored by Li Lin's avatar Li Lin Committed by Commit Bot

Only create QuickAnswersController if the feature is enabled.

Bug: b/156912750
Test: manual test
Change-Id: I4e7c4ee3623499108d8883009f85d94cc6d9d22b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207950
Commit-Queue: Li Lin <llin@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770699}
parent 7ab562dd
......@@ -25,6 +25,8 @@ class ASH_PUBLIC_EXPORT QuickAnswersController {
QuickAnswersController();
virtual ~QuickAnswersController();
// Get the instance of |QuickAnswersController|. It is only available when
// quick answers rich UI is enabled.
static QuickAnswersController* Get();
// Passes in a client instance for the controller to use.
......
......@@ -1071,7 +1071,10 @@ void Shell::Init(
magnification_controller_ = std::make_unique<MagnificationController>();
mru_window_tracker_ = std::make_unique<MruWindowTracker>();
assistant_controller_ = std::make_unique<AssistantControllerImpl>();
quick_answers_controller_ = std::make_unique<QuickAnswersControllerImpl>();
if (chromeos::features::IsQuickAnswersEnabled() &&
chromeos::features::IsQuickAnswersRichUiEnabled()) {
quick_answers_controller_ = std::make_unique<QuickAnswersControllerImpl>();
}
// |assistant_controller_| is put before |ambient_controller_| as it will be
// used by the latter.
......
......@@ -78,7 +78,8 @@ QuickAnswersMenuObserver::QuickAnswersMenuObserver(
.get(),
assistant_state, /*delegate=*/this);
quick_answers_controller_ = ash::QuickAnswersController::Get();
DCHECK(quick_answers_controller_);
if (!quick_answers_controller_)
return;
quick_answers_controller_->SetClient(std::make_unique<QuickAnswersClient>(
content::BrowserContext::GetDefaultStoragePartition(browser_context)
->GetURLLoaderFactoryForBrowserProcess()
......@@ -150,6 +151,8 @@ void QuickAnswersMenuObserver::OnContextMenuShown(
void QuickAnswersMenuObserver::OnContextMenuViewBoundsChanged(
const gfx::Rect& bounds_in_screen) {
if (!quick_answers_controller_)
return;
quick_answers_controller_->UpdateQuickAnswersAnchorBounds(bounds_in_screen);
}
......
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