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

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add two more const for Windows. 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/location_bar/icon_label_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_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/views/location_bar/location_bar_view.h" 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9 #include "grit/theme_resources.h" 9 #include "grit/theme_resources.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 void IconLabelBubbleView::SetLabel(const base::string16& label) { 75 void IconLabelBubbleView::SetLabel(const base::string16& label) {
76 label_->SetText(label); 76 label_->SetText(label);
77 } 77 }
78 78
79 void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) { 79 void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) {
80 image_->SetImage(image_skia); 80 image_->SetImage(image_skia);
81 } 81 }
82 82
83 gfx::Size IconLabelBubbleView::GetPreferredSize() { 83 gfx::Size IconLabelBubbleView::GetPreferredSize() const {
84 // Height will be ignored by the LocationBarView. 84 // Height will be ignored by the LocationBarView.
85 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); 85 return GetSizeForLabelWidth(label_->GetPreferredSize().width());
86 } 86 }
87 87
88 void IconLabelBubbleView::Layout() { 88 void IconLabelBubbleView::Layout() {
89 image_->SetBounds(GetBubbleOuterPadding(!is_extension_icon_), 0, 89 image_->SetBounds(GetBubbleOuterPadding(!is_extension_icon_), 0,
90 image_->GetPreferredSize().width(), height()); 90 image_->GetPreferredSize().width(), height());
91 const int pre_label_width = GetPreLabelWidth(); 91 const int pre_label_width = GetPreLabelWidth();
92 label_->SetBounds(pre_label_width, 0, 92 label_->SetBounds(pre_label_width, 0,
93 width() - pre_label_width - GetBubbleOuterPadding(false), 93 width() - pre_label_width - GetBubbleOuterPadding(false),
(...skipping 28 matching lines...) Expand all
122 views::Painter* painter = (in_hover_ && hover_background_painter_) ? 122 views::Painter* painter = (in_hover_ && hover_background_painter_) ?
123 hover_background_painter_.get() : background_painter_.get(); 123 hover_background_painter_.get() : background_painter_.get();
124 painter->Paint(canvas, size()); 124 painter->Paint(canvas, size());
125 } 125 }
126 126
127 int IconLabelBubbleView::GetPreLabelWidth() const { 127 int IconLabelBubbleView::GetPreLabelWidth() const {
128 const int image_width = image_->GetPreferredSize().width(); 128 const int image_width = image_->GetPreferredSize().width();
129 return GetBubbleOuterPadding(true) + 129 return GetBubbleOuterPadding(true) +
130 (image_width ? (image_width + LocationBarView::kItemPadding) : 0); 130 (image_width ? (image_width + LocationBarView::kItemPadding) : 0);
131 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698