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_WALLET_WALLET_SIGNIN_HELPER_H_ | |
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_SIGNIN_HELPER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "net/url_request/url_fetcher_delegate.h" | |
14 | |
15 namespace net { | |
16 class URLFetcher; | |
17 class URLRequestContextGetter; | |
18 } | |
19 | |
20 class GoogleServiceAuthError; | |
21 | |
22 namespace autofill { | |
23 namespace wallet { | |
24 | |
25 class WalletSigninHelperDelegate; | |
26 | |
27 // Authenticates the user against the Online Wallet service. | |
28 // This class is not thread-safe. An instance may be used on any thread, but | |
29 // should not be accessed from multiple threads. | |
30 class WalletSigninHelper : public net::URLFetcherDelegate { | |
31 public: | |
32 // Constructs a helper that works with a given |delegate| and uses a given | |
33 // |getter| to obtain a context for URL. Both |delegate| and |getter| shall | |
34 // remain valid over the entire lifetime of the created instance. | |
35 WalletSigninHelper(WalletSigninHelperDelegate* delegate, | |
36 net::URLRequestContextGetter* getter); | |
37 | |
38 ~WalletSigninHelper() override; | |
39 | |
40 // Initiates an attempt to passively sign the user into the Online Wallet. | |
41 // A passive sign-in is a non-interactive refresh of content area cookies, | |
42 // and it succeeds as long as the Online Wallet service could safely accept | |
43 // or refresh the existing area cookies, and the user doesn't need to be | |
44 // fully reauthenticated with the service. | |
45 // Either OnPassiveSigninSuccess or OnPassiveSigninFailure will be called | |
46 // on the original thread. | |
47 void StartPassiveSignin(size_t user_index); | |
48 | |
49 // Initiates the fetch of the user's Google Wallet cookie. | |
50 void StartWalletCookieValueFetch(); | |
51 | |
52 private: | |
53 // Called if a service authentication error occurs. | |
54 void OnServiceError(const GoogleServiceAuthError& error); | |
55 | |
56 // Called if any other error occurs. | |
57 void OnOtherError(); | |
58 | |
59 // URLFetcherDelegate implementation. | |
60 void OnURLFetchComplete(const net::URLFetcher* fetcher) override; | |
61 | |
62 // Callback for when the Google Wallet cookie has been retrieved. | |
63 void ReturnWalletCookieValue(const std::string& cookie_value); | |
64 | |
65 // Should be valid throughout the lifetime of the instance. | |
66 WalletSigninHelperDelegate* const delegate_; | |
67 | |
68 // URLRequestContextGetter to be used for URLFetchers. | |
69 net::URLRequestContextGetter* const getter_; | |
70 | |
71 // While passive login/merge session URL fetches are going on: | |
72 scoped_ptr<net::URLFetcher> url_fetcher_; | |
73 | |
74 base::WeakPtrFactory<WalletSigninHelper> weak_ptr_factory_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(WalletSigninHelper); | |
77 }; | |
78 | |
79 } // namespace wallet | |
80 } // namespace autofill | |
81 | |
82 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_SIGNIN_HELPER_H_ | |
OLD | NEW |