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_INTERNAL_CREATION_UTIL_H_
6 #define IOS_WEB_WEB_STATE_WEB_VIEW_INTERNAL_CREATION_UTIL_H_
8 #import <UIKit/UIKit.h>
10 #include "ios/web/public/web_view_type.h"
12 @protocol CRWSimpleWebViewController
;
14 @
class WKWebViewConfiguration
;
16 // This file is a collection of functions that vend web views.
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 // The BrowsingDataPartition must be synchronized before this method is called.
39 // Note: Callers are responsible for releasing the returned WKWebView.
40 WKWebView
* CreateWKWebView(CGRect frame
,
41 WKWebViewConfiguration
* configuration
,
42 BrowserState
* browser_state
,
43 NSString
* request_group_id
,
44 BOOL use_desktop_user_agent
);
46 // Creates and returns a new WKWebView for displaying regular web content.
47 // |browser_state| cannot be null. The |configuration| should have the same
48 // WKProcessPool as the WKWebViewConfiguration associated with |browser_state|.
49 // The BrowsingDataPartition must be synchronized before this method is called.
50 // Note: Callers are responsible for releasing the returned WKWebView.
51 WKWebView
* CreateWKWebView(CGRect frame
,
52 WKWebViewConfiguration
* configuration
,
53 BrowserState
* browser_state
);
55 // Returns the total number of WKWebViews that are currently present.
56 // NOTE: This only works in Debug builds and should not be used in Release
58 NSUInteger
GetActiveWKWebViewsCount();
60 // Returns a CRWSimpleWebViewController for managing/showing a web view.
61 // The BrowsingDataPartition must be synchronized before this method is called.
62 // Note: Callers are responsible for releasing the CRWSimpleWebViewController.
63 id
<CRWSimpleWebViewController
> CreateSimpleWebViewController(
65 BrowserState
* browser_state
,
66 WebViewType web_view_type
);
68 // Returns a new CRWSimpleWebViewController subclass displaying static HTML file
69 // content stored in the application bundle.
70 // The BrowsingDataPartition must be synchronized before this method is called.
71 // Note: Callers are responsible for releasing the returned ViewController.
72 id
<CRWSimpleWebViewController
> CreateStaticFileSimpleWebViewController(
74 BrowserState
* browser_state
,
75 WebViewType web_view_type
);
77 // Returns a new UIWebView subclass for displaying static HTML file content
78 // stored in the application bundle. if |browser_state| is nullptr, requests
79 // from the returned UIWebView will be done with global request context. When
80 // requests are made with global request context, requests such as file://
82 // Note: Callers are responsible for releasing the returned UIWebView.
83 UIWebView
* CreateStaticFileWebView(CGRect frame
, BrowserState
* browser_state
);
85 // A convenience method that returns a static file web view with
86 // CGRectZero and |nullptr| browser state.
87 // Note: Callers are responsible for releasing the returned UIWebView.
88 UIWebView
* CreateStaticFileWebView();
92 #endif // IOS_WEB_WEB_STATE_WEB_VIEW_INTERNAL_CREATION_UTIL_H_