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

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

Issue 2789093002: [Payments] Desktop: implement shipping address/option change (Closed)
Patch Set: compile fix 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 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 "chrome/grit/chromium_strings.h" 14 #include "chrome/grit/chromium_strings.h"
14 #include "chrome/grit/theme_resources.h" 15 #include "chrome/grit/theme_resources.h"
15 #include "components/autofill/core/browser/autofill_data_util.h" 16 #include "components/autofill/core/browser/autofill_data_util.h"
16 #include "components/autofill/core/browser/autofill_profile.h" 17 #include "components/autofill/core/browser/autofill_profile.h"
17 #include "components/autofill/core/browser/autofill_type.h" 18 #include "components/autofill/core/browser/autofill_type.h"
18 #include "components/autofill/core/browser/credit_card.h" 19 #include "components/autofill/core/browser/credit_card.h"
19 #include "components/autofill/core/browser/field_types.h" 20 #include "components/autofill/core/browser/field_types.h"
20 #include "components/payments/core/payment_options_provider.h" 21 #include "components/payments/core/payment_options_provider.h"
21 #include "components/strings/grit/components_strings.h" 22 #include "components/strings/grit/components_strings.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 layout->set_cross_axis_alignment( 73 layout->set_cross_axis_alignment(
73 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 74 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
74 container->SetLayoutManager(layout.release()); 75 container->SetLayoutManager(layout.release());
75 76
76 if (!s1.empty()) { 77 if (!s1.empty()) {
77 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(s1); 78 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(s1);
78 if (type == AddressStyleType::DETAILED) { 79 if (type == AddressStyleType::DETAILED) {
79 const gfx::FontList& font_list = label->font_list(); 80 const gfx::FontList& font_list = label->font_list();
80 label->SetFontList(font_list.DeriveWithWeight(gfx::Font::Weight::BOLD)); 81 label->SetFontList(font_list.DeriveWithWeight(gfx::Font::Weight::BOLD));
81 } 82 }
83 label->set_id(static_cast<int>(DialogViewID::THREE_LINE_LABEL_LINE_1));
82 container->AddChildView(label.release()); 84 container->AddChildView(label.release());
83 } 85 }
84 86
85 if (!s2.empty()) { 87 if (!s2.empty()) {
86 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(s2); 88 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(s2);
89 label->set_id(static_cast<int>(DialogViewID::THREE_LINE_LABEL_LINE_2));
87 container->AddChildView(label.release()); 90 container->AddChildView(label.release());
88 } 91 }
89 92
90 if (!s3.empty()) { 93 if (!s3.empty()) {
91 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(s3); 94 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(s3);
95 label->set_id(static_cast<int>(DialogViewID::THREE_LINE_LABEL_LINE_3));
92 container->AddChildView(label.release()); 96 container->AddChildView(label.release());
93 } 97 }
94 98
95 // TODO(anthonyvd): add the error label 99 // TODO(anthonyvd): add the error label
96 100
97 return container; 101 return container;
98 } 102 }
99 103
100 // Paints the gray horizontal line that doesn't span the entire width of the 104 // Paints the gray horizontal line that doesn't span the entire width of the
101 // dialog at the bottom of the view it borders. 105 // dialog at the bottom of the view it borders.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 layout->StartRow(0, 0); 159 layout->StartRow(0, 0);
156 if (!show_back_arrow) { 160 if (!show_back_arrow) {
157 layout->SkipColumns(1); 161 layout->SkipColumns(1);
158 } else { 162 } else {
159 views::ImageButton* back_arrow = views::CreateVectorImageButton(listener); 163 views::ImageButton* back_arrow = views::CreateVectorImageButton(listener);
160 views::SetImageFromVectorIcon(back_arrow, ui::kBackArrowIcon); 164 views::SetImageFromVectorIcon(back_arrow, ui::kBackArrowIcon);
161 constexpr int kBackArrowSize = 16; 165 constexpr int kBackArrowSize = 16;
162 back_arrow->SetSize(gfx::Size(kBackArrowSize, kBackArrowSize)); 166 back_arrow->SetSize(gfx::Size(kBackArrowSize, kBackArrowSize));
163 back_arrow->set_tag(static_cast<int>( 167 back_arrow->set_tag(static_cast<int>(
164 PaymentRequestCommonTags::BACK_BUTTON_TAG)); 168 PaymentRequestCommonTags::BACK_BUTTON_TAG));
169 back_arrow->set_id(static_cast<int>(DialogViewID::BACK_BUTTON));
165 layout->AddView(back_arrow); 170 layout->AddView(back_arrow);
166 } 171 }
167 172
168 views::Label* title_label = new views::Label(title); 173 views::Label* title_label = new views::Label(title);
169 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 174 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
170 title_label->SetFontList( 175 title_label->SetFontList(
171 title_label->GetDefaultFontList().DeriveWithSizeDelta(2)); 176 title_label->GetDefaultFontList().DeriveWithSizeDelta(2));
172 layout->AddView(title_label); 177 layout->AddView(title_label);
173 178
174 return container; 179 return container;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 const base::string16& formatted_amount) { 310 const base::string16& formatted_amount) {
306 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); 311 std::unique_ptr<views::View> container = base::MakeUnique<views::View>();
307 312
308 std::unique_ptr<views::BoxLayout> layout = 313 std::unique_ptr<views::BoxLayout> layout =
309 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 0, 0, 0); 314 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 0, 0, 0);
310 layout->set_cross_axis_alignment( 315 layout->set_cross_axis_alignment(
311 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 316 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
312 container->SetLayoutManager(layout.release()); 317 container->SetLayoutManager(layout.release());
313 318
314 if (shipping_option) { 319 if (shipping_option) {
315 container->AddChildView( 320 std::unique_ptr<views::Label> shipping_label =
316 new views::Label(base::ASCIIToUTF16(shipping_option->label))); 321 base::MakeUnique<views::Label>(
317 container->AddChildView(new views::Label(formatted_amount)); 322 base::ASCIIToUTF16(shipping_option->label));
323 shipping_label->set_id(
324 static_cast<int>(DialogViewID::SHIPPING_OPTION_DESCRIPTION));
325 container->AddChildView(shipping_label.release());
326
327 std::unique_ptr<views::Label> amount_label =
328 base::MakeUnique<views::Label>(formatted_amount);
329 amount_label->set_id(
330 static_cast<int>(DialogViewID::SHIPPING_OPTION_AMOUNT));
331 container->AddChildView(amount_label.release());
318 } 332 }
319 333
320 return container; 334 return container;
321 } 335 }
322 336
323 } // namespace payments 337 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698