Chromium Code Reviews| Index: chrome/browser/ui/views/website_settings/permission_selector_view.cc |
| diff --git a/chrome/browser/ui/views/website_settings/permission_selector_view.cc b/chrome/browser/ui/views/website_settings/permission_selector_view.cc |
| index f7a790e3954196db0b4883c84f20ddf4a97e93d7..2deddc2c116cce5e1516048c86e67a468d8548f4 100644 |
| --- a/chrome/browser/ui/views/website_settings/permission_selector_view.cc |
| +++ b/chrome/browser/ui/views/website_settings/permission_selector_view.cc |
| @@ -94,8 +94,14 @@ class PermissionMenuButton : public views::MenuButton, |
| PermissionMenuModel* model); |
| virtual ~PermissionMenuButton(); |
| + // Overridden from views::MenuButton. |
| + virtual gfx::Size GetPreferredSize() OVERRIDE; |
| + |
| + // Overridden from views::TextButton. |
| + virtual void SetText(const string16& text) OVERRIDE; |
| + |
| private: |
| - // Overridden from views::MenuButtonListener: |
| + // Overridden from views::MenuButtonListener. |
| virtual void OnMenuButtonClicked(View* source, |
| const gfx::Point& point) OVERRIDE; |
| @@ -158,7 +164,7 @@ void PermissionMenuModel::ExecuteCommand(int command_id) { |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| -// PermissionMenuModel |
| +// PermissionMenuButton |
| /////////////////////////////////////////////////////////////////////////////// |
| PermissionMenuButton::PermissionMenuButton(const string16& text, |
| @@ -170,6 +176,25 @@ PermissionMenuButton::PermissionMenuButton(const string16& text, |
| PermissionMenuButton::~PermissionMenuButton() { |
| } |
| +gfx::Size PermissionMenuButton::GetPreferredSize() { |
| + gfx::Insets insets = GetInsets(); |
| + // Scale the button to the current text size. |
|
msw
2012/07/26 20:01:33
Should there be a minimum size? What does this loo
markusheintz_
2012/07/30 12:55:37
The minimum size is the size to fit the menu marke
msw
2012/07/30 15:48:42
OK, that seems fine.
|
| + gfx::Size prefsize(text_size_.width() + insets.width(), |
| + text_size_.height() + insets.height()); |
| + if (max_width_ > 0) |
| + prefsize.set_width(std::min(max_width_, prefsize.width())); |
| + if (show_menu_marker()) { |
| + prefsize.Enlarge(menu_marker()->width() + 2 /*marke padding left + right*/, |
|
msw
2012/07/26 20:01:33
Shouldn't this use/match kMenuMarkerPaddingLeft an
markusheintz_
2012/07/30 12:55:37
Uups done.
On 2012/07/26 20:01:33, msw wrote:
|
| + 0); |
| + } |
| + return prefsize; |
| +} |
| + |
| +void PermissionMenuButton::SetText(const string16& text) { |
| + MenuButton::SetText(text); |
| + SizeToPreferredSize(); |
| +} |
| + |
| void PermissionMenuButton::OnMenuButtonClicked(View* source, |
| const gfx::Point& point) { |
| views::MenuModelAdapter menu_model_adapter(menu_model_); |
| @@ -286,5 +311,14 @@ ContentSettingsType PermissionSelectorView::GetPermissionType() const { |
| return menu_button_model_->site_permission(); |
| } |
| +void PermissionSelectorView::ChildPreferredSizeChanged(View* child) { |
| + SizeToPreferredSize(); |
| + // The parent is only a plain |View| that is used as a container/box/panel. |
| + // In order to not implment a custom |View| class with its own implementation |
|
msw
2012/07/26 20:01:33
nit: use indirect verbiage here: "Call SizeToPrefe
markusheintz_
2012/07/30 12:55:37
Done.
|
| + // of the ChildPreferredSizeChanged method, we call the SizeToPreferredSize |
| + // method of the parent directly from here. |
| + parent()->SizeToPreferredSize(); |
|
msw
2012/07/26 20:01:33
It's a little odd (perhaps bad) to make assumption
markusheintz_
2012/07/30 12:55:37
I totally agree with you this is odd.
It would be
|
| +} |
| + |
| PermissionSelectorView::~PermissionSelectorView() { |
| } |