OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_CONTENT_BROWSER_WALLET_WALLET_SIGNIN_HELPER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_SIGNIN_HELPER_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_SIGNIN_HELPER_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_SIGNIN_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // This class is not thread-safe. An instance may be used on any thread, but | 28 // This class is not thread-safe. An instance may be used on any thread, but |
29 // should not be accessed from multiple threads. | 29 // should not be accessed from multiple threads. |
30 class WalletSigninHelper : public net::URLFetcherDelegate { | 30 class WalletSigninHelper : public net::URLFetcherDelegate { |
31 public: | 31 public: |
32 // Constructs a helper that works with a given |delegate| and uses a given | 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 | 33 // |getter| to obtain a context for URL. Both |delegate| and |getter| shall |
34 // remain valid over the entire lifetime of the created instance. | 34 // remain valid over the entire lifetime of the created instance. |
35 WalletSigninHelper(WalletSigninHelperDelegate* delegate, | 35 WalletSigninHelper(WalletSigninHelperDelegate* delegate, |
36 net::URLRequestContextGetter* getter); | 36 net::URLRequestContextGetter* getter); |
37 | 37 |
38 virtual ~WalletSigninHelper(); | 38 ~WalletSigninHelper() override; |
39 | 39 |
40 // Initiates an attempt to passively sign the user into the Online Wallet. | 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, | 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 | 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 | 43 // or refresh the existing area cookies, and the user doesn't need to be |
44 // fully reauthenticated with the service. | 44 // fully reauthenticated with the service. |
45 // Either OnPassiveSigninSuccess or OnPassiveSigninFailure will be called | 45 // Either OnPassiveSigninSuccess or OnPassiveSigninFailure will be called |
46 // on the original thread. | 46 // on the original thread. |
47 void StartPassiveSignin(size_t user_index); | 47 void StartPassiveSignin(size_t user_index); |
48 | 48 |
49 // Initiates the fetch of the user's Google Wallet cookie. | 49 // Initiates the fetch of the user's Google Wallet cookie. |
50 void StartWalletCookieValueFetch(); | 50 void StartWalletCookieValueFetch(); |
51 | 51 |
52 private: | 52 private: |
53 // Called if a service authentication error occurs. | 53 // Called if a service authentication error occurs. |
54 void OnServiceError(const GoogleServiceAuthError& error); | 54 void OnServiceError(const GoogleServiceAuthError& error); |
55 | 55 |
56 // Called if any other error occurs. | 56 // Called if any other error occurs. |
57 void OnOtherError(); | 57 void OnOtherError(); |
58 | 58 |
59 // URLFetcherDelegate implementation. | 59 // URLFetcherDelegate implementation. |
60 virtual void OnURLFetchComplete(const net::URLFetcher* fetcher) override; | 60 void OnURLFetchComplete(const net::URLFetcher* fetcher) override; |
61 | 61 |
62 // Callback for when the Google Wallet cookie has been retrieved. | 62 // Callback for when the Google Wallet cookie has been retrieved. |
63 void ReturnWalletCookieValue(const std::string& cookie_value); | 63 void ReturnWalletCookieValue(const std::string& cookie_value); |
64 | 64 |
65 // Should be valid throughout the lifetime of the instance. | 65 // Should be valid throughout the lifetime of the instance. |
66 WalletSigninHelperDelegate* const delegate_; | 66 WalletSigninHelperDelegate* const delegate_; |
67 | 67 |
68 // URLRequestContextGetter to be used for URLFetchers. | 68 // URLRequestContextGetter to be used for URLFetchers. |
69 net::URLRequestContextGetter* const getter_; | 69 net::URLRequestContextGetter* const getter_; |
70 | 70 |
71 // While passive login/merge session URL fetches are going on: | 71 // While passive login/merge session URL fetches are going on: |
72 scoped_ptr<net::URLFetcher> url_fetcher_; | 72 scoped_ptr<net::URLFetcher> url_fetcher_; |
73 | 73 |
74 base::WeakPtrFactory<WalletSigninHelper> weak_ptr_factory_; | 74 base::WeakPtrFactory<WalletSigninHelper> weak_ptr_factory_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(WalletSigninHelper); | 76 DISALLOW_COPY_AND_ASSIGN(WalletSigninHelper); |
77 }; | 77 }; |
78 | 78 |
79 } // namespace wallet | 79 } // namespace wallet |
80 } // namespace autofill | 80 } // namespace autofill |
81 | 81 |
82 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_SIGNIN_HELPER_H_ | 82 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_SIGNIN_HELPER_H_ |
OLD | NEW |