File: glic_actor_task_icon_manager.h

package info (click to toggle)
chromium 141.0.7390.65-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,246,236 kB
  • sloc: cpp: 35,264,825; ansic: 7,169,920; javascript: 4,250,185; python: 1,460,623; asm: 950,788; xml: 751,717; pascal: 187,972; sh: 89,459; perl: 88,691; objc: 79,953; sql: 53,924; cs: 44,622; fortran: 24,137; makefile: 22,313; tcl: 15,277; php: 14,018; yacc: 8,995; ruby: 7,553; awk: 3,720; lisp: 3,096; lex: 1,330; ada: 727; jsp: 228; sed: 36
file content (101 lines) | stat: -rw-r--r-- 3,426 bytes parent folder | download | duplicates (4)
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_