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

Side by Side Diff: chrome/browser/autofill/wallet/wallet_items.cc

Issue 11777007: Adds wallet::RequiredAction for when we start interacting with Online Wallet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ahutter@ review Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/autofill/wallet/wallet_items.h" 5 #include "chrome/browser/autofill/wallet/wallet_items.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 9
10 namespace { 10 namespace {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 bool WalletItems::LegalDocument::operator==(const LegalDocument& other) const { 236 bool WalletItems::LegalDocument::operator==(const LegalDocument& other) const {
237 return document_id_ == other.document_id_ && 237 return document_id_ == other.document_id_ &&
238 display_name_ == other.display_name_ && 238 display_name_ == other.display_name_ &&
239 document_body_ == other.document_body_; 239 document_body_ == other.document_body_;
240 } 240 }
241 241
242 bool WalletItems::LegalDocument::operator!=(const LegalDocument& other) const { 242 bool WalletItems::LegalDocument::operator!=(const LegalDocument& other) const {
243 return !(*this == other); 243 return !(*this == other);
244 } 244 }
245 245
246 WalletItems::WalletItems(const std::vector<std::string>& required_actions, 246 WalletItems::WalletItems(const std::vector<RequiredAction>& required_actions,
247 const std::string& google_transaction_id, 247 const std::string& google_transaction_id,
248 const std::string& default_instrument_id, 248 const std::string& default_instrument_id,
249 const std::string& default_address_id) 249 const std::string& default_address_id)
250 : required_actions_(required_actions), 250 : required_actions_(required_actions),
251 google_transaction_id_(google_transaction_id), 251 google_transaction_id_(google_transaction_id),
252 default_instrument_id_(default_instrument_id), 252 default_instrument_id_(default_instrument_id),
253 default_address_id_(default_address_id) {} 253 default_address_id_(default_address_id) {}
254 254
255 WalletItems::~WalletItems() {} 255 WalletItems::~WalletItems() {}
256 256
257 scoped_ptr<WalletItems> 257 scoped_ptr<WalletItems>
258 WalletItems::CreateWalletItems(const base::DictionaryValue& dictionary) { 258 WalletItems::CreateWalletItems(const base::DictionaryValue& dictionary) {
259 std::string google_transaction_id; 259 std::string google_transaction_id;
260 if (!dictionary.GetString("google_transaction_id", &google_transaction_id)) { 260 if (!dictionary.GetString("google_transaction_id", &google_transaction_id)) {
261 DLOG(ERROR) << "Response from Google wallet missing google transaction id"; 261 DLOG(ERROR) << "Response from Google wallet missing google transaction id";
262 return scoped_ptr<WalletItems>(); 262 return scoped_ptr<WalletItems>();
263 } 263 }
264 264
265 std::vector<std::string> required_action; 265 std::vector<RequiredAction> required_action;
266 const ListValue* required_action_list; 266 const ListValue* required_action_list;
267 if (dictionary.GetList("required_action", &required_action_list)) { 267 if (dictionary.GetList("required_action", &required_action_list)) {
268 for (size_t i = 0; i < required_action_list->GetSize(); ++i) { 268 for (size_t i = 0; i < required_action_list->GetSize(); ++i) {
269 std::string action; 269 std::string action_string;
270 if (required_action_list->GetString(i, &action)) 270 if (required_action_list->GetString(i, &action_string)) {
271 RequiredAction action = ParseRequiredActionFromString(action_string);
272 if (!ActionAppliesToWalletItems(action)) {
273 DLOG(ERROR) << "Response from Google wallet with bad required action:"
274 " \"" << action_string << "\"";
275 return scoped_ptr<WalletItems>();
276 }
271 required_action.push_back(action); 277 required_action.push_back(action);
278 }
272 } 279 }
273 } else { 280 } else {
274 DVLOG(1) << "Response from Google wallet missing required actions"; 281 DVLOG(1) << "Response from Google wallet missing required actions";
275 } 282 }
276 283
277 std::string default_instrument_id; 284 std::string default_instrument_id;
278 if (!dictionary.GetString("default_instrument_id", &default_instrument_id)) 285 if (!dictionary.GetString("default_instrument_id", &default_instrument_id))
279 DVLOG(1) << "Response from Google wallet missing default instrument id"; 286 DVLOG(1) << "Response from Google wallet missing default instrument id";
280 287
281 std::string default_address_id; 288 std::string default_address_id;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 349 }
343 350
344 return wallet_items.Pass(); 351 return wallet_items.Pass();
345 } 352 }
346 353
347 bool WalletItems::operator==(const WalletItems& other) const { 354 bool WalletItems::operator==(const WalletItems& other) const {
348 // TODO(ahutter): Check scoped vector equality. 355 // TODO(ahutter): Check scoped vector equality.
349 return google_transaction_id_ == other.google_transaction_id_ && 356 return google_transaction_id_ == other.google_transaction_id_ &&
350 default_instrument_id_ == other.default_instrument_id_ && 357 default_instrument_id_ == other.default_instrument_id_ &&
351 default_address_id_ == other.default_address_id_ && 358 default_address_id_ == other.default_address_id_ &&
352 required_actions_ == required_actions_; 359 required_actions_ == other.required_actions_;
353 } 360 }
354 361
355 bool WalletItems::operator!=(const WalletItems& other) const { 362 bool WalletItems::operator!=(const WalletItems& other) const {
356 return !(*this == other); 363 return !(*this == other);
357 } 364 }
358 365
359 } // namespace wallet 366 } // namespace wallet
360 367
OLDNEW
« no previous file with comments | « chrome/browser/autofill/wallet/wallet_items.h ('k') | chrome/browser/autofill/wallet/wallet_items_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698