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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_row_view.cc

Issue 2853163002: [Web Payments] Implement proper focusing in Payment Request (Closed)
Patch Set: Address comments. Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/payments/payment_request_row_view.h" 5 #include "chrome/browser/ui/views/payments/payment_request_row_view.h"
6 6
7 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 7 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
8 #include "third_party/skia/include/core/SkColor.h" 8 #include "third_party/skia/include/core/SkColor.h"
9 #include "ui/native_theme/native_theme.h"
9 #include "ui/views/background.h" 10 #include "ui/views/background.h"
10 #include "ui/views/border.h" 11 #include "ui/views/border.h"
12 #include "ui/views/widget/widget.h"
11 13
12 namespace payments { 14 namespace payments {
13 15
14 PaymentRequestRowView::PaymentRequestRowView(views::ButtonListener* listener, 16 PaymentRequestRowView::PaymentRequestRowView(views::ButtonListener* listener,
15 bool clickable) 17 bool clickable)
16 : views::CustomButton(listener), clickable_(clickable) { 18 : views::CustomButton(listener), clickable_(clickable) {
17 SetEnabled(clickable_); 19 SetEnabled(clickable_);
18 SetBorder(payments::CreatePaymentRequestRowBorder()); 20 SetBorder(payments::CreatePaymentRequestRowBorder());
21 SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
19 } 22 }
20 23
21 PaymentRequestRowView::~PaymentRequestRowView() {} 24 PaymentRequestRowView::~PaymentRequestRowView() {}
22 25
26 void PaymentRequestRowView::SetActiveBackground() {
27 ui::NativeTheme* theme = GetWidget()->GetNativeTheme();
28 set_background(views::Background::CreateSolidBackground(theme->GetSystemColor(
29 ui::NativeTheme::kColorId_ResultsTableHoveredBackground)));
30 }
31
23 // views::CustomButton: 32 // views::CustomButton:
24 void PaymentRequestRowView::StateChanged(ButtonState old_state) { 33 void PaymentRequestRowView::StateChanged(ButtonState old_state) {
25 if (clickable_ && (state() == views::Button::STATE_HOVERED || 34 if (clickable_ && (state() == views::Button::STATE_HOVERED ||
26 state() == views::Button::STATE_PRESSED)) { 35 state() == views::Button::STATE_PRESSED)) {
27 set_background(views::Background::CreateSolidBackground(SK_ColorLTGRAY)); 36 SetActiveBackground();
28 } else { 37 } else {
29 set_background(nullptr); 38 set_background(nullptr);
30 } 39 }
31 } 40 }
32 41
42 void PaymentRequestRowView::OnFocus() {
43 if (clickable_) {
44 SetActiveBackground();
45 SchedulePaint();
46 }
47 }
48
49 void PaymentRequestRowView::OnBlur() {
50 if (clickable_) {
51 set_background(nullptr);
52 SchedulePaint();
53 }
54 }
55
33 } // namespace payments 56 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698