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