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 #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/utf_string_conversions.h" | 7 #include "base/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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void IconLabelBubbleView::Layout() { | 79 void IconLabelBubbleView::Layout() { |
80 image_->SetBounds(GetBubbleOuterPadding() + | 80 image_->SetBounds(GetBubbleOuterPadding() + |
81 (is_extension_icon_ ? LocationBarView::kIconInternalPadding : 0), 0, | 81 (is_extension_icon_ ? LocationBarView::kIconInternalPadding : 0), 0, |
82 image_->GetPreferredSize().width(), height()); | 82 image_->GetPreferredSize().width(), height()); |
83 const int label_height = label_->GetPreferredSize().height(); | 83 const int label_height = label_->GetPreferredSize().height(); |
84 label_->SetBounds(GetPreLabelWidth(), (height() - label_height) / 2, | 84 label_->SetBounds(GetPreLabelWidth(), (height() - label_height) / 2, |
85 width() - GetNonLabelWidth(), label_height); | 85 width() - GetNonLabelWidth(), label_height); |
86 } | 86 } |
87 | 87 |
88 void IconLabelBubbleView::SetElideInMiddle(bool elide_in_middle) { | 88 void IconLabelBubbleView::SetElideInMiddle(bool elide_in_middle) { |
89 label_->SetElideInMiddle(elide_in_middle); | 89 label_->SetElideBehavior( |
| 90 elide_in_middle ? views::Label::ELIDE_IN_MIDDLE : views::Label::NO_ELIDE); |
90 } | 91 } |
91 | 92 |
92 gfx::Size IconLabelBubbleView::GetNonLabelSize() const { | 93 gfx::Size IconLabelBubbleView::GetNonLabelSize() const { |
93 return gfx::Size(GetNonLabelWidth(), background_painter_.height()); | 94 return gfx::Size(GetNonLabelWidth(), background_painter_.height()); |
94 } | 95 } |
95 | 96 |
96 int IconLabelBubbleView::GetPreLabelWidth() const { | 97 int IconLabelBubbleView::GetPreLabelWidth() const { |
97 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 98 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
98 return GetBubbleOuterPadding() + | 99 return GetBubbleOuterPadding() + |
99 rb.GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)->width() + | 100 rb.GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)->width() + |
100 LocationBarView::GetItemPadding(); | 101 LocationBarView::GetItemPadding(); |
101 } | 102 } |
102 | 103 |
103 int IconLabelBubbleView::GetNonLabelWidth() const { | 104 int IconLabelBubbleView::GetNonLabelWidth() const { |
104 return GetPreLabelWidth() + GetBubbleOuterPadding(); | 105 return GetPreLabelWidth() + GetBubbleOuterPadding(); |
105 } | 106 } |
OLD | NEW |