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

Side by Side Diff: components/autofill/content/browser/wallet/encryption_escrow_client.h

Issue 17970003: New encryption/escrow endpoints for Wallet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing again... Created 7 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_ENCRYPTION_ESCROW_CLIENT_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_ENCRYPTION_ESCROW_CLIENT_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/ref_counted.h"
12 #include "net/url_request/url_fetcher_delegate.h"
13
14 class GURL;
15
16 namespace net {
17 class URLFetcher;
18 class URLRequestContextGetter;
19 }
20
21 namespace autofill {
22 namespace wallet {
23
24 class EncryptionEscrowClientObserver;
25 class Instrument;
26
27 // EncrytionEscrowClient is responsible for making calls to the Online Wallet
28 // encryption and escrow backend.
29 class EncryptionEscrowClient : public net::URLFetcherDelegate {
30 public:
31 // |observer| must outlive |this|.
32 EncryptionEscrowClient(net::URLRequestContextGetter* context_getter,
33 EncryptionEscrowClientObserver* observer);
34 virtual ~EncryptionEscrowClient();
35
36 // Sends |one_time_pad|, a vector of cryptographically secure random bytes, to
37 // Online Wallet to be encrypted. These bytes must be generated using
38 // crypto/random.h.
39 void EncryptOneTimePad(const std::vector<uint8>& one_time_pad);
40
41 // Escrows the primary account number and card verfication number of
42 // |new_instrument| with Online Wallet. The escrow is keyed off of
43 // |obfuscated_gaia_id|.
44 void EscrowInstrumentInformation(const Instrument& new_instrument,
45 const std::string& obfuscated_gaia_id);
46
47 // Escrows the card verfication number of an existing instrument with Online
48 // Wallet. The escrow is keyed off of |obfuscated_gaia_id|.
49 void EscrowCardVerificationNumber(const std::string& card_verification_number,
50 const std::string& obfuscated_gaia_id);
51
52 // Cancels |request_| (if it exists).
53 void CancelRequest();
54
55 bool HasRequestInProgress() const;
56
57 protected:
58 // Exposed for testing.
59 const net::URLFetcher* request() const { return request_.get(); }
60
61 private:
62 enum RequestType {
63 NO_PENDING_REQUEST,
64 ENCRYPT_ONE_TIME_PAD,
65 ESCROW_INSTRUMENT_INFORMATION,
66 ESCROW_CARD_VERIFICATION_NUMBER,
67 };
68
69 // Posts |post_body| to |url|. When the request is complete, |observer_| is
70 // notified of the result.
71 void MakeRequest(const GURL& url, const std::string& post_body);
72
73 // Performs bookkeeping tasks for any invalid requests.
74 void HandleMalformedResponse(net::URLFetcher* request);
75
76 // net::URLFetcherDelegate:
77 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
78
79 // The context for the request. Ensures the gdToken cookie is set as a header
80 // in the requests to Online Wallet if it is present.
81 scoped_refptr<net::URLRequestContextGetter> context_getter_;
82
83 // Observer class that has its various On* methods called based on the results
84 // of a request to Online Wallet.
85 EncryptionEscrowClientObserver* const observer_;
86
87 // The current request object.
88 scoped_ptr<net::URLFetcher> request_;
89
90 // The type of the current request. Must be NO_PENDING_REQUEST for a request
91 // to be initiated as only one request may be running at a given time.
92 RequestType request_type_;
93
94 DISALLOW_COPY_AND_ASSIGN(EncryptionEscrowClient);
95 };
96
97 } // namespace wallet
98 } // namespace autofill
99
100 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_ENCRYPTION_ESCROW_CLIENT_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698