| 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_WEBSITE_SETTINGS_PERMISSION_SELECTOR_ROW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_ROW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_ROW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_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 "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "chrome/browser/ui/views/website_settings/permission_selector_row_obser
ver.h" | 14 #include "chrome/browser/ui/views/website_settings/permission_selector_row_obser
ver.h" |
| 15 #include "chrome/browser/ui/website_settings/permission_menu_model.h" | 15 #include "chrome/browser/ui/website_settings/permission_menu_model.h" |
| 16 #include "chrome/browser/ui/website_settings/website_settings_ui.h" | 16 #include "chrome/browser/ui/website_settings/website_settings_ui.h" |
| 17 #include "components/content_settings/core/common/content_settings.h" | 17 #include "components/content_settings/core/common/content_settings.h" |
| 18 #include "components/content_settings/core/common/content_settings_types.h" | 18 #include "components/content_settings/core/common/content_settings_types.h" |
| 19 #include "ui/views/controls/button/menu_button_listener.h" | 19 #include "ui/views/controls/button/menu_button_listener.h" |
| 20 #include "ui/views/layout/grid_layout.h" |
| 20 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 21 | 22 |
| 22 namespace internal { | 23 namespace internal { |
| 23 class ComboboxModelAdapter; | 24 class ComboboxModelAdapter; |
| 24 class PermissionCombobox; | 25 class PermissionCombobox; |
| 25 class PermissionMenuButton; | 26 class PermissionMenuButton; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace views { | 29 namespace views { |
| 29 class GridLayout; | 30 class GridLayout; |
| 30 class ImageView; | 31 class ImageView; |
| 31 class MenuRunner; | 32 class MenuRunner; |
| 32 } | 33 } |
| 33 | 34 |
| 34 // A PermissionSelectorRow is a row in the Page Info bubble that shows a | 35 // A PermissionSelectorRow is a row in the Page Info bubble that shows a |
| 35 // permission that a site can have ambient access to, and allows the user to | 36 // permission that a site can have ambient access to, and allows the user to |
| 36 // control whether that access is granted. | 37 // control whether that access is granted. |
| 37 class PermissionSelectorRow : public views::View { | 38 class PermissionSelectorRow { |
| 38 public: | 39 public: |
| 40 // The constructor adds two views to the current row of |layout|: |
| 41 // 1. An icon. |
| 42 // 2. A view with a left-aligned label and a right-aligned menu. |
| 39 PermissionSelectorRow(const GURL& url, | 43 PermissionSelectorRow(const GURL& url, |
| 40 const WebsiteSettingsUI::PermissionInfo& permission); | 44 const WebsiteSettingsUI::PermissionInfo& permission, |
| 45 views::GridLayout* layout); |
| 41 | 46 |
| 42 void AddObserver(PermissionSelectorRowObserver* observer); | 47 void AddObserver(PermissionSelectorRowObserver* observer); |
| 43 | 48 |
| 44 void PermissionChanged(const WebsiteSettingsUI::PermissionInfo& permission); | 49 void PermissionChanged(const WebsiteSettingsUI::PermissionInfo& permission); |
| 45 | 50 |
| 46 protected: | |
| 47 // Overridden from views::View. | |
| 48 void ChildPreferredSizeChanged(View* child) override; | |
| 49 | |
| 50 private: | 51 private: |
| 51 ~PermissionSelectorRow() override; | 52 ~PermissionSelectorRow(); |
| 52 | 53 |
| 53 void InitializeMenuButtonView( | 54 void InitializeMenuButtonView( |
| 54 views::GridLayout* layout, | 55 views::GridLayout* layout, |
| 55 const WebsiteSettingsUI::PermissionInfo& permission); | 56 const WebsiteSettingsUI::PermissionInfo& permission); |
| 56 void InitializeComboboxView( | 57 void InitializeComboboxView( |
| 57 views::GridLayout* layout, | 58 views::GridLayout* layout, |
| 58 const WebsiteSettingsUI::PermissionInfo& permission); | 59 const WebsiteSettingsUI::PermissionInfo& permission); |
| 59 | 60 |
| 60 // Model for the permission's menu. | 61 // Model for the permission's menu. |
| 61 std::unique_ptr<PermissionMenuModel> menu_model_; | 62 std::unique_ptr<PermissionMenuModel> menu_model_; |
| 62 std::unique_ptr<internal::ComboboxModelAdapter> combobox_model_adapter_; | 63 std::unique_ptr<internal::ComboboxModelAdapter> combobox_model_adapter_; |
| 63 | 64 |
| 64 views::ImageView* icon_; // Owned by the views hierachy. | 65 views::ImageView* icon_; // Owned by the views hierachy. |
| 65 internal::PermissionMenuButton* menu_button_; // Owned by the views hierachy. | 66 internal::PermissionMenuButton* menu_button_; // Owned by the views hierachy. |
| 66 internal::PermissionCombobox* combobox_; // Owned by the views hierarchy. | 67 internal::PermissionCombobox* combobox_; // Owned by the views hierarchy. |
| 67 | 68 |
| 68 base::ObserverList<PermissionSelectorRowObserver, false> observer_list_; | 69 base::ObserverList<PermissionSelectorRowObserver, false> observer_list_; |
| 69 | 70 |
| 70 DISALLOW_COPY_AND_ASSIGN(PermissionSelectorRow); | 71 DISALLOW_COPY_AND_ASSIGN(PermissionSelectorRow); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_ROW_H_ | 74 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_ROW_H_ |
| OLD | NEW |