| OLD | NEW |
| (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_AUTOCHECKOUT_REQUEST_MANAGER_H_ | |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_ | |
| 7 | |
| 8 #include "base/supports_user_data.h" | |
| 9 #include "components/autofill/content/browser/autocheckout_statistic.h" | |
| 10 #include "components/autofill/content/browser/wallet/wallet_client.h" | |
| 11 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" | |
| 12 #include "components/autofill/core/browser/autofill_metrics.h" | |
| 13 #include "components/autofill/core/common/autocheckout_status.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 namespace content { | |
| 17 class BrowserContext; | |
| 18 } | |
| 19 | |
| 20 namespace net { | |
| 21 class URLRequestContextGetter; | |
| 22 } | |
| 23 | |
| 24 namespace autofill { | |
| 25 | |
| 26 // AutocheckoutRequestManager's only responsiblity is to make sure any | |
| 27 // SendAutocheckoutStatus calls succeed regardless of any actions the user may | |
| 28 // make in the browser i.e. closing a tab, the requestAutocomplete dialog, etc. | |
| 29 // To that end, it is a piece of user data tied to the BrowserContext. | |
| 30 class AutocheckoutRequestManager : public base::SupportsUserData::Data, | |
| 31 public wallet::WalletClientDelegate { | |
| 32 public: | |
| 33 virtual ~AutocheckoutRequestManager(); | |
| 34 | |
| 35 // Creates a new AutocheckoutRequestManager and stores it as user data in | |
| 36 // |browser_context| if one does not already exist. | |
| 37 static void CreateForBrowserContext( | |
| 38 content::BrowserContext* browser_context); | |
| 39 | |
| 40 // Retrieves the AutocheckoutRequestManager for |browser_context| if one | |
| 41 // exists. | |
| 42 static AutocheckoutRequestManager* FromBrowserContext( | |
| 43 content::BrowserContext* browser_context); | |
| 44 | |
| 45 // Sends the |status| of an Autocheckout flow to Online Wallet using | |
| 46 // |wallet_client_|. | |
| 47 void SendAutocheckoutStatus( | |
| 48 AutocheckoutStatus status, | |
| 49 const GURL& source_url, | |
| 50 const std::vector<AutocheckoutStatistic>& latency_statistics, | |
| 51 const std::string& google_transaction_id); | |
| 52 | |
| 53 // wallet::WalletClientDelegate: | |
| 54 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE; | |
| 55 virtual DialogType GetDialogType() const OVERRIDE; | |
| 56 virtual std::string GetRiskData() const OVERRIDE; | |
| 57 virtual std::string GetWalletCookieValue() const OVERRIDE; | |
| 58 virtual bool IsShippingAddressRequired() const OVERRIDE; | |
| 59 virtual void OnDidAcceptLegalDocuments() OVERRIDE; | |
| 60 virtual void OnDidAuthenticateInstrument(bool success) OVERRIDE; | |
| 61 virtual void OnDidGetFullWallet( | |
| 62 scoped_ptr<wallet::FullWallet> full_wallet) OVERRIDE; | |
| 63 virtual void OnDidGetWalletItems( | |
| 64 scoped_ptr<wallet::WalletItems> wallet_items) OVERRIDE; | |
| 65 virtual void OnDidSaveToWallet( | |
| 66 const std::string& instrument_id, | |
| 67 const std::string& address_id, | |
| 68 const std::vector<wallet::RequiredAction>& required_actions, | |
| 69 const std::vector<wallet::FormFieldError>& form_field_errors) OVERRIDE; | |
| 70 virtual void OnWalletError( | |
| 71 wallet::WalletClient::ErrorType error_type) OVERRIDE; | |
| 72 | |
| 73 private: | |
| 74 // |request_context_getter| is passed in to construct |wallet_client_|. | |
| 75 AutocheckoutRequestManager( | |
| 76 net::URLRequestContextGetter* request_context_getter); | |
| 77 | |
| 78 // Logs various UMA metrics. | |
| 79 AutofillMetrics metric_logger_; | |
| 80 | |
| 81 // Makes requests to Online Wallet. The only request this class is configured | |
| 82 // to make is SendAutocheckoutStatus. | |
| 83 wallet::WalletClient wallet_client_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(AutocheckoutRequestManager); | |
| 86 }; | |
| 87 | |
| 88 } // namespace autofill | |
| 89 | |
| 90 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_ | |
| OLD | NEW |