Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: chrome/browser/ui/views/website_settings/permission_selector_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" 5 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/website_settings/permission_menu_model.h" 8 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
9 #include "chrome/browser/ui/website_settings/website_settings_ui.h" 9 #include "chrome/browser/ui/website_settings/website_settings_ui.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 28 matching lines...) Expand all
39 // of the |model| remains with the caller and is not transfered to the 39 // of the |model| remains with the caller and is not transfered to the
40 // |PermissionMenuButton|. If the |show_menu_marker| flag is true, then a 40 // |PermissionMenuButton|. If the |show_menu_marker| flag is true, then a
41 // small icon is be displayed next to the button |text|, indicating that the 41 // small icon is be displayed next to the button |text|, indicating that the
42 // button opens a drop down menu. 42 // button opens a drop down menu.
43 PermissionMenuButton(const base::string16& text, 43 PermissionMenuButton(const base::string16& text,
44 PermissionMenuModel* model, 44 PermissionMenuModel* model,
45 bool show_menu_marker); 45 bool show_menu_marker);
46 virtual ~PermissionMenuButton(); 46 virtual ~PermissionMenuButton();
47 47
48 // Overridden from views::MenuButton. 48 // Overridden from views::MenuButton.
49 virtual gfx::Size GetPreferredSize() OVERRIDE; 49 virtual gfx::Size GetPreferredSize() const OVERRIDE;
50 50
51 // Overridden from views::TextButton. 51 // Overridden from views::TextButton.
52 virtual void SetText(const base::string16& text) OVERRIDE; 52 virtual void SetText(const base::string16& text) OVERRIDE;
53 53
54 // Overridden from views::View. 54 // Overridden from views::View.
55 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; 55 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
56 56
57 private: 57 private:
58 // Overridden from views::MenuButtonListener. 58 // Overridden from views::MenuButtonListener.
59 virtual void OnMenuButtonClicked(View* source, 59 virtual void OnMenuButtonClicked(View* source,
(...skipping 18 matching lines...) Expand all
78 ui::NativeTheme::kColorId_LabelEnabledColor)); 78 ui::NativeTheme::kColorId_LabelEnabledColor));
79 SetHoverColor(GetNativeTheme()->GetSystemColor( 79 SetHoverColor(GetNativeTheme()->GetSystemColor(
80 ui::NativeTheme::kColorId_LabelEnabledColor)); 80 ui::NativeTheme::kColorId_LabelEnabledColor));
81 SetDisabledColor(GetNativeTheme()->GetSystemColor( 81 SetDisabledColor(GetNativeTheme()->GetSystemColor(
82 ui::NativeTheme::kColorId_LabelDisabledColor)); 82 ui::NativeTheme::kColorId_LabelDisabledColor));
83 } 83 }
84 84
85 PermissionMenuButton::~PermissionMenuButton() { 85 PermissionMenuButton::~PermissionMenuButton() {
86 } 86 }
87 87
88 gfx::Size PermissionMenuButton::GetPreferredSize() { 88 gfx::Size PermissionMenuButton::GetPreferredSize() const {
89 gfx::Insets insets = GetInsets(); 89 gfx::Insets insets = GetInsets();
90 // Scale the button to the current text size. 90 // Scale the button to the current text size.
91 gfx::Size prefsize(text_size_.width() + insets.width(), 91 gfx::Size prefsize(text_size_.width() + insets.width(),
92 text_size_.height() + insets.height()); 92 text_size_.height() + insets.height());
93 if (max_width_ > 0) 93 if (max_width_ > 0)
94 prefsize.set_width(std::min(max_width_, prefsize.width())); 94 prefsize.set_width(std::min(max_width_, prefsize.width()));
95 if (show_menu_marker()) { 95 if (show_menu_marker()) {
96 prefsize.Enlarge(menu_marker()->width() + 96 prefsize.Enlarge(menu_marker()->width() +
97 views::MenuButton::kMenuMarkerPaddingLeft + 97 views::MenuButton::kMenuMarkerPaddingLeft +
98 views::MenuButton::kMenuMarkerPaddingRight, 98 views::MenuButton::kMenuMarkerPaddingRight,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // Update the menu button text to reflect the new setting. 228 // Update the menu button text to reflect the new setting.
229 menu_button_->SetText(WebsiteSettingsUI::PermissionActionToUIString( 229 menu_button_->SetText(WebsiteSettingsUI::PermissionActionToUIString(
230 permission.setting, 230 permission.setting,
231 permission.default_setting, 231 permission.default_setting,
232 content_settings::SETTING_SOURCE_USER)); 232 content_settings::SETTING_SOURCE_USER));
233 233
234 FOR_EACH_OBSERVER(PermissionSelectorViewObserver, 234 FOR_EACH_OBSERVER(PermissionSelectorViewObserver,
235 observer_list_, 235 observer_list_,
236 OnPermissionChanged(permission)); 236 OnPermissionChanged(permission));
237 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698