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

Unified Diff: chrome/browser/autofill/wallet/wallet_address.cc

Issue 11293078: Integrating Online Wallet into Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes from latest code review Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/wallet/wallet_address.cc
diff --git a/chrome/browser/autofill/wallet/wallet_address.cc b/chrome/browser/autofill/wallet/wallet_address.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e7a28a56fc1321db3ba09790c94c611c9e803873
--- /dev/null
+++ b/chrome/browser/autofill/wallet/wallet_address.cc
@@ -0,0 +1,170 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autofill/wallet/wallet_address.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+
+namespace wallet {
+
+Address::Address() {}
+
+Address::Address(const std::string& country_name_code,
+ const std::string& recipient_name,
+ const std::string& address_line_1,
+ const std::string& address_line_2,
+ const std::string& locality_name,
+ const std::string& administrative_area_name,
+ const std::string& postal_code_number,
+ const std::string& phone_number,
+ const std::string& object_id)
+ : country_name_code_(country_name_code),
+ recipient_name_(recipient_name),
+ address_line_1_(address_line_1),
+ address_line_2_(address_line_2),
+ locality_name_(locality_name),
+ administrative_area_name_(administrative_area_name),
+ postal_code_number_(postal_code_number),
+ phone_number_(phone_number),
+ object_id_(object_id) {}
+
+Address::~Address() {}
+
+Address* Address::CreateAddressWithID(const base::DictionaryValue& dictionary) {
+ std::string object_id;
+ if (!dictionary.GetString("id", &object_id)) {
+ DLOG(ERROR) << "Response from Google Wallet missing object id";
+ return NULL;
+ }
+
+ std::string phone_number;
+ if (!dictionary.GetString("phone_number", &phone_number))
+ DVLOG(1) << "Response from Google Wallet missing phone number";
+
+ std::string country_name_code;
+ if (!dictionary.GetString("postal_address.country_name_code",
+ &country_name_code)) {
+ DLOG(ERROR) << "Response from Google Wallet missing country name";
+ return NULL;
+ }
+
+ std::string recipient_name;
+ if (!dictionary.GetString("postal_address.recipient_name",
+ &recipient_name)) {
+ DLOG(ERROR) << "Response from Google Wallet recipient name";
+ return NULL;
+ }
+
+ std::string address_line_1;
+ std::string address_line_2;
+ const ListValue* address_line_list;
+ if (dictionary.GetList("postal_address.address_line", &address_line_list)) {
+ if (!address_line_list->GetString(0, &address_line_1))
+ DVLOG(1) << "Response from Google Wallet missing address line 1";
+ if (!address_line_list->GetString(1, &address_line_2))
+ DVLOG(1) << "Response from Google Wallet missing address line 2";
+ } else {
+ DVLOG(1) << "Response from Google Wallet missing address lines";
+ }
+
+ std::string locality_name;
+ if (!dictionary.GetString("postal_address.locality_name",
+ &locality_name)) {
+ DVLOG(1) << "Response from Google Wallet missing locality name";
+ }
+
+ std::string administrative_area_name;
+ if (!dictionary.GetString("postal_address.administrative_area_name",
+ &administrative_area_name)) {
+ DVLOG(1) << "Response from Google Wallet missing administrative area name";
+ }
+
+ std::string postal_code_number;
+ if (!dictionary.GetString("postal_address.postal_code_number",
+ &postal_code_number)) {
+ DLOG(ERROR) << "Response from Google Wallet missing postal code number";
+ return NULL;
+ }
+
+ return new Address(country_name_code,
+ recipient_name ,
+ address_line_1,
+ address_line_2,
+ locality_name,
+ administrative_area_name,
+ postal_code_number,
+ phone_number,
+ object_id);
+}
+
+
+Address* Address::CreateDisplayAddress(
+ const base::DictionaryValue& dictionary) {
+ std::string country_code;
+ if (!dictionary.GetString("country_code", &country_code)) {
+ DLOG(ERROR) << "Reponse from Google Wallet missing country code";
+ return NULL;
+ }
+
+ std::string name;
+ if (!dictionary.GetString("name", &name)) {
+ DLOG(ERROR) << "Reponse from Google Wallet missing name";
+ return NULL;
+ }
+
+ std::string address1;
+ if (!dictionary.GetString("address1", &address1))
+ DVLOG(1) << "Reponse from Google Wallet missing address1";
+
+ std::string address2;
+ if (!dictionary.GetString("address2", &address2))
+ DVLOG(1) << "Reponse from Google Wallet missing address2";
+
+ std::string city;
+ if (!dictionary.GetString("city", &city))
+ DVLOG(1) << "Reponse from Google Wallet missing city";
+
+ std::string state;
+ if (!dictionary.GetString("state", &state))
+ DVLOG(1) << "Reponse from Google Wallet missing state";
+
+ std::string postal_code;
+ if (!dictionary.GetString("postal_code", &postal_code)) {
+ DLOG(ERROR) << "Reponse from Google Wallet missing postal code";
+ return NULL;
+ }
+
+ std::string phone_number;
+ if (!dictionary.GetString("phone_number", &phone_number))
+ DVLOG(1) << "Reponse from Google Wallet missing phone number";
+
+ return new Address(country_code,
+ name,
+ address1,
+ address2,
+ city,
+ state,
+ postal_code,
+ phone_number,
+ "");
+}
+
+bool Address::operator==(const Address& other) const {
+ return country_name_code_ == other.country_name_code_ &&
+ recipient_name_ == other.recipient_name_ &&
Albert Bodenhamer 2012/12/06 00:36:43 nit: 4 space indent.
Dan Beam 2012/12/06 00:52:07 I thought ASCII ident prevailed in Chrome? see ne
+ address_line_1_ == other.address_line_1_ &&
+ address_line_2_ == other.address_line_2_ &&
+ locality_name_ == other.locality_name_ &&
+ administrative_area_name_ == other.administrative_area_name_ &&
+ postal_code_number_ == other.postal_code_number_ &&
+ phone_number_ == other.phone_number_ &&
+ object_id_ == other.object_id_;
+}
+
+bool Address::operator!=(const Address& other) const {
+ return !(*this == other);
+}
+
+} // end wallet namespace

Powered by Google App Engine
This is Rietveld 408576698