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

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: Changes from Dane's review Created 8 years, 1 month 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..f30ae48b8d1aa5cf79b22ca130861678c5d5f7bf
--- /dev/null
+++ b/chrome/browser/autofill/wallet/wallet_address.cc
@@ -0,0 +1,173 @@
+// 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::CreateFromIdedDictionary(
+ base::DictionaryValue* dictionary) {
+ DCHECK(dictionary);
+
+ std::string object_id;
+ if (!dictionary->GetString("id", &object_id)) {
+ LOG(ERROR) << "Response from Google Wallet missing object id";
+ return NULL;
+ }
+ std::string phone_number;
+ if (!dictionary->GetString("phone_number", &phone_number)) {
+ VLOG(1) << "Response from Google Wallet missing phone number";
+ }
+ std::string country_name_code;
+ if (!dictionary->GetString("postal_address.country_name_code",
+ &country_name_code)) {
Raman Kakilate 2012/11/17 02:28:31 Indentation not correct. here and below.
ahutter 2012/11/27 00:46:12 Done.
+ LOG(ERROR) << "Response from Google Wallet missing country name";
+ return NULL;
+ }
+ std::string recipient_name;
+ if (!dictionary->GetString("postal_address.recipient_name",
+ &recipient_name)) {
+ LOG(ERROR) << "Response from Google Wallet recipient name";
+ return NULL;
+ }
+ std::string address_line_1;
+ std::string address_line_2;
+ ListValue* address_line_list;
+ if (dictionary->GetList("postal_address.address_line", &address_line_list)) {
+ if (!address_line_list->GetString(0, &address_line_1))
+ VLOG(1) << "Response from Google Wallet missing address line 1";
+ if (!address_line_list->GetString(1, &address_line_2))
+ VLOG(1) << "Response from Google Wallet missing address line 2";
+ } else {
+ VLOG(1) << "Response from Google Wallet missing address lines";
+ }
+ std::string locality_name;
+ if (!dictionary->GetString("postal_address.locality_name",
+ &locality_name)) {
+ VLOG(1) << "Response from Google Wallet missing locality name";
+ }
+ std::string administrative_area_name;
+ if (!dictionary->GetString("postal_address.administrative_area_name",
+ &administrative_area_name)) {
+ VLOG(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)) {
+ LOG(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::CreateFromDisplayDictionary(
Raman Kakilate 2012/11/17 02:28:31 I couldn't understand difference between DisplayDi
ahutter 2012/11/27 00:46:12 Done.
+ base::DictionaryValue* dictionary) {
+ DCHECK(dictionary);
+ std::string country_code;
+
+ if (!dictionary->GetString("country_code", &country_code)) {
+ LOG(ERROR) << "Reponse from Google Wallet missing country code";
+ return NULL;
+ }
+ std::string name;
+ if (!dictionary->GetString("name", &name)) {
+ LOG(ERROR) << "Reponse from Google Wallet missing name";
+ return NULL;
+ }
+ std::string address1;
+ if (!dictionary->GetString("address1", &address1))
+ VLOG(1) << "Reponse from Google Wallet missing address1";
+ std::string address2;
+ if (!dictionary->GetString("address2", &address2))
+ VLOG(1) << "Reponse from Google Wallet missing address2";
+ std::string city;
+ if (!dictionary->GetString("city", &city))
+ VLOG(1) << "Reponse from Google Wallet missing city";
+ std::string state;
+ if (!dictionary->GetString("state", &state))
+ VLOG(1) << "Reponse from Google Wallet missing state";
+ std::string postal_code;
+ if (!dictionary->GetString("postal_code", &postal_code)) {
+ LOG(ERROR) << "Reponse from Google Wallet missing postal code";
+ return NULL;
+ }
+ std::string phone_number;
+ if (!dictionary->GetString("phone_number", &phone_number))
+ VLOG(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 {
+ if (country_name_code_.compare(other.country_name_code_) != 0)
+ return false;
+ if (recipient_name_.compare(other.recipient_name_) != 0)
+ return false;
+ if (address_line_1_.compare(other.address_line_1_) != 0)
+ return false;
+ if (address_line_2_.compare(other.address_line_2_) != 0)
+ return false;
+ if (locality_name_.compare(other.locality_name_) != 0)
+ return false;
+ if (administrative_area_name_.compare(other.administrative_area_name_) != 0)
+ return false;
+ if (postal_code_number_ != other.postal_code_number_)
+ return false;
+ if (phone_number_.compare(other.phone_number_) != 0)
+ return false;
+ if (object_id_.compare(other.object_id_) != 0)
+ return false;
+ return true;
+}
+
+bool Address::operator!=(const Address& other) const {
+ return !(*this == other);
+}
+
+
+} // end wallet namespace

Powered by Google App Engine
This is Rietveld 408576698