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

Side by Side Diff: chrome/browser/autofill/wallet/encryption_escrow_client.h

Issue 12434004: Move remaining Autofill code to //components/autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 CHROME_BROWSER_AUTOFILL_WALLET_ENCRYPTION_ESCROW_CLIENT_H_
6 #define CHROME_BROWSER_AUTOFILL_WALLET_ENCRYPTION_ESCROW_CLIENT_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "net/url_request/url_fetcher_delegate.h"
14
15 class GURL;
16
17 namespace net {
18 class URLFetcher;
19 class URLRequestContextGetter;
20 }
21
22 namespace autofill {
23 namespace wallet {
24
25 class EncryptionEscrowClientObserver;
26 class Instrument;
27
28 // EncrytionEscrowClient is responsible for making calls to the Online Wallet
29 // encryption and escrow backend.
30 class EncryptionEscrowClient : public net::URLFetcherDelegate {
31 public:
32 explicit EncryptionEscrowClient(net::URLRequestContextGetter* context_getter);
33 virtual ~EncryptionEscrowClient();
34
35 // Sends |one_time_pad|, a vector of cryptographically secure random bytes, to
36 // Online Wallet to be encrypted. These bytes must be generated using
37 // crypto/random.h. |observer| is notified when the request is complete.
38 void EncryptOneTimePad(
39 const std::vector<uint8>& one_time_pad,
40 base::WeakPtr<EncryptionEscrowClientObserver> observer);
41
42 // Escrows the card verfication number of an existing instrument with Online
43 // Wallet. The escrow is keyed off of |obfuscated_gaia_id|. |observer| is
44 // notified when the request is complete.
45 void EscrowCardVerificationNumber(
46 const std::string& card_verification_number,
47 const std::string& obfuscated_gaia_id,
48 base::WeakPtr<EncryptionEscrowClientObserver> observer);
49
50 // Escrows the primary account number and card verfication number of
51 // |new_instrument| with Online Wallet. The escrow is keyed off of
52 // |obfuscated_gaia_id|. |observer| is notified when the request is complete.
53 void EscrowInstrumentInformation(
54 const Instrument& new_instrument,
55 const std::string& obfuscated_gaia_id,
56 base::WeakPtr<EncryptionEscrowClientObserver> observer);
57
58 private:
59 enum RequestType {
60 NO_PENDING_REQUEST,
61 ENCRYPT_ONE_TIME_PAD,
62 ESCROW_INSTRUMENT_INFORMATION,
63 ESCROW_CARD_VERIFICATION_NUMBER,
64 };
65
66 // Posts |post_body| to |url|. When the request is complete, the |observer|
67 // is notified of the result.
68 void MakeRequest(
69 const GURL& url,
70 const std::string& post_body,
71 base::WeakPtr<EncryptionEscrowClientObserver> observer);
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 base::WeakPtr<EncryptionEscrowClientObserver> 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 // CHROME_BROWSER_AUTOFILL_WALLET_ENCRYPTION_ESCROW_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698