1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/tabs/glic_actor_task_icon_controller.h"
#include "base/functional/bind.h"
#include "chrome/browser/actor/actor_keyed_service.h"
#include "chrome/browser/ui/views/tabs/tab_strip_action_container.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_features.h"
namespace tabs {
GlicActorTaskIconController::GlicActorTaskIconController(
Profile* profile,
TabStripActionContainer* tab_strip_action_container)
: profile_(profile),
tab_strip_action_container_(tab_strip_action_container) {
if (base::FeatureList::IsEnabled(features::kGlicActorUi)) {
RegisterFloatyTaskStateCallback();
}
}
GlicActorTaskIconController::~GlicActorTaskIconController() = default;
void GlicActorTaskIconController::RegisterFloatyTaskStateCallback() {
#if BUILDFLAG(ENABLE_GLIC)
floaty_task_state_change_callback_subscription_.push_back(
actor::ActorKeyedService::Get(profile_)
->GetActorUiStateManager()
->RegisterFloatyTaskStateChange(
base::BindRepeating(&GlicActorTaskIconController::OnStateUpdate,
base::Unretained(this))));
// TODO(crbug.com/422439520): Call GetUiState() and update current window to
// maintain consistency across multiple windows.
#endif
}
#if BUILDFLAG(ENABLE_GLIC)
void GlicActorTaskIconController::OnStateUpdate(
actor::ui::ActorUiStateManagerInterface::UiState task_state,
glic::GlicWindowController::State floaty_state) {
switch (task_state) {
case actor::ui::ActorUiStateManagerInterface::UiState::kActive:
tab_strip_action_container_->ShowGlicActorTaskIcon();
break;
case actor::ui::ActorUiStateManagerInterface::UiState::kCheckTasks:
tab_strip_action_container_->TriggerGlicActorTaskIconCheckTasksNudge();
break;
case actor::ui::ActorUiStateManagerInterface::UiState::kInactive:
tab_strip_action_container_->HideGlicActorTaskIcon();
break;
}
switch (floaty_state) {
// Floaty state will only ever be sent if a task is not inactive (so if
// the Task Icon is already open).
case glic::GlicWindowController::State::kOpen:
// TODO(crbug.com/422439931): Highlight Gemini icon.
case glic::GlicWindowController::State::kClosed:
// TODO(crbug.com/422439931): Unhighlight Gemini icon.
case glic::GlicWindowController::State::kWaitingForGlicToLoad:
break;
}
}
#endif
} // namespace tabs
|