| 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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/views/layout_constants.h" | 8 #include "chrome/browser/ui/views/layout_constants.h" |
| 9 #include "ui/base/resource/material_design/material_design_controller.h" | 9 #include "ui/base/resource/material_design/material_design_controller.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 gfx::Size IconLabelBubbleView::GetPreferredSize() const { | 98 gfx::Size IconLabelBubbleView::GetPreferredSize() const { |
| 99 // Height will be ignored by the LocationBarView. | 99 // Height will be ignored by the LocationBarView. |
| 100 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); | 100 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void IconLabelBubbleView::Layout() { | 103 void IconLabelBubbleView::Layout() { |
| 104 // In MD mode, both extension icons and Chrome-provided icons are 16px, | 104 // In MD mode, both extension icons and Chrome-provided icons are 16px, |
| 105 // so it's not necessary to handle them differently. TODO(estade): clean | 105 // so it's not necessary to handle them differently. TODO(estade): clean |
| 106 // this up when MD is on by default. | 106 // this up when MD is on by default. |
| 107 bool icon_needs_extra_padding = | 107 bool icon_has_enough_padding = |
| 108 !is_extension_icon_ && !ui::MaterialDesignController::IsModeMaterial(); | 108 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); |
| 109 const int image_width = image()->GetPreferredSize().width(); | 109 const int image_width = image()->GetPreferredSize().width(); |
| 110 image_->SetBounds(std::min((width() - image_width) / 2, | 110 image_->SetBounds(std::min((width() - image_width) / 2, |
| 111 GetBubbleOuterPadding(icon_needs_extra_padding)), | 111 GetBubbleOuterPadding(icon_has_enough_padding)), |
| 112 0, image_->GetPreferredSize().width(), height()); | 112 0, image_->GetPreferredSize().width(), height()); |
| 113 | 113 |
| 114 const int padding = GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_PADDING); | 114 const int padding = GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_PADDING); |
| 115 int pre_label_width = | 115 int pre_label_width = |
| 116 GetBubbleOuterPadding(true) + (image_width ? (image_width + padding) : 0); | 116 GetBubbleOuterPadding(true) + (image_width ? (image_width + padding) : 0); |
| 117 label_->SetBounds(pre_label_width, 0, | 117 label_->SetBounds(pre_label_width, 0, |
| 118 width() - pre_label_width - GetBubbleOuterPadding(false), | 118 width() - pre_label_width - GetBubbleOuterPadding(false), |
| 119 height()); | 119 height()); |
| 120 } | 120 } |
| 121 | 121 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 const char* IconLabelBubbleView::GetClassName() const { | 158 const char* IconLabelBubbleView::GetClassName() const { |
| 159 return "IconLabelBubbleView"; | 159 return "IconLabelBubbleView"; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { | 162 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { |
| 163 if (!ShouldShowBackground()) | 163 if (!ShouldShowBackground()) |
| 164 return; | 164 return; |
| 165 if (background_painter_) | 165 if (background_painter_) |
| 166 background_painter_->Paint(canvas, size()); | 166 background_painter_->Paint(canvas, size()); |
| 167 } | 167 } |
| OLD | NEW |