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