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

Side by Side Diff: components/autofill/browser/autocheckout_request_manager.h

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

Powered by Google App Engine
This is Rietveld 408576698