File: glic_tab_indicator_helper.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (64 lines) | stat: -rw-r--r-- 2,473 bytes parent folder | download | duplicates (3)
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
// Copyright 2024 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_GLIC_BROWSER_UI_GLIC_TAB_INDICATOR_HELPER_H_
#define CHROME_BROWSER_GLIC_BROWSER_UI_GLIC_TAB_INDICATOR_HELPER_H_

#include <vector>

#include "base/callback_list.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "chrome/browser/glic/host/context/glic_tab_data.h"
#include "components/tabs/public/tab_interface.h"

namespace glic {

// This class is partially responsible for updating tab indicators for glic
// focus. TODO(crbug.com/393557651): Simplify TabRendererData design, at which
// point this class can be fully responsible.
//
// Tab UI reflects feature state (such as the glic focused tab), but is stored
// on a per-index basis rather than a per-tab basis. This means that the UI
// needs to be updated either when the feature state changes, OR when the tab is
// moved around (either in the same tabstrip, or into a new tabstrip). The
// latter is currently handled by
// BrowserTabStripController::OnTabStripModelChanged. This class is only
// responsible for propagating glic focus changes for a fixed TabInterface,
// without handling moving and for changes to the sharing status of a tab.
class GlicTabIndicatorHelper {
 public:
  explicit GlicTabIndicatorHelper(tabs::TabInterface* tab);
  ~GlicTabIndicatorHelper();

 private:
  // Updates the Tab UI. This only needs to be called when the tab gains/loses
  // focus, or when the indicator status changes.
  void UpdateTab();

  // Called when the focused tab changes with the focused tab data object.
  void OnFocusedTabChanged(const FocusedTabData& focused_tab_data);

  // Called when the client changes the context access indicator status.
  void OnIndicatorStatusChanged(bool enabled);

  // Called when the tab's pinning status is updated.
  void OnTabPinningStatusChanged(tabs::TabInterface*, bool pinned);

  // Called when the tab is detached.
  void OnTabWillDetach(tabs::TabInterface* tab,
                       tabs::TabInterface::DetachReason reason);

  // Called when the tab is inserted.
  void OnTabDidInsert(tabs::TabInterface* tab);

  raw_ptr<tabs::TabInterface> tab_;
  bool tab_is_focused_ = false;
  bool is_detached_ = false;
  std::vector<base::CallbackListSubscription> subscriptions_;
};

}  // namespace glic

#endif  // CHROME_BROWSER_GLIC_BROWSER_UI_GLIC_TAB_INDICATOR_HELPER_H_