File: bubble_manager_impl.h

package info (click to toggle)
chromium 141.0.7390.65-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • 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 (80 lines) | stat: -rw-r--r-- 2,843 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// 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_AUTOFILL_BUBBLE_MANAGER_IMPL_H_
#define CHROME_BROWSER_UI_AUTOFILL_BUBBLE_MANAGER_IMPL_H_

#include <memory>
#include <set>

#include "base/time/time.h"
#include "chrome/browser/ui/autofill/bubble_controller_base.h"
#include "chrome/browser/ui/autofill/bubble_manager.h"

namespace autofill {

class BubbleManagerImpl : public BubbleManager {
 public:
  BubbleManagerImpl();
  ~BubbleManagerImpl() override;

  BubbleManagerImpl(const BubbleManagerImpl&) = delete;
  BubbleManagerImpl& operator=(const BubbleManagerImpl&) = delete;

  // BubbleManager:
  void RequestShowController(BubbleControllerBase& controller_to_show) override;
  void OnBubbleHiddenByController(
      BubbleControllerBase& controller_to_hide) override;
  bool HasPendingBubble(const BubbleControllerBase& controller) override;

 private:
  struct PendingRequest {
    PendingRequest(base::WeakPtr<BubbleControllerBase> controller,
                   base::TimeTicks time_added,
                   int priority);
    ~PendingRequest();
    PendingRequest(const PendingRequest& other);
    PendingRequest& operator=(const PendingRequest& other);

    // Sorts by priority (descending), then by time (ascending) as a
    // tie-breaker.
    bool operator<(const PendingRequest& other) const;

    base::WeakPtr<BubbleControllerBase> controller;
    base::TimeTicks time_added;
    int priority;
  };

  // Checks the pending bubbles queue and shows the highest-priority one if no
  // bubble is currently active.
  void ProcessPendingBubbles();

  // Shows the given controller, sets it as the active one, and ensures
  // it's removed from the pending queue.
  void ShowAndSetCurrentActive(
      base::WeakPtr<BubbleControllerBase> controller_to_show);

  // Adds a controller to the pending queue based on (uniqueness by type,
  // timeout, and password exception).
  void AddToPendingQueue(base::WeakPtr<BubbleControllerBase> controller);

  // Hides the currently active bubble to show a higher-priority one.
  void HideActiveBubbleForPreemption(
      base::WeakPtr<BubbleControllerBase> preempting_controller);

  // Currently active controller that is shown.
  base::WeakPtr<BubbleControllerBase> active_bubble_controller_ = nullptr;

  // A queue of controllers that have requested to be shown. The container is
  // kept sorted by priority and creation time.
  std::set<PendingRequest> pending_bubbles_queue_;

  // A boolean indicating that the manager is in the process of showing a
  // bubble. This could mean another bubble is in the process of preemption.
  bool handling_show_request_ = false;
};

}  // namespace autofill

#endif  // CHROME_BROWSER_UI_AUTOFILL_BUBBLE_MANAGER_IMPL_H_