1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
|
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PAYMENTS_CONTENT_SECURE_PAYMENT_CONFIRMATION_MODEL_H_
#define COMPONENTS_PAYMENTS_CONTENT_SECURE_PAYMENT_CONFIRMATION_MODEL_H_
#include <optional>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace payments {
// The data model for the secure payment confirmation flow. Owned by the
// SecurePaymentConfirmationController.
class SecurePaymentConfirmationModel {
public:
SecurePaymentConfirmationModel();
~SecurePaymentConfirmationModel();
// Disallow copy and assign.
SecurePaymentConfirmationModel(const SecurePaymentConfirmationModel& other) =
delete;
SecurePaymentConfirmationModel& operator=(
const SecurePaymentConfirmationModel& other) = delete;
// Title, e.g. "Use TouchID to verify and complete your purchase?"
const std::u16string& title() const { return title_; }
void set_title(const std::u16string& title) { title_ = title; }
// Descriptive text that goes under the title.
const std::u16string& description() const { return description_; }
void set_description(const std::u16string& description) {
description_ = description;
}
// Label for the merchant row, e.g. "Store".
const std::u16string& merchant_label() const { return merchant_label_; }
void set_merchant_label(const std::u16string& merchant_label) {
merchant_label_ = merchant_label;
}
// Label for the merchant name, e.g. "Merchant"
const std::optional<std::u16string>& merchant_name() const {
return merchant_name_;
}
void set_merchant_name(const std::optional<std::u16string>& merchant_name) {
merchant_name_ = merchant_name;
}
// Label for the merchant origin, e.g. "merchant.com"
const std::optional<std::u16string>& merchant_origin() const {
return merchant_origin_;
}
void set_merchant_origin(
const std::optional<std::u16string>& merchant_origin) {
merchant_origin_ = merchant_origin;
}
// Label for the instrument row, e.g. "Payment".
const std::u16string& instrument_label() const { return instrument_label_; }
void set_instrument_label(const std::u16string& instrument_label) {
instrument_label_ = instrument_label;
}
// Label for the instrument row value, e.g. "****4444"
const std::u16string& instrument_value() const { return instrument_value_; }
void set_instrument_value(const std::u16string& instrument_value) {
instrument_value_ = instrument_value;
}
// Instrument icon.
const SkBitmap* instrument_icon() const { return instrument_icon_; }
void set_instrument_icon(const SkBitmap* instrument_icon) {
instrument_icon_ = instrument_icon;
}
// Label for the network row, e.g. "Network".
const std::u16string& network_label() const { return network_label_; }
void set_network_label(const std::u16string& network_label) {
network_label_ = network_label;
}
// Label for the network row value, e.g. "Mastercard"
const std::u16string& network_value() const { return network_value_; }
void set_network_value(const std::u16string& network_value) {
network_value_ = network_value;
}
// Network icon.
const SkBitmap* network_icon() const { return network_icon_; }
void set_network_icon(const SkBitmap* network_icon) {
network_icon_ = network_icon;
}
// Label for the issuer row, e.g. "Issuer".
const std::u16string& issuer_label() const { return issuer_label_; }
void set_issuer_label(const std::u16string& issuer_label) {
issuer_label_ = issuer_label;
}
// Label for the issuer row value, e.g. "CitiBank"
const std::u16string& issuer_value() const { return issuer_value_; }
void set_issuer_value(const std::u16string& issuer_value) {
issuer_value_ = issuer_value;
}
// Issuer icon.
const SkBitmap* issuer_icon() const { return issuer_icon_; }
void set_issuer_icon(const SkBitmap* issuer_icon) {
issuer_icon_ = issuer_icon;
}
// Label for the total row, e.g. "Total".
const std::u16string& total_label() const { return total_label_; }
void set_total_label(const std::u16string& total_label) {
total_label_ = total_label;
}
// Label for the total row value, e.g. "$20.00 USD"
const std::u16string& total_value() const { return total_value_; }
void set_total_value(const std::u16string& total_value) {
total_value_ = total_value;
}
// Label for the verify button, e.g. "Verify".
const std::u16string& verify_button_label() const {
return verify_button_label_;
}
void set_verify_button_label(const std::u16string& verify_button_label) {
verify_button_label_ = verify_button_label;
}
// Label for the cancel button, e.g. "Cancel".
const std::u16string& cancel_button_label() const {
return cancel_button_label_;
}
void set_cancel_button_label(const std::u16string& cancel_button_label) {
cancel_button_label_ = cancel_button_label;
}
// Progress bar visibility.
bool progress_bar_visible() const { return progress_bar_visible_; }
void set_progress_bar_visible(bool progress_bar_visible) {
progress_bar_visible_ = progress_bar_visible;
}
// Verify button enabled state.
bool verify_button_enabled() const { return verify_button_enabled_; }
void set_verify_button_enabled(bool verify_button_enabled) {
verify_button_enabled_ = verify_button_enabled;
}
// Verify button visibility.
bool verify_button_visible() const { return verify_button_visible_; }
void set_verify_button_visible(bool verify_button_visible) {
verify_button_visible_ = verify_button_visible;
}
// Cancel button enabled state.
bool cancel_button_enabled() const { return cancel_button_enabled_; }
void set_cancel_button_enabled(bool cancel_button_enabled) {
cancel_button_enabled_ = cancel_button_enabled;
}
// Cancel button visibility.
bool cancel_button_visible() const { return cancel_button_visible_; }
void set_cancel_button_visible(bool cancel_button_visible) {
cancel_button_visible_ = cancel_button_visible;
}
// Opt Out text visibility and label.
bool opt_out_visible() const { return opt_out_visible_; }
void set_opt_out_visible(const bool opt_out_visible) {
opt_out_visible_ = opt_out_visible;
}
const std::u16string& opt_out_label() const { return opt_out_label_; }
void set_opt_out_label(const std::u16string& opt_out_label) {
opt_out_label_ = opt_out_label;
}
const std::u16string& opt_out_link_label() const {
return opt_out_link_label_;
}
void set_opt_out_link_label(const std::u16string& opt_out_link_label) {
opt_out_link_label_ = opt_out_link_label;
}
bool opt_out_clicked() const { return opt_out_clicked_; }
void set_opt_out_clicked(const bool opt_out_clicked) {
opt_out_clicked_ = opt_out_clicked;
}
// Relying Party id (origin); used in the opt out dialog.
const std::u16string& relying_party_id() const { return relying_party_id_; }
void set_relying_party_id(const std::u16string& relying_party_id) {
relying_party_id_ = relying_party_id;
}
base::WeakPtr<SecurePaymentConfirmationModel> GetWeakPtr();
private:
std::u16string title_;
std::u16string description_;
std::u16string merchant_label_;
std::optional<std::u16string> merchant_name_;
std::optional<std::u16string> merchant_origin_;
std::u16string instrument_label_;
std::u16string instrument_value_;
raw_ptr<const SkBitmap> instrument_icon_ = nullptr;
std::u16string network_label_;
std::u16string network_value_;
raw_ptr<const SkBitmap> network_icon_ = nullptr;
std::u16string issuer_label_;
std::u16string issuer_value_;
raw_ptr<const SkBitmap> issuer_icon_ = nullptr;
std::u16string total_label_;
std::u16string total_value_;
std::u16string verify_button_label_;
std::u16string cancel_button_label_;
bool progress_bar_visible_ = false;
bool verify_button_enabled_ = true;
bool verify_button_visible_ = true;
bool cancel_button_enabled_ = true;
bool cancel_button_visible_ = true;
bool opt_out_visible_ = false;
std::u16string opt_out_label_;
std::u16string opt_out_link_label_;
bool opt_out_clicked_ = false;
std::u16string relying_party_id_;
base::WeakPtrFactory<SecurePaymentConfirmationModel> weak_ptr_factory_{this};
};
} // namespace payments
#endif // COMPONENTS_PAYMENTS_CONTENT_SECURE_PAYMENT_CONFIRMATION_MODEL_H_
|