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_PRIVATE_H_
6 #define IOS_CHROME_BROWSER_SIGNIN_GAIA_AUTH_FETCHER_IOS_PRIVATE_H_
8 #import <Webkit/Webkit.h>
10 #import "base/mac/scoped_nsobject.h"
11 #include "base/macros.h"
13 class GaiaAuthFetcherIOS
;
20 // Navigation delegate attached to a WKWebView used for URL fetches.
21 @interface GaiaAuthFetcherNavigationDelegate
: NSObject
<WKNavigationDelegate
>
24 // Bridge between the GaiaAuthFetcherIOS and the webview (and its navigation
25 // delegate) used to actually do the network fetch.
26 class GaiaAuthFetcherIOSBridge
{
28 GaiaAuthFetcherIOSBridge(GaiaAuthFetcherIOS
* fetcher
,
29 web::BrowserState
* browser_state
);
30 ~GaiaAuthFetcherIOSBridge();
32 // Starts a network fetch.
33 // * |url| is the URL to fetch.
34 // * |headers| are the HTTP headers to add to the request.
35 // * |body| is the HTTP body to add to the request. If not empty, the fetch
36 // will be a POST request.
37 void Fetch(const GURL
& url
,
38 const std::string
& headers
,
39 const std::string
& body
);
41 // Cancels the current fetch.
44 // Informs the bridge of the success of the URL fetch.
45 // * |data| is the body of the HTTP response.
46 // URLFetchSuccess and URLFetchFailure are no-op if one of them was already
48 void URLFetchSuccess(const std::string
& data
);
50 // Informs the bridge of the failure of the URL fetch.
51 // * |is_cancelled| whether the fetch failed because it was cancelled.
52 // URLFetchSuccess and URLFetchFailure are no-op if one of them was already
54 void URLFetchFailure(bool is_cancelled
);
57 friend class GaiaAuthFetcherIOSTest
;
60 GaiaAuthFetcherIOS
* fetcher_
;
62 base::scoped_nsobject
<GaiaAuthFetcherNavigationDelegate
> navigation_delegate_
;
63 base::scoped_nsobject
<WKWebView
> web_view_
;
65 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcherIOSBridge
);
68 #endif // IOS_CHROME_BROWSER_SIGNIN_GAIA_AUTH_FETCHER_IOS_PRIVATE_H_