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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
// 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.
#ifndef CHROME_BROWSER_UI_TABS_GLIC_ACTOR_TASK_ICON_MANAGER_H_
#define CHROME_BROWSER_UI_TABS_GLIC_ACTOR_TASK_ICON_MANAGER_H_
#include "chrome/browser/actor/task_id.h"
#include "chrome/browser/glic/host/glic.mojom.h"
#include "chrome/browser/glic/widget/glic_window_controller.h"
#include "components/keyed_service/core/keyed_service.h"
namespace actor {
class ActorKeyedService;
} // namespace actor
class Profile;
namespace tabs {
struct ActorTaskIconState {
enum class Text {
// Default/no text.
kDefault,
// `Needs attention` text.
kNeedsAttention,
// `Complete Tasks` text.
kCompleteTasks,
};
// Whether the task icon should be visible.
bool is_visible = false;
// The text that should be displayed, may change this to a string in the
// future.
Text text = Text::kDefault;
bool operator==(const ActorTaskIconState& other) const {
return is_visible == other.is_visible && text == other.text;
}
};
class GlicActorTaskIconManager : public KeyedService {
public:
GlicActorTaskIconManager(Profile* profile,
actor::ActorKeyedService* actor_service,
glic::GlicWindowController& window_controller,
glic::Host& host);
~GlicActorTaskIconManager() override;
// Called whenever floaty updates.
void OnFloatyUpdate(glic::GlicWindowController::State floaty_state,
glic::mojom::CurrentView current_view);
// Called whenever actor task state updates.
void OnActorTaskStateUpdate(actor::TaskId task_id);
// Determines the state the task icon should be in.
void UpdateTaskIcon(glic::GlicWindowController::State floaty_state,
glic::mojom::CurrentView current_view);
// Register for this callback to get task icon state change notifications.
using TaskIconStateChangeCallback = base::RepeatingCallback<void(
glic::GlicWindowController::State floaty_state,
glic::mojom::CurrentView current_view,
const ActorTaskIconState& actor_task_icon_state)>;
base::CallbackListSubscription RegisterTaskIconStateChange(
TaskIconStateChangeCallback callback);
ActorTaskIconState GetCurrentActorTaskIconState() const;
raw_ptr<tabs::TabInterface> GetLastUpdatedTab();
// KeyedService:
void Shutdown() override;
private:
// Called once on startup.
void RegisterSubscriptions();
std::vector<base::CallbackListSubscription> callback_subscriptions_;
using TaskIconStateChangeCallbackList = base::RepeatingCallbackList<void(
glic::GlicWindowController::State floaty_state,
glic::mojom::CurrentView current_view,
const ActorTaskIconState& actor_task_icon_state)>;
TaskIconStateChangeCallbackList task_icon_state_change_callback_list_;
ActorTaskIconState current_actor_task_icon_state_;
// Determines whether to suppress the task icon text.
bool suppress_task_icon_text_ = false;
raw_ptr<Profile> profile_;
raw_ptr<actor::ActorKeyedService> actor_service_;
raw_ref<glic::GlicWindowController> window_controller_;
raw_ref<glic::Host> host_;
// TODO(mjenn): Update implementation for multi-tab actuation.
actor::TaskId current_task_id_;
};
} // namespace tabs
#endif // CHROME_BROWSER_UI_TABS_GLIC_ACTOR_TASK_ICON_MANAGER_H_
|