| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/autofill/content/browser/wallet/gaia_account.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/values.h" | |
| 9 | |
| 10 namespace autofill { | |
| 11 | |
| 12 namespace wallet { | |
| 13 | |
| 14 GaiaAccount::~GaiaAccount() {} | |
| 15 | |
| 16 // static | |
| 17 scoped_ptr<GaiaAccount> GaiaAccount::Create( | |
| 18 const base::DictionaryValue& dictionary) { | |
| 19 std::string email_address; | |
| 20 if (!dictionary.GetString("buyer_email", &email_address)) { | |
| 21 DLOG(ERROR) << "GAIA account: missing email address"; | |
| 22 return scoped_ptr<GaiaAccount>(); | |
| 23 } | |
| 24 | |
| 25 std::string obfuscated_id; | |
| 26 if (!dictionary.GetString("gaia_id", &obfuscated_id)) { | |
| 27 DLOG(ERROR) << "GAIA account: missing GAIA id"; | |
| 28 return scoped_ptr<GaiaAccount>(); | |
| 29 } | |
| 30 | |
| 31 int index = 0; | |
| 32 if (!dictionary.GetInteger("gaia_index", &index) || | |
| 33 index < 0) { | |
| 34 DLOG(ERROR) << "GAIA account: missing or bad GAIA index"; | |
| 35 return scoped_ptr<GaiaAccount>(); | |
| 36 } | |
| 37 | |
| 38 bool is_active = false; | |
| 39 if (!dictionary.GetBoolean("is_active", &is_active)) { | |
| 40 DLOG(ERROR) << "GAIA account: missing is_active"; | |
| 41 return scoped_ptr<GaiaAccount>(); | |
| 42 } | |
| 43 | |
| 44 return scoped_ptr<GaiaAccount>(new GaiaAccount(email_address, | |
| 45 obfuscated_id, | |
| 46 index, | |
| 47 is_active)); | |
| 48 } | |
| 49 | |
| 50 // static | |
| 51 scoped_ptr<GaiaAccount> GaiaAccount::CreateForTesting( | |
| 52 const std::string& email_address, | |
| 53 const std::string& obfuscated_id, | |
| 54 size_t index, | |
| 55 bool is_active) { | |
| 56 scoped_ptr<GaiaAccount> account(new GaiaAccount(email_address, | |
| 57 obfuscated_id, | |
| 58 index, | |
| 59 is_active)); | |
| 60 return account.Pass(); | |
| 61 } | |
| 62 | |
| 63 bool GaiaAccount::operator==(const GaiaAccount& other) const { | |
| 64 return email_address_ == other.email_address_ && | |
| 65 obfuscated_id_ == other.obfuscated_id_ && | |
| 66 index_ == other.index_ && | |
| 67 is_active_ == other.is_active_; | |
| 68 } | |
| 69 | |
| 70 bool GaiaAccount::operator!=(const GaiaAccount& other) const { | |
| 71 return !(*this == other); | |
| 72 } | |
| 73 | |
| 74 GaiaAccount::GaiaAccount(const std::string& email_address, | |
| 75 const std::string& obfuscated_id, | |
| 76 size_t index, | |
| 77 bool is_active) | |
| 78 : email_address_(email_address), | |
| 79 obfuscated_id_(obfuscated_id), | |
| 80 index_(index), | |
| 81 is_active_(is_active) {} | |
| 82 | |
| 83 } // namespace wallet | |
| 84 | |
| 85 } // namespace autofill | |
| OLD | NEW |