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

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

Issue 1955583002: Second try at fixing location bar icon keyboard activation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 bool IconLabelBubbleView::OnActivate() { 116 bool IconLabelBubbleView::OnActivate() {
117 return false; 117 return false;
118 } 118 }
119 119
120 gfx::Size IconLabelBubbleView::GetPreferredSize() const { 120 gfx::Size IconLabelBubbleView::GetPreferredSize() const {
121 // Height will be ignored by the LocationBarView. 121 // Height will be ignored by the LocationBarView.
122 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); 122 return GetSizeForLabelWidth(label_->GetPreferredSize().width());
123 } 123 }
124 124
125 bool IconLabelBubbleView::OnKeyPressed(const ui::KeyEvent& event) {
126 if (event.key_code() == ui::VKEY_RETURN)
127 return OnActivate();
128 return false;
129 }
130
125 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) { 131 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) {
126 if (event.key_code() != ui::VKEY_RETURN && event.key_code() != ui::VKEY_SPACE) 132 if (event.key_code() == ui::VKEY_SPACE)
127 return false; 133 return OnActivate();
128 return OnActivate(); 134 return false;
129 } 135 }
130 136
131 void IconLabelBubbleView::Layout() { 137 void IconLabelBubbleView::Layout() {
132 // 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
133 // whether this is an extension icon, since extension icons and 139 // whether this is an extension icon, since extension icons and
134 // 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
135 // 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.
136 const bool icon_has_enough_padding = 142 const bool icon_has_enough_padding =
137 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); 143 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial();
138 int image_x = GetOuterPadding(icon_has_enough_padding); 144 int image_x = GetOuterPadding(icon_has_enough_padding);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { 287 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
282 if (!ShouldShowBackground()) 288 if (!ShouldShowBackground())
283 return; 289 return;
284 if (background_painter_) { 290 if (background_painter_) {
285 views::Painter::PaintPainterAt(canvas, background_painter_.get(), 291 views::Painter::PaintPainterAt(canvas, background_painter_.get(),
286 GetContentsBounds()); 292 GetContentsBounds());
287 } 293 }
288 if (background()) 294 if (background())
289 background()->Paint(canvas, this); 295 background()->Paint(canvas, this);
290 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698