OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_ROW_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_ROW_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "base/macros.h" | |
12 #include "base/observer_list.h" | |
13 #include "chrome/browser/ui/page_info/permission_menu_model.h" | |
14 #include "chrome/browser/ui/page_info/website_settings_ui.h" | |
15 #include "chrome/browser/ui/views/website_settings/permission_selector_row_obser
ver.h" | |
16 #include "components/content_settings/core/common/content_settings.h" | |
17 #include "components/content_settings/core/common/content_settings_types.h" | |
18 #include "ui/views/controls/button/menu_button_listener.h" | |
19 | |
20 class Profile; | |
21 | |
22 namespace internal { | |
23 class ComboboxModelAdapter; | |
24 class PermissionCombobox; | |
25 class PermissionMenuButton; | |
26 } | |
27 | |
28 namespace test { | |
29 class WebsiteSettingsPopupViewTestApi; | |
30 } | |
31 | |
32 namespace views { | |
33 class GridLayout; | |
34 class ImageView; | |
35 class Label; | |
36 class View; | |
37 } | |
38 | |
39 // A |PermissionSelectorRow| is a row in the Page Info bubble that shows a | |
40 // permission that a site can have ambient access to, and allows the user to | |
41 // control whether that access is granted. A |PermissionSelectorRow| is not | |
42 // itself a |View|, but creates some |View|s, which end up owned by the |View| | |
43 // hierarchy. | |
44 class PermissionSelectorRow { | |
45 public: | |
46 // The |PermissionSelectorRow|'s constituent views are added to |layout|. | |
47 PermissionSelectorRow(Profile* profile, | |
48 const GURL& url, | |
49 const WebsiteSettingsUI::PermissionInfo& permission, | |
50 views::GridLayout* layout); | |
51 virtual ~PermissionSelectorRow(); | |
52 | |
53 void AddObserver(PermissionSelectorRowObserver* observer); | |
54 | |
55 void PermissionChanged(const WebsiteSettingsUI::PermissionInfo& permission); | |
56 | |
57 private: | |
58 friend class test::WebsiteSettingsPopupViewTestApi; | |
59 | |
60 void InitializeMenuButtonView( | |
61 views::GridLayout* layout, | |
62 const WebsiteSettingsUI::PermissionInfo& permission); | |
63 void InitializeComboboxView( | |
64 views::GridLayout* layout, | |
65 const WebsiteSettingsUI::PermissionInfo& permission); | |
66 | |
67 // Returns the "button" for this row, which is the control used to change the | |
68 // permission's value. This is either a |MenuButton| or a |Combobox|. | |
69 views::View* button(); | |
70 | |
71 Profile* profile_; | |
72 | |
73 // Model for the permission's menu. | |
74 std::unique_ptr<PermissionMenuModel> menu_model_; | |
75 std::unique_ptr<internal::ComboboxModelAdapter> combobox_model_adapter_; | |
76 | |
77 // These are all owned by the views hierarchy: | |
78 views::ImageView* icon_; | |
79 views::Label* label_; | |
80 internal::PermissionMenuButton* menu_button_; | |
81 internal::PermissionCombobox* combobox_; | |
82 | |
83 base::ObserverList<PermissionSelectorRowObserver, false> observer_list_; | |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(PermissionSelectorRow); | |
86 }; | |
87 | |
88 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_ROW_H_ | |
OLD | NEW |