Fix breakages in https://codereview.chromium.org/1155713003/
[chromium-blink-merge.git] / ios / web / web_state / web_view_creation_utils.h
blob6bab9d1aed82bee774c0af4b7ba28e5a111df9a8
1 // Copyright 2014 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_WEB_WEB_STATE_WEB_VIEW_CREATION_UTILS_H_
6 #define IOS_WEB_WEB_STATE_WEB_VIEW_CREATION_UTILS_H_
8 #import <UIKit/UIKit.h>
10 #include "ios/web/public/web_view_type.h"
12 @protocol CRWSimpleWebViewController;
13 @class WKWebView;
14 @class WKWebViewConfiguration;
16 // This file is a collection of functions that vend web views.
17 namespace web {
18 class BrowserState;
20 // Returns a new UIWebView for displaying regular web content and registers a
21 // user agent for it. The returned UIWebView will have a user agent string that
22 // includes the |request_group_id|.
23 // Note: Callers are responsible for releasing the returned UIWebView.
24 // TODO(shreyasv): Rename to CreateUIWebView.
25 UIWebView* CreateWebView(CGRect frame,
26 NSString* request_group_id,
27 BOOL use_desktop_user_agent);
29 // Returns a new UIWebView for displaying regular web content.
30 // Note: Callers are responsible for releasing the returned UIWebView.
31 // TODO(shreyasv): Rename to CreateUIWebView.
32 UIWebView* CreateWebView(CGRect frame);
34 // Creates and returns a WKWebView. The returned WKWebView will have a
35 // user agent string that includes the |request_group_id|.
36 // |browser_state| cannot be null. The |configuration| should have the same
37 // WKProcessPool as the WKWebViewConfiguration associated with |browser_state|.
38 // Note: Callers are responsible for releasing the returned WKWebView.
39 WKWebView* CreateWKWebView(CGRect frame,
40 WKWebViewConfiguration* configuration,
41 BrowserState* browser_state,
42 NSString* request_group_id,
43 BOOL use_desktop_user_agent);
45 // Returns a new WKWebView for displaying regular web content.
46 // WKWebViewConfiguration object for resulting web view will be obtained from
47 // the given |browser_state| which must not be null.
48 // Note: Callers are responsible for releasing the returned WKWebView.
49 WKWebView* CreateWKWebView(CGRect frame, BrowserState* browser_state);
51 // Returns the total number of WKWebViews that are currently present.
52 // NOTE: This only works in Debug builds and should not be used in Release
53 // builds.
54 NSUInteger GetActiveWKWebViewsCount();
56 // Returns a CRWSimpleWebViewController for managing/showing a web view.
57 // Note: Callers are responsible for releasing the CRWSimpleWebViewController.
58 id<CRWSimpleWebViewController> CreateSimpleWebViewController(
59 CGRect frame,
60 BrowserState* browser_state,
61 WebViewType web_view_type);
63 // Returns a new CRWSimpleWebViewController subclass displaying static HTML file
64 // content stored in the application bundle.
65 // Note: Callers are responsible for releasing the returned ViewController.
66 id<CRWSimpleWebViewController> CreateStaticFileSimpleWebViewController(
67 CGRect frame,
68 BrowserState* browser_state,
69 WebViewType web_view_type);
71 // Returns a new UIWebView subclass for displaying static HTML file content
72 // stored in the application bundle. if |browser_state| is nullptr, requests
73 // from the returned UIWebView will be done with global request context. When
74 // requests are made with global request context, requests such as file://
75 // will fail.
76 // Note: Callers are responsible for releasing the returned UIWebView.
77 UIWebView* CreateStaticFileWebView(CGRect frame, BrowserState* browser_state);
79 // A convenience method that returns a static file web view with
80 // CGRectZero and |nullptr| browser state.
81 // Note: Callers are responsible for releasing the returned UIWebView.
82 UIWebView* CreateStaticFileWebView();
84 } // namespace web
86 #endif // IOS_WEB_WEB_STATE_WEB_VIEW_CREATION_UTILS_H_