Chromium Code Reviews| 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/layout_constants.h" | 8 #include "chrome/browser/ui/layout_constants.h" |
| 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 10 #include "ui/base/material_design/material_design_controller.h" | 10 #include "ui/base/material_design/material_design_controller.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 } | 112 } |
| 113 | 113 |
| 114 double IconLabelBubbleView::WidthMultiplier() const { | 114 double IconLabelBubbleView::WidthMultiplier() const { |
| 115 return 1.0; | 115 return 1.0; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool IconLabelBubbleView::IsShrinking() const { | 118 bool IconLabelBubbleView::IsShrinking() const { |
| 119 return false; | 119 return false; |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool IconLabelBubbleView::OnActivate() { | |
| 123 return false; | |
| 124 } | |
| 125 | |
| 122 gfx::Size IconLabelBubbleView::GetPreferredSize() const { | 126 gfx::Size IconLabelBubbleView::GetPreferredSize() const { |
| 123 // Height will be ignored by the LocationBarView. | 127 // Height will be ignored by the LocationBarView. |
| 124 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); | 128 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); |
| 125 } | 129 } |
| 126 | 130 |
| 131 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) { | |
| 132 if (event.key_code() != ui::VKEY_RETURN && event.key_code() != ui::VKEY_SPACE) | |
|
msw
2016/04/20 23:57:55
nit: invert conditional to nest OnActivate?
Evan Stade
2016/04/24 17:45:26
I could see it going either way, but in the intere
| |
| 133 return false; | |
| 134 return OnActivate(); | |
| 135 } | |
| 136 | |
| 127 void IconLabelBubbleView::Layout() { | 137 void IconLabelBubbleView::Layout() { |
| 128 // Compute the image bounds. In non-MD, the leading padding depends on | 138 // Compute the image bounds. In non-MD, the leading padding depends on |
| 129 // whether this is an extension icon, since extension icons and | 139 // whether this is an extension icon, since extension icons and |
| 130 // Chrome-provided icons are different sizes. In MD, these sizes are the | 140 // Chrome-provided icons are different sizes. In MD, these sizes are the |
| 131 // same, so it's not necessary to handle the two types differently. | 141 // same, so it's not necessary to handle the two types differently. |
| 132 const bool icon_has_enough_padding = | 142 const bool icon_has_enough_padding = |
| 133 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); | 143 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); |
| 134 int image_x = GetOuterPadding(icon_has_enough_padding); | 144 int image_x = GetOuterPadding(icon_has_enough_padding); |
| 135 int bubble_trailing_padding = GetOuterPadding(false); | 145 int bubble_trailing_padding = GetOuterPadding(false); |
| 136 | 146 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { | 293 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { |
| 284 if (!ShouldShowBackground()) | 294 if (!ShouldShowBackground()) |
| 285 return; | 295 return; |
| 286 if (background_painter_) { | 296 if (background_painter_) { |
| 287 views::Painter::PaintPainterAt(canvas, background_painter_.get(), | 297 views::Painter::PaintPainterAt(canvas, background_painter_.get(), |
| 288 GetContentsBounds()); | 298 GetContentsBounds()); |
| 289 } | 299 } |
| 290 if (background()) | 300 if (background()) |
| 291 background()->Paint(canvas, this); | 301 background()->Paint(canvas, this); |
| 292 } | 302 } |
| OLD | NEW |