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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/payment_request_row_view.cc
diff --git a/chrome/browser/ui/views/payments/payment_request_row_view.cc b/chrome/browser/ui/views/payments/payment_request_row_view.cc
index 05cdb38e999b986af13264bd56ce0a44a993ae1d..6c6a13e28d8c6323416f8698c6fd3368d8d4cee9 100644
--- a/chrome/browser/ui/views/payments/payment_request_row_view.cc
+++ b/chrome/browser/ui/views/payments/payment_request_row_view.cc
@@ -6,8 +6,10 @@
#include "chrome/browser/ui/views/payments/payment_request_views_util.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "ui/native_theme/native_theme.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
+#include "ui/views/widget/widget.h"
namespace payments {
@@ -16,18 +18,39 @@ PaymentRequestRowView::PaymentRequestRowView(views::ButtonListener* listener,
: views::CustomButton(listener), clickable_(clickable) {
SetEnabled(clickable_);
SetBorder(payments::CreatePaymentRequestRowBorder());
+ SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
}
PaymentRequestRowView::~PaymentRequestRowView() {}
+void PaymentRequestRowView::SetActiveBackground() {
+ ui::NativeTheme* theme = GetWidget()->GetNativeTheme();
+ set_background(views::Background::CreateSolidBackground(theme->GetSystemColor(
+ ui::NativeTheme::kColorId_ResultsTableHoveredBackground)));
+}
+
// views::CustomButton:
void PaymentRequestRowView::StateChanged(ButtonState old_state) {
if (clickable_ && (state() == views::Button::STATE_HOVERED ||
state() == views::Button::STATE_PRESSED)) {
- set_background(views::Background::CreateSolidBackground(SK_ColorLTGRAY));
+ SetActiveBackground();
} else {
set_background(nullptr);
}
}
+void PaymentRequestRowView::OnFocus() {
+ if (clickable_) {
+ SetActiveBackground();
+ SchedulePaint();
+ }
+}
+
+void PaymentRequestRowView::OnBlur() {
+ if (clickable_) {
+ set_background(nullptr);
+ SchedulePaint();
+ }
+}
+
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698