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

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

Issue 1915063003: Change ContentSettingImageView activation to key release (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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 bool IconLabelBubbleView::IsShrinking() const { 108 bool IconLabelBubbleView::IsShrinking() const {
109 return false; 109 return false;
110 } 110 }
111 111
112 int IconLabelBubbleView::GetImageAndPaddingWidth() const { 112 int IconLabelBubbleView::GetImageAndPaddingWidth() const {
113 return image_->GetPreferredSize().width() + GetInternalSpacing(); 113 return image_->GetPreferredSize().width() + GetInternalSpacing();
114 } 114 }
115 115
116 bool IconLabelBubbleView::OnActivate() {
117 return false;
118 }
119
116 gfx::Size IconLabelBubbleView::GetPreferredSize() const { 120 gfx::Size IconLabelBubbleView::GetPreferredSize() const {
117 // Height will be ignored by the LocationBarView. 121 // Height will be ignored by the LocationBarView.
118 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); 122 return GetSizeForLabelWidth(label_->GetPreferredSize().width());
119 } 123 }
120 124
125 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) {
126 if (event.key_code() != ui::VKEY_RETURN && event.key_code() != ui::VKEY_SPACE)
127 return false;
128 return OnActivate();
129 }
130
121 void IconLabelBubbleView::Layout() { 131 void IconLabelBubbleView::Layout() {
122 // Compute the image bounds. In non-MD, the leading padding depends on 132 // Compute the image bounds. In non-MD, the leading padding depends on
123 // whether this is an extension icon, since extension icons and 133 // whether this is an extension icon, since extension icons and
124 // Chrome-provided icons are different sizes. In MD, these sizes are the 134 // Chrome-provided icons are different sizes. In MD, these sizes are the
125 // same, so it's not necessary to handle the two types differently. 135 // same, so it's not necessary to handle the two types differently.
126 const bool icon_has_enough_padding = 136 const bool icon_has_enough_padding =
127 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); 137 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial();
128 int image_x = GetOuterPadding(icon_has_enough_padding); 138 int image_x = GetOuterPadding(icon_has_enough_padding);
129 int bubble_trailing_padding = GetOuterPadding(false); 139 int bubble_trailing_padding = GetOuterPadding(false);
130 140
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { 281 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
272 if (!ShouldShowBackground()) 282 if (!ShouldShowBackground())
273 return; 283 return;
274 if (background_painter_) { 284 if (background_painter_) {
275 views::Painter::PaintPainterAt(canvas, background_painter_.get(), 285 views::Painter::PaintPainterAt(canvas, background_painter_.get(),
276 GetContentsBounds()); 286 GetContentsBounds());
277 } 287 }
278 if (background()) 288 if (background())
279 background()->Paint(canvas, this); 289 background()->Paint(canvas, this);
280 } 290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698