| OLD | NEW |
| (Empty) | |
| 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_WEB_STATE_UI_CRW_SIMPLE_WEB_VIEW_CONTROLLER_H_ |
| 6 #define IOS_WEB_WEB_STATE_UI_CRW_SIMPLE_WEB_VIEW_CONTROLLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 #import "ios/web/web_state/ui/web_view_js_utils.h" |
| 11 |
| 12 @protocol CRWSimpleWebViewControllerDelegate; |
| 13 |
| 14 #pragma mark - |
| 15 #pragma mark Web View Protocol |
| 16 // An abstraction for interacting with a web view without having to know if it's |
| 17 // a UIWebView or a WKWebView internally. |
| 18 @protocol CRWSimpleWebViewController<NSObject> |
| 19 |
| 20 // The page title, meant for display to the user. Will return nil if not |
| 21 // available. |
| 22 @property(nonatomic, readonly) NSString* title; |
| 23 |
| 24 // The web view associated with this controller. |
| 25 @property(nonatomic, readonly) UIView* view; |
| 26 |
| 27 // The web view's scroll view. |
| 28 @property(nonatomic, readonly) UIScrollView* scrollView; |
| 29 |
| 30 // The delegate that recieves page lifecycle callbacks |
| 31 @property(nonatomic, weak) id<CRWSimpleWebViewControllerDelegate> delegate; |
| 32 |
| 33 // Reloads any displayed data to ensure the view is up to date. |
| 34 - (void)reload; |
| 35 |
| 36 // Loads a request in the WebView. |
| 37 - (void)loadRequest:(NSURLRequest*)request; |
| 38 |
| 39 // Loads an HTML document in the web view. |baseURL| is a URL that is used to |
| 40 // resolve relative URLs within the document. |
| 41 - (void)loadHTMLString:(NSString*)html baseURL:(NSURL*)baseURL; |
| 42 |
| 43 // Loads a PDF file from the application sandbox. A file must exist at |
| 44 // |filePath|. |
| 45 - (void)loadPDFAtFilePath:(NSString*)filePath; |
| 46 |
| 47 // Evaluates the supplied JavaScript in the web view. Calls |completionHandler| |
| 48 // with results of the evaluation. The |completionHandler| can be nil. |
| 49 - (void)evaluateJavaScript:(NSString*)script |
| 50 stringResultHandler:(web::JavaScriptCompletion)handler; |
| 51 |
| 52 @end |
| 53 |
| 54 #pragma mark - |
| 55 #pragma mark Delegate Protocol |
| 56 // CRWSimpleWebViewController delegate protocol for subscribing to page |
| 57 // lifecycle events. |
| 58 @protocol CRWSimpleWebViewControllerDelegate<NSObject> |
| 59 |
| 60 @optional |
| 61 // Called to decide if the CRWSimpleWebViewController should load a request. |
| 62 - (BOOL)simpleWebViewController: |
| 63 (id<CRWSimpleWebViewController>)simpleWebViewController |
| 64 shouldStartLoadWithRequest:(NSURLRequest*)request; |
| 65 |
| 66 // Called when the title changes. Can be called with nil value for |title|. |
| 67 // Note: This call is not accurate all the time for the UIWebView case. The |
| 68 // delegate method is not guaranteed to be called even if the title has changed. |
| 69 // Clients should structure their code around it. |
| 70 - (void)simpleWebViewController: |
| 71 (id<CRWSimpleWebViewController>)simpleWebViewController |
| 72 titleMayHaveChanged:(NSString*)title; |
| 73 |
| 74 @end |
| 75 |
| 76 #endif // IOS_WEB_WEB_STATE_UI_CRW_SIMPLE_WEB_VIEW_CONTROLLER_H_ |
| OLD | NEW |