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

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

Issue 1947533003: Second try at fixing location bar icon keyboard activation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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/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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698