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

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

Issue 2720223004: Use PaymentRequestItemList for Shipping screen (Closed)
Patch Set: tryna fix tests Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_views_util.h" 5 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
12 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h" 13 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
13 #include "components/autofill/core/browser/autofill_data_util.h" 14 #include "components/autofill/core/browser/autofill_data_util.h"
14 #include "components/autofill/core/browser/autofill_profile.h" 15 #include "components/autofill/core/browser/autofill_profile.h"
15 #include "components/autofill/core/browser/autofill_type.h" 16 #include "components/autofill/core/browser/autofill_type.h"
16 #include "components/autofill/core/browser/credit_card.h" 17 #include "components/autofill/core/browser/credit_card.h"
17 #include "components/autofill/core/browser/field_types.h" 18 #include "components/autofill/core/browser/field_types.h"
18 #include "third_party/skia/include/core/SkColor.h" 19 #include "third_party/skia/include/core/SkColor.h"
19 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/geometry/insets.h" 22 #include "ui/gfx/geometry/insets.h"
22 #include "ui/gfx/geometry/point_f.h" 23 #include "ui/gfx/geometry/point_f.h"
23 #include "ui/gfx/paint_vector_icon.h" 24 #include "ui/gfx/paint_vector_icon.h"
24 #include "ui/vector_icons/vector_icons.h" 25 #include "ui/vector_icons/vector_icons.h"
25 #include "ui/views/border.h" 26 #include "ui/views/border.h"
26 #include "ui/views/bubble/bubble_frame_view.h" 27 #include "ui/views/bubble/bubble_frame_view.h"
27 #include "ui/views/controls/button/button.h" 28 #include "ui/views/controls/button/button.h"
28 #include "ui/views/controls/button/vector_icon_button.h" 29 #include "ui/views/controls/button/vector_icon_button.h"
29 #include "ui/views/controls/image_view.h" 30 #include "ui/views/controls/image_view.h"
30 #include "ui/views/controls/label.h" 31 #include "ui/views/controls/label.h"
31 #include "ui/views/controls/styled_label.h" 32 #include "ui/views/controls/styled_label.h"
32 #include "ui/views/layout/grid_layout.h" 33 #include "ui/views/layout/grid_layout.h"
33 #include "ui/views/painter.h" 34 #include "ui/views/painter.h"
35 #include "ui/views/vector_icons.h"
34 #include "ui/views/view.h" 36 #include "ui/views/view.h"
35 37
36 namespace { 38 namespace {
37 39
38 // TODO(tmartino): Consider combining this with the Android equivalent in 40 // TODO(tmartino): Consider combining this with the Android equivalent in
39 // PersonalDataManager.java 41 // PersonalDataManager.java
40 base::string16 GetAddressFromProfile(const autofill::AutofillProfile& profile, 42 base::string16 GetAddressFromProfile(const autofill::AutofillProfile& profile,
41 const std::string& locale) { 43 const std::string& locale) {
42 std::vector<autofill::ServerFieldType> fields; 44 std::vector<autofill::ServerFieldType> fields;
43 fields.push_back(autofill::COMPANY_NAME); 45 fields.push_back(autofill::COMPANY_NAME);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 values.push_back(name_value); 210 values.push_back(name_value);
209 if (!phone_value.empty()) 211 if (!phone_value.empty())
210 values.push_back(phone_value); 212 values.push_back(phone_value);
211 if (!email_value.empty()) 213 if (!email_value.empty())
212 values.push_back(email_value); 214 values.push_back(email_value);
213 215
214 return base::MakeUnique<views::StyledLabel>( 216 return base::MakeUnique<views::StyledLabel>(
215 base::JoinString(values, base::ASCIIToUTF16("\n")), nullptr); 217 base::JoinString(values, base::ASCIIToUTF16("\n")), nullptr);
216 } 218 }
217 219
218 // Creates a views::Border object that can paint the gray horizontal ruler used
219 // as a separator between items in the Payment Request dialog.
220 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() { 220 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() {
221 return views::CreateBorderPainter( 221 return views::CreateBorderPainter(
222 base::MakeUnique<PaymentRequestRowBorderPainter>(), 222 base::MakeUnique<PaymentRequestRowBorderPainter>(),
223 gfx::Insets()); 223 gfx::Insets());
224 } 224 }
225 225
226 std::unique_ptr<views::ImageView> CreateCheckmark(bool selected) {
anthonyvd 2017/03/01 15:37:00 While you're moving this around: can you move it t
tmartino 2017/03/01 20:00:30 Done
227 std::unique_ptr<views::ImageView> checkmark =
228 base::MakeUnique<views::ImageView>();
229 checkmark->set_id(static_cast<int>(DialogViewID::CHECKMARK_VIEW));
230 checkmark->set_can_process_events_within_subtree(false);
231 checkmark->SetImage(gfx::CreateVectorIcon(views::kMenuCheckIcon, 0xFF609265));
anthonyvd 2017/03/01 15:37:00 Can we move the 0xFF609265 color to a constant? (M
tmartino 2017/03/01 20:00:30 Done
232 checkmark->SetVisible(selected);
233 return checkmark;
234 }
235
226 } // namespace payments 236 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698