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. 4 5 #ifndef IOS_WEB_COMMON_WEB_VIEW_CREATION_UTIL_H_ 6 #define IOS_WEB_COMMON_WEB_VIEW_CREATION_UTIL_H_ 7 8 #import <CoreGraphics/CoreGraphics.h> 9 #import <Foundation/Foundation.h> 10 11 @protocol CRWContextMenuDelegate; 12 @class WKWebView; 13 14 namespace web { 15 class BrowserState; 16 17 // Returns a new WKWebView for displaying regular web content. 18 // WKWebViewConfiguration object for resulting web view will be obtained from 19 // the given |browser_state|. 20 // 21 // Preconditions for creation of a WKWebView: 22 // 1) |browser_state| is not null. 23 // 2) web::BrowsingDataPartition is synchronized. 24 // 25 WKWebView* BuildWKWebView(CGRect frame, BrowserState* browser_state); 26 27 // Returns a new WKWebView that will not be used to display content. 28 // This WKWebView can be used to fetch some data using the same cookie store 29 // as the other WKWebView but cannot be presented to the user as some components 30 // are not initialized (e.g. voice search). 31 // 32 // Preconditions for creation of a WKWebView: 33 // 1) |browser_state| is not null. 34 // 2) web::BrowsingDataPartition is synchronized. 35 // 36 WKWebView* BuildWKWebViewForQueries(BrowserState* browser_state); 37 38 // Returns a new WKWebView for displaying regular web content. 39 // The returned WKWebView is equivalent to the one created by |BuildWKWebView| 40 // but a context menu recognizer is attached to it. 41 // On a long press, context_menu_delegate webView:handleContextMenu:| is called. 42 // The custom context menu involves gesture recognizers on every touch and 43 // JavaScript. It can have impact on performances. 44 // Calling |BuildWKWebViewWithCustomContextMenu| with a |context_menu_delegate| 45 // nil is equivalent to |BuildWKWebView|. 46 WKWebView* BuildWKWebViewWithCustomContextMenu( 47 CGRect frame, 48 BrowserState* browser_state, 49 id<CRWContextMenuDelegate> context_menu_delegate); 50 51 } // web 52 53 #endif // IOS_WEB_COMMON_WEB_VIEW_CREATION_UTIL_H_ 54