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

Unified Diff: chrome/browser/ui/views/payments/view_stack.cc

Issue 2853163002: [Web Payments] Implement proper focusing in Payment Request (Closed)
Patch Set: Allow ViewControllers to specify their first focused view 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/view_stack.cc
diff --git a/chrome/browser/ui/views/payments/view_stack.cc b/chrome/browser/ui/views/payments/view_stack.cc
index 78f44ef73b87bea26d3d059054f024f29581085d..ac77c98e386461a3549f80965666fc9e2c2803d4 100644
--- a/chrome/browser/ui/views/payments/view_stack.cc
+++ b/chrome/browser/ui/views/payments/view_stack.cc
@@ -49,6 +49,7 @@ void ViewStack::Push(std::unique_ptr<views::View> view, bool animate) {
// Add the new view to the stack so it can be popped later when navigating
// back to the previous screen.
stack_.push_back(std::move(view));
+ RequestFocus();
Mathieu 2017/05/02 13:16:10 I'm curious, does this still work even though the
anthonyvd 2017/05/02 13:43:32 Yeah, the other view gets focused right away but d
}
void ViewStack::Pop() {
@@ -95,6 +96,14 @@ void ViewStack::Layout() {
UpdateAnimatorBounds(slide_out_animator_.get(), out_new_destination);
}
+void ViewStack::RequestFocus() {
+ // The view can only be focused if it has a widget already. It's possible that
+ // this isn't the case if some views are pushed before the stack is added to a
+ // hierarchy that has a widget.
+ if (top()->GetWidget())
+ top()->RequestFocus();
+}
+
void ViewStack::UpdateAnimatorBounds(
views::BoundsAnimator* animator, const gfx::Rect& target) {
// If an animator is currently animating, figure out which views and update
@@ -115,4 +124,5 @@ void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) {
stack_.pop_back();
DCHECK(!stack_.empty()) << "State stack should never be empty";
+ RequestFocus();
}

Powered by Google App Engine
This is Rietveld 408576698