File: permission_selector_row.h

package info (click to toggle)
chromium-browser 70.0.3538.110-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,619,476 kB
  • sloc: cpp: 13,024,755; ansic: 1,349,823; python: 916,672; xml: 314,489; java: 280,047; asm: 276,936; perl: 75,771; objc: 66,634; sh: 45,860; cs: 28,354; php: 11,064; makefile: 10,911; yacc: 9,109; tcl: 8,403; ruby: 4,065; lex: 1,779; pascal: 1,411; lisp: 1,055; awk: 41; jsp: 39; sed: 17; sql: 3
file content (95 lines) | stat: -rw-r--r-- 3,283 bytes parent folder | download
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
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// 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_PERMISSION_SELECTOR_ROW_H_
#define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PERMISSION_SELECTOR_ROW_H_

#include <memory>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/observer_list.h"
#include "chrome/browser/ui/page_info/page_info_ui.h"
#include "chrome/browser/ui/page_info/permission_menu_model.h"
#include "chrome/browser/ui/views/page_info/permission_selector_row_observer.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "ui/views/controls/button/menu_button_listener.h"

class Profile;

namespace internal {
class ComboboxModelAdapter;
class PermissionCombobox;
class PermissionMenuButton;
}  // namespace internal

namespace test {
class PageInfoBubbleViewTestApi;
}

namespace views {
class GridLayout;
class ImageView;
class Label;
class View;
}  // namespace views

// A |PermissionSelectorRow| is a row in the Page Info bubble that shows a
// permission that a site can have ambient access to, and allows the user to
// control whether that access is granted. A |PermissionSelectorRow| is not
// itself a |View|, but creates some |View|s, which end up owned by the |View|
// hierarchy.
class PermissionSelectorRow {
 public:
  // The |PermissionSelectorRow|'s constituent views are added to |layout|.
  PermissionSelectorRow(Profile* profile,
                        const GURL& url,
                        const PageInfoUI::PermissionInfo& permission,
                        views::GridLayout* layout);
  virtual ~PermissionSelectorRow();

  // Retrieve the minimum height a |PermissionSelectorRow| can be.
  static int MinHeightForPermissionRow();

  void AddObserver(PermissionSelectorRowObserver* observer);

  void PermissionChanged(const PageInfoUI::PermissionInfo& permission);

  // Returns the preferred width for the currently selected combobox option
  // (unchanged by any minimum width set using SetMinComboboxWidth()).
  int GetComboboxWidth() const;

  // Sets the minimum width for |combobox_|.
  void SetMinComboboxWidth(int width);

 private:
  friend class test::PageInfoBubbleViewTestApi;

  void InitializeComboboxView(views::GridLayout* layout,
                              const PageInfoUI::PermissionInfo& permission);

  // Returns the "button" for this row, which is the control used to change the
  // permission's value. This is either a |MenuButton| or a |Combobox|.
  views::View* button();

  Profile* profile_;

  // Model for the permission's menu.
  std::unique_ptr<PermissionMenuModel> menu_model_;
  std::unique_ptr<internal::ComboboxModelAdapter> combobox_model_adapter_;

  // These are all owned by the views hierarchy:
  views::ImageView* icon_;
  views::Label* label_;
  internal::PermissionMenuButton* menu_button_;
  internal::PermissionCombobox* combobox_;

  base::ObserverList<PermissionSelectorRowObserver, false>::Unchecked
      observer_list_;

  DISALLOW_COPY_AND_ASSIGN(PermissionSelectorRow);
};

#endif  // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PERMISSION_SELECTOR_ROW_H_