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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 | 121 |
| 122 bool IconLabelBubbleView::OnActivate() { | 122 bool IconLabelBubbleView::OnActivate() { |
| 123 return false; | 123 return false; |
| 124 } | 124 } |
| 125 | 125 |
| 126 gfx::Size IconLabelBubbleView::GetPreferredSize() const { | 126 gfx::Size IconLabelBubbleView::GetPreferredSize() const { |
| 127 // Height will be ignored by the LocationBarView. | 127 // Height will be ignored by the LocationBarView. |
| 128 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); | 128 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool IconLabelBubbleView::OnKeyPressed(const ui::KeyEvent& event) { | |
| 132 if (event.key_code() == ui::VKEY_RETURN) | |
| 133 return OnActivate(); | |
| 134 return false; | |
|
Peter Kasting
2016/05/04 02:21:00
BubbleIconView::OnKeyPressed() returned true for s
Evan Stade
2016/05/04 02:45:52
yea, this one isn't right; it should show a ripple
| |
| 135 } | |
| 136 | |
| 131 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) { | 137 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) { |
| 132 if (event.key_code() != ui::VKEY_RETURN && event.key_code() != ui::VKEY_SPACE) | 138 if (event.key_code() == ui::VKEY_SPACE) |
| 133 return false; | 139 return OnActivate(); |
| 134 return OnActivate(); | 140 return false; |
| 135 } | 141 } |
| 136 | 142 |
| 137 void IconLabelBubbleView::Layout() { | 143 void IconLabelBubbleView::Layout() { |
| 138 // Compute the image bounds. In non-MD, the leading padding depends on | 144 // Compute the image bounds. In non-MD, the leading padding depends on |
| 139 // whether this is an extension icon, since extension icons and | 145 // whether this is an extension icon, since extension icons and |
| 140 // Chrome-provided icons are different sizes. In MD, these sizes are the | 146 // Chrome-provided icons are different sizes. In MD, these sizes are the |
| 141 // same, so it's not necessary to handle the two types differently. | 147 // same, so it's not necessary to handle the two types differently. |
| 142 const bool icon_has_enough_padding = | 148 const bool icon_has_enough_padding = |
| 143 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); | 149 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); |
| 144 int image_x = GetOuterPadding(icon_has_enough_padding); | 150 int image_x = GetOuterPadding(icon_has_enough_padding); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { | 299 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { |
| 294 if (!ShouldShowBackground()) | 300 if (!ShouldShowBackground()) |
| 295 return; | 301 return; |
| 296 if (background_painter_) { | 302 if (background_painter_) { |
| 297 views::Painter::PaintPainterAt(canvas, background_painter_.get(), | 303 views::Painter::PaintPainterAt(canvas, background_painter_.get(), |
| 298 GetContentsBounds()); | 304 GetContentsBounds()); |
| 299 } | 305 } |
| 300 if (background()) | 306 if (background()) |
| 301 background()->Paint(canvas, this); | 307 background()->Paint(canvas, this); |
| 302 } | 308 } |
| OLD | NEW |