diff options
author | ahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-26 04:20:20 +0000 |
---|---|---|
committer | ahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-26 04:20:20 +0000 |
commit | d9e23038d9d133cd0c36872cf601e897494bf40b (patch) | |
tree | 4de38f49de3e6acef3def84c23a15c64a9795648 | |
parent | 152ca7e5280d1aaee5f38181a97c2c9fc0d09105 (diff) | |
download | chromium_src-d9e23038d9d133cd0c36872cf601e897494bf40b.zip chromium_src-d9e23038d9d133cd0c36872cf601e897494bf40b.tar.gz chromium_src-d9e23038d9d133cd0c36872cf601e897494bf40b.tar.bz2 |
Removing LegalDocument body and adding a function to get a url to the document based on its id.
BUG=172124
Review URL: https://chromiumcodereview.appspot.com/12045101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179028 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_items.cc | 26 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_items.h | 11 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_items_unittest.cc | 39 |
3 files changed, 34 insertions, 42 deletions
diff --git a/chrome/browser/autofill/wallet/wallet_items.cc b/chrome/browser/autofill/wallet/wallet_items.cc index f15ce9c..89cea15 100644 --- a/chrome/browser/autofill/wallet/wallet_items.cc +++ b/chrome/browser/autofill/wallet/wallet_items.cc @@ -6,9 +6,13 @@ #include "base/logging.h" #include "base/values.h" +#include "googleurl/src/gurl.h" namespace { +const char kLegalDocumentUrl[] = + "https://wallet.google.com/customer/gadget/legaldocument.html?docId="; + wallet::WalletItems::MaskedInstrument::Type TypeFromString(const std::string& type_string) { if (type_string == "VISA") @@ -199,11 +203,9 @@ bool WalletItems::MaskedInstrument::operator!=( } WalletItems::LegalDocument::LegalDocument(const std::string& document_id, - const std::string& display_name, - const std::string& document_body) + const std::string& display_name) : document_id_(document_id), - display_name_(display_name), - document_body_(document_body) {} + display_name_(display_name) {} WalletItems::LegalDocument::~LegalDocument() {} @@ -222,21 +224,17 @@ scoped_ptr<WalletItems::LegalDocument> return scoped_ptr<LegalDocument>(); } - std::string document_body; - if (!dictionary.GetString("document", &document_body)) { - DLOG(ERROR) << "Response from Google Wallet missing document body"; - return scoped_ptr<LegalDocument>(); - } - return scoped_ptr<LegalDocument>(new LegalDocument(document_id, - display_name, - document_body)); + display_name)); +} + +GURL WalletItems::LegalDocument::GetUrl() { + return GURL(kLegalDocumentUrl + document_id_); } bool WalletItems::LegalDocument::operator==(const LegalDocument& other) const { return document_id_ == other.document_id_ && - display_name_ == other.display_name_ && - document_body_ == other.document_body_; + display_name_ == other.display_name_; } bool WalletItems::LegalDocument::operator!=(const LegalDocument& other) const { diff --git a/chrome/browser/autofill/wallet/wallet_items.h b/chrome/browser/autofill/wallet/wallet_items.h index e1f0601..ffc55a5 100644 --- a/chrome/browser/autofill/wallet/wallet_items.h +++ b/chrome/browser/autofill/wallet/wallet_items.h @@ -16,6 +16,8 @@ #include "chrome/browser/autofill/wallet/required_action.h" #include "chrome/browser/autofill/wallet/wallet_address.h" +class GURL; + namespace base { class DictionaryValue; } @@ -116,23 +118,24 @@ class WalletItems { static scoped_ptr<LegalDocument> CreateLegalDocument(const base::DictionaryValue& dictionary); + // Get the url where this legal document is hosted. + GURL GetUrl(); + bool operator==(const LegalDocument& other) const; bool operator!=(const LegalDocument& other) const; const std::string& document_id() const { return document_id_; } const std::string& display_name() const { return display_name_; } - const std::string& document_body() const { return document_body_; } private: friend class WalletItemsTest; FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, CreateLegalDocument); FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, CreateWalletItems); + FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, LegalDocumentGetUrl); LegalDocument(const std::string& document_id, - const std::string& display_name, - const std::string& document_body); + const std::string& display_name); std::string document_id_; std::string display_name_; - std::string document_body_; DISALLOW_COPY_AND_ASSIGN(LegalDocument); }; diff --git a/chrome/browser/autofill/wallet/wallet_items_unittest.cc b/chrome/browser/autofill/wallet/wallet_items_unittest.cc index ab202f1..cf2496c 100644 --- a/chrome/browser/autofill/wallet/wallet_items_unittest.cc +++ b/chrome/browser/autofill/wallet/wallet_items_unittest.cc @@ -8,6 +8,7 @@ #include "base/values.h" #include "chrome/browser/autofill/wallet/required_action.h" #include "chrome/browser/autofill/wallet/wallet_items.h" +#include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -187,26 +188,17 @@ const char kMaskedInstrumentMissingObjectId[] = const char kLegalDocument[] = "{" " \"legal_document_id\":\"doc_id\"," - " \"display_name\":\"display_name\"," - " \"document\":\"doc_body\"" + " \"display_name\":\"display_name\"" "}"; const char kLegalDocumentMissingDocumentId[] = "{" - " \"display_name\":\"display_name\"," - " \"document\":\"doc_body\"" + " \"display_name\":\"display_name\"" "}"; const char kLegalDocumentMissingDisplayName[] = "{" - " \"legal_document_id\":\"doc_id\"," - " \"document\":\"doc_body\"" - "}"; - -const char kLegalDocumentMissingDocumentBody[] = - "{" - " \"legal_document_id\":\"doc_id\"," - " \"display_name\":\"display_name\"" + " \"legal_document_id\":\"doc_id\"" "}"; const char kWalletItemsWithRequiredActions[] = @@ -291,8 +283,7 @@ const char kWalletItemsMissingGoogleTransactionId[] = " [" " {" " \"legal_document_id\":\"doc_id\"," - " \"display_name\":\"display_name\"," - " \"document\":\"doc_body\"" + " \"display_name\":\"display_name\"" " }" " ]" "}"; @@ -355,8 +346,7 @@ const char kWalletItems[] = " [" " {" " \"legal_document_id\":\"doc_id\"," - " \"display_name\":\"display_name\"," - " \"document\":\"doc_body\"" + " \"display_name\":\"display_name\"" " }" " ]" "}"; @@ -452,18 +442,20 @@ TEST_F(WalletItemsTest, CreateLegalDocumentMissingDisplayName) { ASSERT_EQ(NULL, WalletItems::LegalDocument::CreateLegalDocument(*dict).get()); } -TEST_F(WalletItemsTest, CreateLegalDocumentMissingDocBody) { - SetUpDictionary(kLegalDocumentMissingDocumentBody); - ASSERT_EQ(NULL, WalletItems::LegalDocument::CreateLegalDocument(*dict).get()); -} - TEST_F(WalletItemsTest, CreateLegalDocument) { SetUpDictionary(kLegalDocument); - WalletItems::LegalDocument expected("doc_id", "display_name", "doc_body"); + WalletItems::LegalDocument expected("doc_id", "display_name"); ASSERT_EQ(expected, *WalletItems::LegalDocument::CreateLegalDocument(*dict)); } +TEST_F(WalletItemsTest, LegalDocumentGetUrl) { + WalletItems::LegalDocument legal_doc("doc_id", "display_name"); + EXPECT_EQ("https://wallet.google.com/customer/gadget/legaldocument.html?" + "docId=doc_id", + legal_doc.GetUrl().spec()); +} + TEST_F(WalletItemsTest, CreateWalletItemsWithRequiredActions) { SetUpDictionary(kWalletItemsWithRequiredActions); @@ -547,8 +539,7 @@ TEST_F(WalletItemsTest, CreateWalletItems) { scoped_ptr<WalletItems::LegalDocument> legal_document( new WalletItems::LegalDocument("doc_id", - "display_name", - "doc_body")); + "display_name")); expected.AddLegalDocument(legal_document.Pass()); ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict)); |