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

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

Issue 2720223004: Use PaymentRequestItemList for Shipping screen (Closed)
Patch Set: Removing extraneous import 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
15 namespace {
anthonyvd 2017/03/01 20:15:34 nit: anonymous namespace is inside of payments:: i
tmartino 2017/03/01 22:48:14 Done.
16 const SkColor kCheckmarkColor = 0xFF609265;
17 }
18
11 namespace payments { 19 namespace payments {
12 20
13 PaymentRequestItemList::Item::Item(PaymentRequest* request, 21 PaymentRequestItemList::Item::Item(PaymentRequest* request,
14 PaymentRequestItemList* list, 22 PaymentRequestItemList* list,
15 bool selected) 23 bool selected)
16 : request_(request), list_(list), selected_(selected) {} 24 : request_(request), list_(list), selected_(selected) {}
17 25
18 PaymentRequestItemList::Item::~Item() {} 26 PaymentRequestItemList::Item::~Item() {}
19 27
20 views::View* PaymentRequestItemList::Item::GetItemView() { 28 views::View* PaymentRequestItemList::Item::GetItemView() {
21 if (!item_view_) { 29 if (!item_view_) {
22 item_view_ = CreateItemView(); 30 item_view_ = CreateItemView();
23 item_view_->set_owned_by_client(); 31 item_view_->set_owned_by_client();
24 } 32 }
25 33
26 return item_view_.get(); 34 return item_view_.get();
27 } 35 }
28 36
29 void PaymentRequestItemList::Item::SetSelected(bool selected) { 37 void PaymentRequestItemList::Item::SetSelected(bool selected) {
30 selected_ = selected; 38 selected_ = selected;
31 SelectedStateChanged(); 39 SelectedStateChanged();
32 } 40 }
33 41
42 std::unique_ptr<views::ImageView> PaymentRequestItemList::Item::CreateCheckmark(
43 bool selected) {
44 std::unique_ptr<views::ImageView> checkmark =
45 base::MakeUnique<views::ImageView>();
46 checkmark->set_id(static_cast<int>(DialogViewID::CHECKMARK_VIEW));
47 checkmark->set_can_process_events_within_subtree(false);
48 checkmark->SetImage(
49 gfx::CreateVectorIcon(views::kMenuCheckIcon, kCheckmarkColor));
50 checkmark->SetVisible(selected);
51 return checkmark;
52 }
53
34 PaymentRequestItemList::PaymentRequestItemList() : selected_item_(nullptr) {} 54 PaymentRequestItemList::PaymentRequestItemList() : selected_item_(nullptr) {}
35 55
36 PaymentRequestItemList::~PaymentRequestItemList() {} 56 PaymentRequestItemList::~PaymentRequestItemList() {}
37 57
38 void PaymentRequestItemList::AddItem( 58 void PaymentRequestItemList::AddItem(
39 std::unique_ptr<PaymentRequestItemList::Item> item) { 59 std::unique_ptr<PaymentRequestItemList::Item> item) {
40 DCHECK_EQ(this, item->list()); 60 DCHECK_EQ(this, item->list());
41 items_.push_back(std::move(item)); 61 items_.push_back(std::move(item));
42 if (items_.back()->selected()) 62 if (items_.back()->selected())
43 SelectItem(items_.back().get()); 63 SelectItem(items_.back().get());
(...skipping 28 matching lines...) Expand all
72 // It's possible that no item is currently selected, either during list 92 // 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 93 // 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. 94 // selected item has been deselected but the new one isn't selected yet.
75 if (selected_item_) 95 if (selected_item_)
76 selected_item_->SetSelected(false); 96 selected_item_->SetSelected(false);
77 97
78 selected_item_ = nullptr; 98 selected_item_ = nullptr;
79 } 99 }
80 100
81 } // namespace payments 101 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698