File: page_info_bubble_view.h

package info (click to toggle)
chromium 140.0.7339.185-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,193,740 kB
  • sloc: cpp: 35,093,945; ansic: 7,161,670; javascript: 4,199,694; python: 1,441,797; asm: 949,904; xml: 747,515; pascal: 187,748; perl: 88,691; sh: 88,248; objc: 79,953; sql: 52,714; cs: 44,599; fortran: 24,137; makefile: 22,114; tcl: 15,277; php: 13,980; yacc: 9,000; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (104 lines) | stat: -rw-r--r-- 4,064 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright 2021 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_PAGE_INFO_PAGE_INFO_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_BUBBLE_VIEW_H_

#include <memory>

#include "base/callback_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "chrome/browser/ui/views/page_info/page_info_bubble_view_base.h"
#include "chrome/browser/ui/views/page_info/page_info_navigation_handler.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/page_info/core/page_info_types.h"
#include "ui/base/metadata/metadata_header_macros.h"

class ChromePageInfoUiDelegate;
class PageSwitcherView;
class PageInfoBubbleSpecification;
class PageInfoViewFactory;
class PageInfoMerchantTrustCoordinator;

// The views implementation of the page info UI.
class PageInfoBubbleView : public PageInfoBubbleViewBase,
                           public PageInfoNavigationHandler {
  METADATA_HEADER(PageInfoBubbleView, PageInfoBubbleViewBase)

 public:
  // The column set id of the permissions table for |permissions_view_|.
  static constexpr int kPermissionColumnSetId = 0;

  ~PageInfoBubbleView() override;

  // Creates the appropriate page info bubble for the given |url|.
  // |anchor_view| will be used to place the bubble.  If |anchor_view| is null,
  // |anchor_rect| will be used instead.  |parent_window| will become the
  // parent of the widget hosting the bubble view.
  static views::BubbleDialogDelegateView* CreatePageInfoBubble(
      std::unique_ptr<PageInfoBubbleSpecification> specification);

  using PageInfoBubbleCreatedCallbackList =
      base::RepeatingCallbackList<void(content::WebContents* web_contents,
                                       views::Widget* bubble_widget)>;
  using PageInfoBubbleCreatedCallback =
      PageInfoBubbleCreatedCallbackList::CallbackType;

  static base::CallbackListSubscription RegisterPageInfoCreatedCallback(
      PageInfoBubbleCreatedCallback callback);

  // PageInfoNavigationHandler:
  void OpenMainPage(base::OnceClosure initialized_callback) override;
  void OpenSecurityPage() override;
  void OpenPermissionPage(ContentSettingsType type) override;
  void OpenAdPersonalizationPage() override;
  void OpenCookiesPage() override;
  void OpenPrivacyAndSiteDataPage() override;
  void OpenMerchantTrustPage(
      page_info::MerchantBubbleOpenReferrer referrer) override;
  void CloseBubble() override;

  // WebContentsObserver:
  void DidChangeVisibleSecurityState() override;

  PageInfo* presenter_for_testing() { return presenter_.get(); }

 private:
  PageInfoBubbleView(views::View* anchor_view,
                     const gfx::Rect& anchor_rect,
                     gfx::NativeView parent_window,
                     content::WebContents* web_contents,
                     const GURL& url,
                     base::OnceClosure initialized_callback,
                     PageInfoClosingCallback closing_callback,
                     bool allow_extended_site_info);

  // PageInfoBubbleViewBase:
  gfx::Size CalculatePreferredSize(
      const views::SizeBounds& available_size) const override;
  void OnWidgetDestroying(views::Widget* widget) override;
  void WebContentsDestroyed() override;
  void ChildPreferredSizeChanged(views::View* child) override;

  void AnnouncePageOpened(std::u16string announcement);

  // The presenter that controls the Page Info UI.
  std::unique_ptr<PageInfo> presenter_;

  std::unique_ptr<ChromePageInfoUiDelegate> ui_delegate_;

  std::unique_ptr<PageInfoViewFactory> view_factory_;

  std::unique_ptr<PageInfoMerchantTrustCoordinator> merchant_trust_coordinator_;

  raw_ptr<PageSwitcherView> page_container_ = nullptr;

  PageInfoClosingCallback closing_callback_;

  base::WeakPtrFactory<PageInfoBubbleView> weak_factory_{this};
};

#endif  // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_BUBBLE_VIEW_H_