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

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

Issue 2720223004: Use PaymentRequestItemList for Shipping screen (Closed)
Patch Set: rebase 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 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_item_list.h" 5 #include "chrome/browser/ui/views/payments/payment_request_item_list.h"
6 6
7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
7 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
9 #include "ui/gfx/paint_vector_icon.h"
10 #include "ui/views/controls/image_view.h"
8 #include "ui/views/layout/box_layout.h" 11 #include "ui/views/layout/box_layout.h"
12 #include "ui/views/vector_icons.h"
9 #include "ui/views/view.h" 13 #include "ui/views/view.h"
10 14
11 namespace payments { 15 namespace payments {
12 16
17 namespace {
18
19 const SkColor kCheckmarkColor = 0xFF609265;
20
21 } // namespace
22
13 PaymentRequestItemList::Item::Item(PaymentRequest* request, 23 PaymentRequestItemList::Item::Item(PaymentRequest* request,
14 PaymentRequestItemList* list, 24 PaymentRequestItemList* list,
15 bool selected) 25 bool selected)
16 : request_(request), list_(list), selected_(selected) {} 26 : request_(request), list_(list), selected_(selected) {}
17 27
18 PaymentRequestItemList::Item::~Item() {} 28 PaymentRequestItemList::Item::~Item() {}
19 29
20 views::View* PaymentRequestItemList::Item::GetItemView() { 30 views::View* PaymentRequestItemList::Item::GetItemView() {
21 if (!item_view_) { 31 if (!item_view_) {
22 item_view_ = CreateItemView(); 32 item_view_ = CreateItemView();
23 item_view_->set_owned_by_client(); 33 item_view_->set_owned_by_client();
24 } 34 }
25 35
26 return item_view_.get(); 36 return item_view_.get();
27 } 37 }
28 38
29 void PaymentRequestItemList::Item::SetSelected(bool selected) { 39 void PaymentRequestItemList::Item::SetSelected(bool selected) {
30 selected_ = selected; 40 selected_ = selected;
31 SelectedStateChanged(); 41 SelectedStateChanged();
32 } 42 }
33 43
44 std::unique_ptr<views::ImageView> PaymentRequestItemList::Item::CreateCheckmark(
45 bool selected) {
46 std::unique_ptr<views::ImageView> checkmark =
47 base::MakeUnique<views::ImageView>();
48 checkmark->set_id(static_cast<int>(DialogViewID::CHECKMARK_VIEW));
49 checkmark->set_can_process_events_within_subtree(false);
50 checkmark->SetImage(
51 gfx::CreateVectorIcon(views::kMenuCheckIcon, kCheckmarkColor));
52 checkmark->SetVisible(selected);
53 return checkmark;
54 }
55
34 PaymentRequestItemList::PaymentRequestItemList() : selected_item_(nullptr) {} 56 PaymentRequestItemList::PaymentRequestItemList() : selected_item_(nullptr) {}
35 57
36 PaymentRequestItemList::~PaymentRequestItemList() {} 58 PaymentRequestItemList::~PaymentRequestItemList() {}
37 59
38 void PaymentRequestItemList::AddItem( 60 void PaymentRequestItemList::AddItem(
39 std::unique_ptr<PaymentRequestItemList::Item> item) { 61 std::unique_ptr<PaymentRequestItemList::Item> item) {
40 DCHECK_EQ(this, item->list()); 62 DCHECK_EQ(this, item->list());
41 items_.push_back(std::move(item)); 63 items_.push_back(std::move(item));
42 if (items_.back()->selected()) 64 if (items_.back()->selected())
43 SelectItem(items_.back().get()); 65 SelectItem(items_.back().get());
(...skipping 28 matching lines...) Expand all
72 // It's possible that no item is currently selected, either during list 94 // It's possible that no item is currently selected, either during list
73 // creation or in the middle of the selection operation when the previously 95 // creation or in the middle of the selection operation when the previously
74 // selected item has been deselected but the new one isn't selected yet. 96 // selected item has been deselected but the new one isn't selected yet.
75 if (selected_item_) 97 if (selected_item_)
76 selected_item_->SetSelected(false); 98 selected_item_->SetSelected(false);
77 99
78 selected_item_ = nullptr; 100 selected_item_ = nullptr;
79 } 101 }
80 102
81 } // namespace payments 103 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698