OLD | NEW |
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_sheet_controller.h" | 5 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 9 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 10 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
9 #include "components/payments/content/payment_request.h" | 11 #include "components/payments/content/payment_request.h" |
10 #include "components/strings/grit/components_strings.h" | 12 #include "components/strings/grit/components_strings.h" |
11 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
12 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
13 #include "ui/views/background.h" | 15 #include "ui/views/background.h" |
14 #include "ui/views/border.h" | 16 #include "ui/views/border.h" |
15 #include "ui/views/controls/button/md_text_button.h" | 17 #include "ui/views/controls/button/md_text_button.h" |
16 #include "ui/views/controls/scroll_view.h" | 18 #include "ui/views/controls/scroll_view.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 view->SetFirstFocusableView(GetFirstFocusedView()); | 249 view->SetFirstFocusableView(GetFirstFocusedView()); |
248 return std::move(view); | 250 return std::move(view); |
249 } | 251 } |
250 | 252 |
251 void PaymentRequestSheetController::UpdateContentView() { | 253 void PaymentRequestSheetController::UpdateContentView() { |
252 content_view_->RemoveAllChildViews(true); | 254 content_view_->RemoveAllChildViews(true); |
253 FillContentView(content_view_); | 255 FillContentView(content_view_); |
254 RelayoutPane(); | 256 RelayoutPane(); |
255 } | 257 } |
256 | 258 |
| 259 void PaymentRequestSheetController::UpdateFocus(views::View* focused_view) { |
| 260 DialogViewID sheet_id; |
| 261 if (GetSheetId(&sheet_id)) { |
| 262 SheetView* sheet_view = static_cast<SheetView*>( |
| 263 dialog()->GetViewByID(static_cast<int>(sheet_id))); |
| 264 // This will be null on first call since it's not been set until CreateView |
| 265 // returns, and the first call to UpdateContentView comes from CreateView. |
| 266 if (sheet_view) { |
| 267 sheet_view->SetFirstFocusableView(focused_view); |
| 268 dialog()->RequestFocus(); |
| 269 } |
| 270 } |
| 271 } |
| 272 |
257 void PaymentRequestSheetController::RelayoutPane() { | 273 void PaymentRequestSheetController::RelayoutPane() { |
258 content_view_->Layout(); | 274 content_view_->Layout(); |
259 pane_->SizeToPreferredSize(); | 275 pane_->SizeToPreferredSize(); |
260 // Now that the content and its surrounding pane are updated, force a Layout | 276 // Now that the content and its surrounding pane are updated, force a Layout |
261 // on the ScrollView so that it updates its scroll bars now. | 277 // on the ScrollView so that it updates its scroll bars now. |
262 scroll_->Layout(); | 278 scroll_->Layout(); |
263 } | 279 } |
264 | 280 |
265 std::unique_ptr<views::Button> | 281 std::unique_ptr<views::Button> |
266 PaymentRequestSheetController::CreatePrimaryButton() { | 282 PaymentRequestSheetController::CreatePrimaryButton() { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 380 |
365 bool PaymentRequestSheetController::PerformPrimaryButtonAction() { | 381 bool PaymentRequestSheetController::PerformPrimaryButtonAction() { |
366 if (primary_button_ && primary_button_->enabled()) { | 382 if (primary_button_ && primary_button_->enabled()) { |
367 ButtonPressed(primary_button_.get(), DummyEvent()); | 383 ButtonPressed(primary_button_.get(), DummyEvent()); |
368 return true; | 384 return true; |
369 } | 385 } |
370 return false; | 386 return false; |
371 } | 387 } |
372 | 388 |
373 } // namespace payments | 389 } // namespace payments |
OLD | NEW |