summaryrefslogtreecommitdiffstats
path: root/components/autofill/browser/wallet/encryption_escrow_client.h
diff options
context:
space:
mode:
Diffstat (limited to 'components/autofill/browser/wallet/encryption_escrow_client.h')
-rw-r--r--components/autofill/browser/wallet/encryption_escrow_client.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/components/autofill/browser/wallet/encryption_escrow_client.h b/components/autofill/browser/wallet/encryption_escrow_client.h
new file mode 100644
index 0000000..12d6078
--- /dev/null
+++ b/components/autofill/browser/wallet/encryption_escrow_client.h
@@ -0,0 +1,91 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_ENCRYPTION_ESCROW_CLIENT_H_
+#define COMPONENTS_AUTOFILL_BROWSER_WALLET_ENCRYPTION_ESCROW_CLIENT_H_
+
+#include <string>
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+class GURL;
+
+namespace net {
+class URLFetcher;
+class URLRequestContextGetter;
+}
+
+namespace autofill {
+namespace wallet {
+
+class EncryptionEscrowClientObserver;
+class Instrument;
+
+// EncrytionEscrowClient is responsible for making calls to the Online Wallet
+// encryption and escrow backend.
+class EncryptionEscrowClient : public net::URLFetcherDelegate {
+ public:
+ // |observer| must outlive |this|.
+ EncryptionEscrowClient(net::URLRequestContextGetter* context_getter,
+ EncryptionEscrowClientObserver* observer);
+ virtual ~EncryptionEscrowClient();
+
+ // Sends |one_time_pad|, a vector of cryptographically secure random bytes, to
+ // Online Wallet to be encrypted. These bytes must be generated using
+ // crypto/random.h.
+ void EncryptOneTimePad(const std::vector<uint8>& one_time_pad);
+
+ // Escrows the card verfication number of an existing instrument with Online
+ // Wallet. The escrow is keyed off of |obfuscated_gaia_id|.
+ void EscrowCardVerificationNumber(const std::string& card_verification_number,
+ const std::string& obfuscated_gaia_id);
+
+ // Escrows the primary account number and card verfication number of
+ // |new_instrument| with Online Wallet. The escrow is keyed off of
+ // |obfuscated_gaia_id|.
+ void EscrowInstrumentInformation(const Instrument& new_instrument,
+ const std::string& obfuscated_gaia_id);
+
+ private:
+ enum RequestType {
+ NO_PENDING_REQUEST,
+ ENCRYPT_ONE_TIME_PAD,
+ ESCROW_INSTRUMENT_INFORMATION,
+ ESCROW_CARD_VERIFICATION_NUMBER,
+ };
+
+ // Posts |post_body| to |url|. When the request is complete, |observer_| is
+ // notified of the result.
+ void MakeRequest(const GURL& url, const std::string& post_body);
+
+ // Performs bookkeeping tasks for any invalid requests.
+ void HandleMalformedResponse(net::URLFetcher* request);
+
+ // net::URLFetcherDelegate:
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ // The context for the request. Ensures the gdToken cookie is set as a header
+ // in the requests to Online Wallet if it is present.
+ scoped_refptr<net::URLRequestContextGetter> context_getter_;
+
+ // Observer class that has its various On* methods called based on the results
+ // of a request to Online Wallet.
+ EncryptionEscrowClientObserver* const observer_;
+
+ // The current request object.
+ scoped_ptr<net::URLFetcher> request_;
+
+ // The type of the current request. Must be NO_PENDING_REQUEST for a request
+ // to be initiated as only one request may be running at a given time.
+ RequestType request_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(EncryptionEscrowClient);
+};
+
+} // namespace wallet
+} // namespace autofill
+
+#endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_ENCRYPTION_ESCROW_CLIENT_H_