File: password_bubble_view_base.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (89 lines) | stat: -rw-r--r-- 3,504 bytes parent folder | download | duplicates (5)
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
// Copyright 2017 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_VIEWS_PASSWORDS_PASSWORD_BUBBLE_VIEW_BASE_H_
#define CHROME_BROWSER_UI_VIEWS_PASSWORDS_PASSWORD_BUBBLE_VIEW_BASE_H_

#include "build/build_config.h"
#include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h"
#include "ui/base/metadata/metadata_header_macros.h"

namespace content {
class WebContents;
}

class Browser;
class PasswordBubbleControllerBase;

// Base class for all manage-passwords bubbles. Provides static methods for
// creating and showing these dialogs. Also used to access the web contents
// related to the dialog.
// These bubbles remove themselves as globals on destruction.
// TODO(pbos): Remove static global usage and move dialog ownership to
// TabDialog instances. Consider removing access to GetWebContents() through
// this class when ownership has moved to TabDialog instances, as it's hopefully
// no longer relevant for checking dialog ownership. These two work items should
// make this base class significantly smaller.
class PasswordBubbleViewBase : public LocationBarBubbleDelegateView {
  METADATA_HEADER(PasswordBubbleViewBase, LocationBarBubbleDelegateView)

 public:
  PasswordBubbleViewBase(const PasswordBubbleViewBase&) = delete;
  PasswordBubbleViewBase& operator=(const PasswordBubbleViewBase&) = delete;

  // Returns a pointer to the bubble.
  static PasswordBubbleViewBase* manage_password_bubble() {
    return g_manage_passwords_bubble_;
  }

  // Shows an appropriate bubble on the toolkit-views Browser window containing
  // |web_contents|.
  static void ShowBubble(content::WebContents* web_contents,
                         DisplayReason reason);
  // Creates and returns the passwords manager bubble UI appropriate for the
  // current password_manager::ui::State value for the provided |web_contents|.
  static PasswordBubbleViewBase* CreateBubble(
      content::WebContents* web_contents,
      views::View* anchor_view,
      DisplayReason reason);

  // Closes the existing bubble.
  static void CloseCurrentBubble();

  // Makes the bubble the foreground window.
  static void ActivateBubble();

  const content::WebContents* GetWebContents() const;

  // Returns the PasswordBubbleController used by the view. Returns nullptr if
  // the view is still using the ManagerPasswordBubbleModel instead of a
  // PasswordBubbleController.
  virtual PasswordBubbleControllerBase* GetController() = 0;
  virtual const PasswordBubbleControllerBase* GetController() const = 0;

 protected:
  // The |easily_dismissable| flag indicates if the bubble should close upon
  // a click in the content area of the browser.
  PasswordBubbleViewBase(content::WebContents* web_contents,
                         views::View* anchor_view,
                         bool easily_dismissable);

  ~PasswordBubbleViewBase() override;

  // Sets the resource ids of the images used in the header in light and dark
  // mode.
  void SetBubbleHeader(int light_image_id, int dark_image_id);

 private:
  // views::BubbleDialogDelegateView:
  void Init() override;

  raw_ptr<Browser> browser_ = nullptr;

  // Singleton instance of the Password bubble.The instance is owned by the
  // Bubble and will be deleted when the bubble closes.
  static PasswordBubbleViewBase* g_manage_passwords_bubble_;
};

#endif  // CHROME_BROWSER_UI_VIEWS_PASSWORDS_PASSWORD_BUBBLE_VIEW_BASE_H_