File: page_info_permission_content_view.h

package info (click to toggle)
chromium 139.0.7258.138-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,120,676 kB
  • sloc: cpp: 35,100,869; 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 (130 lines) | stat: -rw-r--r-- 5,299 bytes parent folder | download | duplicates (6)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// 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_PERMISSION_CONTENT_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_PERMISSION_CONTENT_VIEW_H_

#include "base/memory/raw_ptr.h"
#include "base/scoped_observation.h"
#include "components/page_info/page_info_ui.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/view.h"

#if !BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/ui/views/media_preview/page_info_previews_coordinator.h"
#include "components/media_effects/media_device_info.h"
#endif

class ChromePageInfoUiDelegate;
class NonAccessibleImageView;

namespace views {
class Checkbox;
class Label;
class ToggleButton;
}  // namespace views

// The view that is used as a content view of the permissions subpages in page
// info. It contains information about the permission (icon, title, state label)
// and controls to change the permission state (toggle, checkbox and manage
// button).
// *---------------------------------------------------------------*
// | Icon | Title                                         | Toggle |
// |      | State label                                   |        |
// |      |                                               |        |
// |      | "Remember this setting" checkbox              |        |
// |---------------------------------------------------------------|
// | Manage button                                                 |
// *---------------------------------------------------------------*
// The view for the File System permission subpage additionally contains a
// scrollable panel listing the files and/or directories with granted,
// active permissions.
// *---------------------------------------------------------------*
// | Icon | Title                                         | Toggle |
// |      | State label                                   |        |
// |      |--------------------------------------------------------|
// |      | Scrollable panel of files / directories                |
// |      |                                                        |
// |      | "Remember this setting" checkbox                       |
// |---------------------------------------------------------------|
// | Manage button                                                 |
// *---------------------------------------------------------------*
class PageInfoPermissionContentView
    : public views::View,
#if !BUILDFLAG(IS_CHROMEOS)
      public media_effects::MediaDeviceInfo::Observer,
#endif
      public PageInfoUI {
  METADATA_HEADER(PageInfoPermissionContentView, views::View)

 public:
  PageInfoPermissionContentView(PageInfo* presenter,
                                ChromePageInfoUiDelegate* ui_delegate,
                                ContentSettingsType type,
                                content::WebContents* web_contents);
  ~PageInfoPermissionContentView() override;

  // PageInfoUI implementations.
  void SetPermissionInfo(const PermissionInfoList& permission_info_list,
                         ChosenObjectInfoList chosen_object_info_list) override;

  const raw_ptr<views::ToggleButton> GetToggleButtonForTesting() const {
    return toggle_button_;
  }

#if !BUILDFLAG(IS_CHROMEOS)
  const raw_ptr<views::Label> GetTitleForTesting() const { return title_; }

  const std::optional<PageInfoPreviewsCoordinator>&
  GetPreviewsCoordinatorForTesting() const {
    return previews_coordinator_;
  }
#endif

 private:
  // views::View overrides
  void ChildPreferredSizeChanged(views::View* child) override;

  void OnToggleButtonPressed();
  void OnRememberSettingPressed();
  void PermissionChanged();
  void ToggleFileSystemExtendedPermissions();

#if !BUILDFLAG(IS_CHROMEOS)
  // media_effects::MediaDeviceInfo::Observer overrides.
  void OnAudioDevicesChanged(
      const std::optional<std::vector<media::AudioDeviceDescription>>&
          device_infos) override;
  void OnVideoDevicesChanged(
      const std::optional<std::vector<media::VideoCaptureDeviceInfo>>&
          device_infos) override;
  void SetTitleTextAndTooltip(int message_id,
                              const std::vector<std::string>& device_names);
#endif

  // Adds Media (Camera or Mic) live preview feeds.
  void MaybeAddMediaPreview(content::WebContents* web_contents,
                            views::View& preceding_separator);

  raw_ptr<PageInfo> presenter_ = nullptr;
  ContentSettingsType type_;
  raw_ptr<ChromePageInfoUiDelegate> ui_delegate_ = nullptr;
  base::WeakPtr<content::WebContents> web_contents_;
  PageInfo::PermissionInfo permission_;

  raw_ptr<NonAccessibleImageView> icon_ = nullptr;
  raw_ptr<views::Label> title_ = nullptr;
  raw_ptr<views::Label> state_label_ = nullptr;
  raw_ptr<views::ToggleButton> toggle_button_ = nullptr;
  raw_ptr<views::Checkbox> remember_setting_ = nullptr;

#if !BUILDFLAG(IS_CHROMEOS)
  std::optional<PageInfoPreviewsCoordinator> previews_coordinator_;
  base::ScopedObservation<media_effects::MediaDeviceInfo,
                          PageInfoPermissionContentView>
      devices_observer_{this};
#endif
};

#endif  // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_PERMISSION_CONTENT_VIEW_H_