| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_H_ |
| 6 #define COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" // For base::Closure. | 12 #include "base/callback.h" // For base::Closure. |
| 13 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/time.h" | 15 #include "base/time.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "components/autofill/browser/autofill_manager_delegate.h" | 17 #include "components/autofill/browser/autofill_manager_delegate.h" |
| 17 #include "components/autofill/browser/autofill_metrics.h" | 18 #include "components/autofill/browser/autofill_metrics.h" |
| 18 #include "components/autofill/browser/wallet/cart.h" | 19 #include "components/autofill/browser/wallet/cart.h" |
| 19 #include "components/autofill/browser/wallet/encryption_escrow_client.h" | 20 #include "components/autofill/browser/wallet/encryption_escrow_client.h" |
| 20 #include "components/autofill/browser/wallet/encryption_escrow_client_observer.h
" | 21 #include "components/autofill/browser/wallet/encryption_escrow_client_observer.h
" |
| 21 #include "components/autofill/browser/wallet/full_wallet.h" | 22 #include "components/autofill/browser/wallet/full_wallet.h" |
| 22 #include "components/autofill/browser/wallet/wallet_items.h" | 23 #include "components/autofill/browser/wallet/wallet_items.h" |
| 23 #include "components/autofill/common/autocheckout_status.h" | 24 #include "components/autofill/common/autocheckout_status.h" |
| 25 #include "components/autofill/common/autofill_export.h" |
| 24 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
| 25 #include "net/url_request/url_fetcher_delegate.h" | 27 #include "net/url_request/url_fetcher_delegate.h" |
| 26 #include "testing/gtest/include/gtest/gtest_prod.h" | 28 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 27 | 29 |
| 28 namespace net { | 30 namespace net { |
| 29 class URLFetcher; | 31 class URLFetcher; |
| 30 class URLRequestContextGetter; | 32 class URLRequestContextGetter; |
| 31 } | 33 } |
| 32 | 34 |
| 33 namespace autofill { | 35 namespace autofill { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 // the user will need to verify who they are by authenticating their | 60 // the user will need to verify who they are by authenticating their |
| 59 // chosen backing instrument through AuthenticateInstrument | 61 // chosen backing instrument through AuthenticateInstrument |
| 60 // 4) If the user initiated Autocheckout, SendAutocheckoutStatus to notify | 62 // 4) If the user initiated Autocheckout, SendAutocheckoutStatus to notify |
| 61 // Online Wallet of the status flow to record various metrics. | 63 // Online Wallet of the status flow to record various metrics. |
| 62 // | 64 // |
| 63 // WalletClient is designed so only one request to Online Wallet can be outgoing | 65 // WalletClient is designed so only one request to Online Wallet can be outgoing |
| 64 // at any one time. If |HasRequestInProgress()| is true while calling e.g. | 66 // at any one time. If |HasRequestInProgress()| is true while calling e.g. |
| 65 // GetWalletItems(), the request will be queued and started later. Queued | 67 // GetWalletItems(), the request will be queued and started later. Queued |
| 66 // requests start in the order they were received. | 68 // requests start in the order they were received. |
| 67 | 69 |
| 68 class WalletClient | 70 class AUTOFILL_EXPORT WalletClient |
| 69 : public net::URLFetcherDelegate, | 71 : public net::URLFetcherDelegate, |
| 70 public EncryptionEscrowClientObserver { | 72 NON_EXPORTED_BASE(public EncryptionEscrowClientObserver) { |
| 71 public: | 73 public: |
| 72 // The Risk challenges supported by users of WalletClient. | 74 // The Risk challenges supported by users of WalletClient. |
| 73 enum RiskCapability { | 75 enum RiskCapability { |
| 74 RELOGIN, | 76 RELOGIN, |
| 75 VERIFY_CVC, | 77 VERIFY_CVC, |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 // The type of error returned by Online Wallet. | 80 // The type of error returned by Online Wallet. |
| 79 enum ErrorType { | 81 enum ErrorType { |
| 80 // Errors to display to users. | 82 // Errors to display to users. |
| 81 BUYER_ACCOUNT_ERROR, // Risk deny, unsupported country, or account | 83 BUYER_ACCOUNT_ERROR, // Risk deny, unsupported country, or account |
| 82 // closed. | 84 // closed. |
| 83 SPENDING_LIMIT_EXCEEDED, // User needs make a cheaper transaction or not | 85 SPENDING_LIMIT_EXCEEDED, // User needs make a cheaper transaction or not |
| 84 // use Online Wallet. | 86 // use Online Wallet. |
| 85 | 87 |
| 86 // API errors. | 88 // API errors. |
| 87 BAD_REQUEST, // Request was very malformed or sent to the | 89 BAD_REQUEST, // Request was very malformed or sent to the |
| 88 // wrong endpoint. | 90 // wrong endpoint. |
| 89 INVALID_PARAMS, // API call had missing or invalid parameters. | 91 INVALID_PARAMS, // API call had missing or invalid parameters. |
| 90 UNSUPPORTED_API_VERSION, // The server API version of the request is no | 92 UNSUPPORTED_API_VERSION, // The server API version of the request is no |
| 91 // longer supported. | 93 // longer supported. |
| 92 | 94 |
| 93 // Server errors. | 95 // Server errors. |
| 94 INTERNAL_ERROR, // Unknown server side error. | 96 INTERNAL_ERROR, // Unknown server side error. |
| 95 SERVICE_UNAVAILABLE, // Online Wallet is down. | 97 SERVICE_UNAVAILABLE, // Online Wallet is down. |
| 96 | 98 |
| 97 UNKNOWN_ERROR, // Catch all error type. | 99 UNKNOWN_ERROR, // Catch all error type. |
| 98 }; | 100 }; |
| 99 | 101 |
| 100 struct FullWalletRequest { | 102 struct AUTOFILL_EXPORT FullWalletRequest { |
| 101 public: | 103 public: |
| 102 FullWalletRequest(const std::string& instrument_id, | 104 FullWalletRequest(const std::string& instrument_id, |
| 103 const std::string& address_id, | 105 const std::string& address_id, |
| 104 const GURL& source_url, | 106 const GURL& source_url, |
| 105 const Cart& cart, | 107 const Cart& cart, |
| 106 const std::string& google_transaction_id, | 108 const std::string& google_transaction_id, |
| 107 const std::vector<RiskCapability> risk_capabilities); | 109 const std::vector<RiskCapability> risk_capabilities); |
| 108 ~FullWalletRequest(); | 110 ~FullWalletRequest(); |
| 109 | 111 |
| 110 // The ID of the backing instrument. Should have been selected by the user | 112 // The ID of the backing instrument. Should have been selected by the user |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 // When the current request started. Used to track client side latency. | 323 // When the current request started. Used to track client side latency. |
| 322 base::Time request_started_timestamp_; | 324 base::Time request_started_timestamp_; |
| 323 | 325 |
| 324 DISALLOW_COPY_AND_ASSIGN(WalletClient); | 326 DISALLOW_COPY_AND_ASSIGN(WalletClient); |
| 325 }; | 327 }; |
| 326 | 328 |
| 327 } // namespace wallet | 329 } // namespace wallet |
| 328 } // namespace autofill | 330 } // namespace autofill |
| 329 | 331 |
| 330 #endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_H_ | 332 #endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_H_ |
| OLD | NEW |