Chromium Code Reviews| 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/views/background.h" | 14 #include "ui/views/background.h" |
| 13 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
| 14 #include "ui/views/controls/button/md_text_button.h" | 16 #include "ui/views/controls/button/md_text_button.h" |
| 15 #include "ui/views/controls/scroll_view.h" | 17 #include "ui/views/controls/scroll_view.h" |
| 16 #include "ui/views/focus/focus_search.h" | 18 #include "ui/views/focus/focus_search.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 UpdateContentView(); | 176 UpdateContentView(); |
| 175 | 177 |
| 176 view->SetFirstFocusableView(GetFirstFocusedView()); | 178 view->SetFirstFocusableView(GetFirstFocusedView()); |
| 177 return std::move(view); | 179 return std::move(view); |
| 178 } | 180 } |
| 179 | 181 |
| 180 void PaymentRequestSheetController::UpdateContentView() { | 182 void PaymentRequestSheetController::UpdateContentView() { |
| 181 content_view_->RemoveAllChildViews(true); | 183 content_view_->RemoveAllChildViews(true); |
| 182 FillContentView(content_view_); | 184 FillContentView(content_view_); |
| 183 RelayoutPane(); | 185 RelayoutPane(); |
| 186 DialogViewID sheet_id; | |
| 187 if (GetSheetId(&sheet_id)) { | |
|
anthonyvd
2017/05/12 14:19:44
Some views probably don't want this to happen here
MAD
2017/05/18 16:01:46
Done.
| |
| 188 SheetView* sheet_view = static_cast<SheetView*>( | |
| 189 dialog()->GetViewByID(static_cast<int>(sheet_id))); | |
| 190 // This will be null on first call since it's not been set until CreateView | |
| 191 // returns, and the first call to UpdateContentView comes from CreateView. | |
| 192 if (sheet_view) { | |
| 193 sheet_view->SetFirstFocusableView(GetFirstFocusedView()); | |
| 194 dialog()->RequestFocus(); | |
| 195 } | |
| 196 } | |
| 184 } | 197 } |
| 185 | 198 |
| 186 void PaymentRequestSheetController::RelayoutPane() { | 199 void PaymentRequestSheetController::RelayoutPane() { |
| 187 content_view_->Layout(); | 200 content_view_->Layout(); |
| 188 pane_->SizeToPreferredSize(); | 201 pane_->SizeToPreferredSize(); |
| 189 // Now that the content and its surrounding pane are updated, force a Layout | 202 // Now that the content and its surrounding pane are updated, force a Layout |
| 190 // on the ScrollView so that it updates its scroll bars now. | 203 // on the ScrollView so that it updates its scroll bars now. |
| 191 scroll_->Layout(); | 204 scroll_->Layout(); |
| 192 } | 205 } |
| 193 | 206 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 | 306 |
| 294 bool PaymentRequestSheetController::PerformPrimaryButtonAction() { | 307 bool PaymentRequestSheetController::PerformPrimaryButtonAction() { |
| 295 if (primary_button_ && primary_button_->enabled()) { | 308 if (primary_button_ && primary_button_->enabled()) { |
| 296 ButtonPressed(primary_button_.get(), DummyEvent()); | 309 ButtonPressed(primary_button_.get(), DummyEvent()); |
| 297 return true; | 310 return true; |
| 298 } | 311 } |
| 299 return false; | 312 return false; |
| 300 } | 313 } |
| 301 | 314 |
| 302 } // namespace payments | 315 } // namespace payments |
| OLD | NEW |