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.
5 #include "components/autofill/content/browser/wallet/gaia_account.h"
7 #include "base/logging.h"
8 #include "base/values.h"
14 GaiaAccount::~GaiaAccount() {}
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
>();
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
>();
32 if (!dictionary
.GetInteger("gaia_index", &index
) ||
34 DLOG(ERROR
) << "GAIA account: missing or bad GAIA index";
35 return scoped_ptr
<GaiaAccount
>();
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
>();
44 return scoped_ptr
<GaiaAccount
>(new GaiaAccount(email_address
,
51 scoped_ptr
<GaiaAccount
> GaiaAccount::CreateForTesting(
52 const std::string
& email_address
,
53 const std::string
& obfuscated_id
,
56 scoped_ptr
<GaiaAccount
> account(new GaiaAccount(email_address
,
60 return account
.Pass();
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_
;
70 bool GaiaAccount::operator!=(const GaiaAccount
& other
) const {
71 return !(*this == other
);
74 GaiaAccount::GaiaAccount(const std::string
& email_address
,
75 const std::string
& obfuscated_id
,
78 : email_address_(email_address
),
79 obfuscated_id_(obfuscated_id
),
81 is_active_(is_active
) {}
85 } // namespace autofill