1 // Copyright 2015 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 IOS_CHROME_BROWSER_SIGNIN_GAIA_AUTH_FETCHER_IOS_H_
6 #define IOS_CHROME_BROWSER_SIGNIN_GAIA_AUTH_FETCHER_IOS_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "google_apis/gaia/gaia_auth_fetcher.h"
11 class GaiaAuthFetcherIOSBridge
;
17 // Specialization of GaiaAuthFetcher on iOS.
19 // Authenticate a user against the Google Accounts ClientLogin API
20 // with various capabilities and return results to a GaiaAuthConsumer.
22 // If necessary (cookies needed and WKWebView enabled), the queries will
23 // be fetched via a WKWebView instead of a net::URLFetcher.
24 class GaiaAuthFetcherIOS
: public GaiaAuthFetcher
{
26 // Sets whether the iOS specialization of the GaiaAuthFetcher should be used.
27 // Mainly used for testing.
28 // Note that if |should_use| is true, it might still not be used if it is
29 // unecessary or WKWebView isn't enabled.
30 static void SetShouldUseGaiaAuthFetcherIOSForTesting(
31 bool use_gaia_fetcher_ios
);
33 // Returns whether the iOS specialization of the GaiaAuthFetcher should be
35 static bool ShouldUseGaiaAuthFetcherIOS();
37 GaiaAuthFetcherIOS(GaiaAuthConsumer
* consumer
,
38 const std::string
& source
,
39 net::URLRequestContextGetter
* getter
,
40 web::BrowserState
* browser_state
);
41 ~GaiaAuthFetcherIOS() override
;
43 void CancelRequest() override
;
46 friend class GaiaAuthFetcherIOSBridge
;
47 friend class GaiaAuthFetcherIOSTest
;
49 void CreateAndStartGaiaFetcher(const std::string
& body
,
50 const std::string
& headers
,
51 const GURL
& gaia_gurl
,
52 int load_flags
) override
;
53 void FetchComplete(const GURL
& url
,
54 const std::string
& data
,
55 const net::ResponseCookies
& cookies
,
56 const net::URLRequestStatus
& status
,
59 scoped_ptr
<GaiaAuthFetcherIOSBridge
> bridge_
;
60 web::BrowserState
* browser_state_
;
62 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcherIOS
);
65 #endif // IOS_CHROME_BROWSER_SIGNIN_GAIA_AUTH_FETCHER_IOS_H_