Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_UI_CRW_WEB_DELEGATE_H_ | 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_UI_CRW_WEB_DELEGATE_H_ |
| 6 #define IOS_WEB_PUBLIC_WEB_STATE_UI_CRW_WEB_DELEGATE_H_ | 6 #define IOS_WEB_PUBLIC_WEB_STATE_UI_CRW_WEB_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #import <UIKit/UIKit.h> | 9 #import <UIKit/UIKit.h> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #import "base/ios/block_types.h" | 12 #import "base/ios/block_types.h" |
| 13 #include "ios/web/public/favicon_url.h" | 13 #include "ios/web/public/favicon_url.h" |
| 14 #import "ios/web/public/navigation_manager.h" | 14 #import "ios/web/public/navigation_manager.h" |
| 15 #include "ios/web/public/ssl_status.h" | 15 #include "ios/web/public/ssl_status.h" |
| 16 #import "ios/web/public/web_state/ui/crw_native_content.h" | 16 #import "ios/web/public/web_state/ui/crw_native_content.h" |
| 17 #import "ios/web/public/web_state/web_state.h" | 17 #import "ios/web/public/web_state/web_state.h" |
| 18 #include "ui/base/page_transition_types.h" | 18 #include "ui/base/page_transition_types.h" |
| 19 | 19 |
| 20 class GURL; | 20 class GURL; |
| 21 @class CRWSessionEntry; | 21 @class CRWSessionEntry; |
| 22 @class CRWWebController; | 22 @class CRWWebController; |
| 23 | 23 |
| 24 namespace web { | |
| 25 class BlockedPopupInfo; | |
| 26 struct Referrer; | |
| 27 } | |
| 28 | |
| 29 // Methods implemented by the delegate of the CRWWebController. | 24 // Methods implemented by the delegate of the CRWWebController. |
| 30 // DEPRECATED, do not conform to this protocol and do not add any methods to it. | 25 // DEPRECATED, do not conform to this protocol and do not add any methods to it. |
| 31 // Use web::WebStateDelegate instead. | 26 // Use web::WebStateDelegate instead. |
| 32 // TODO(crbug.com/674991): Remove this protocol. | 27 // TODO(crbug.com/674991): Remove this protocol. |
| 33 @protocol CRWWebDelegate<NSObject> | 28 @protocol CRWWebDelegate<NSObject> |
| 34 | 29 |
| 35 // Called when the page wants to open a new window by DOM (e.g. with | |
| 36 // |window.open| JavaScript call or by clicking a link with |_blank| target) or | |
| 37 // wants to open a window with a new tab. |inBackground| allows a page to force | |
| 38 // a new window to open in the background. CRWSessionController's openedByDOM | |
| 39 // property of the returned CRWWebController must be YES. | |
| 40 - (CRWWebController*)webPageOrderedOpen:(const GURL&)url | |
| 41 referrer:(const web::Referrer&)referrer | |
| 42 windowName:(NSString*)windowName | |
| 43 inBackground:(BOOL)inBackground; | |
| 44 | |
| 45 // Called when the page wants to open a new window by DOM. | |
| 46 // CRWSessionController's openedByDOM property of the returned CRWWebController | |
| 47 // must be YES. | |
| 48 - (CRWWebController*)webPageOrderedOpen; | |
| 49 | |
| 50 // Called when the page calls window.close() on itself. Begin the shut-down | 30 // Called when the page calls window.close() on itself. Begin the shut-down |
| 51 // sequence for this controller. | 31 // sequence for this controller. |
| 52 - (void)webPageOrderedClose; | 32 - (void)webPageOrderedClose; |
| 53 // Called when an external app needs to be opened, it also passes |linkClicked| | 33 // Called when an external app needs to be opened, it also passes |linkClicked| |
| 54 // to track if this call was a result of user action or not. Returns YES iff | 34 // to track if this call was a result of user action or not. Returns YES iff |
| 55 // |URL| is launched in an external app. | 35 // |URL| is launched in an external app. |
| 56 - (BOOL)openExternalURL:(const GURL&)URL linkClicked:(BOOL)linkClicked; | 36 - (BOOL)openExternalURL:(const GURL&)URL linkClicked:(BOOL)linkClicked; |
| 57 | 37 |
| 58 // This method is invoked whenever the system believes the URL is about to | 38 // This method is invoked whenever the system believes the URL is about to |
| 59 // change, or immediately after any unexpected change of the URL, prior to | 39 // change, or immediately after any unexpected change of the URL, prior to |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 // TODO(rohitrao): This is not a great API. Clean it up. | 76 // TODO(rohitrao): This is not a great API. Clean it up. |
| 97 - (void)webWillInitiateLoadWithParams: | 77 - (void)webWillInitiateLoadWithParams: |
| 98 (web::NavigationManager::WebLoadParams&)params; | 78 (web::NavigationManager::WebLoadParams&)params; |
| 99 - (void)webDidUpdateSessionForLoadWithParams: | 79 - (void)webDidUpdateSessionForLoadWithParams: |
| 100 (const web::NavigationManager::WebLoadParams&)params | 80 (const web::NavigationManager::WebLoadParams&)params |
| 101 wasInitialNavigation:(BOOL)initialNavigation; | 81 wasInitialNavigation:(BOOL)initialNavigation; |
| 102 // Called from finishHistoryNavigationFromEntry. | 82 // Called from finishHistoryNavigationFromEntry. |
| 103 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry; | 83 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry; |
| 104 // --------------------------------------------------------------------- | 84 // --------------------------------------------------------------------- |
| 105 | 85 |
| 86 // Called when |webController| wants to open a new window. |URL| is the URL of | |
| 87 // the new window; |openerURL| is the URL of the page which requested a window | |
| 88 // to be open; |initiatedByUser| is YES if action was caused by the user. | |
| 89 // |webController| will not open a window if this method returns nil. This | |
| 90 // method can not return |webController|. | |
| 91 - (CRWWebController*)webController:(CRWWebController*)webController | |
| 92 createWebControllerForURL:(const GURL&)URL | |
|
marq (ping after 24h)
2017/02/15 10:34:10
Naming nit: Delegate methods that return something
Eugene But (OOO till 7-30)
2017/02/15 16:46:59
Modeled from |webView:createWebViewWithConfigurati
marq (ping after 24h)
2017/02/16 12:49:44
Given that, I'm OK with leaving it as is.
| |
| 93 openerURL:(const GURL&)openerURL | |
| 94 initiatedByUser:(BOOL)initiatedByUser; | |
| 95 | |
| 106 @optional | 96 @optional |
| 107 | 97 |
| 108 // Called to ask CRWWebDelegate if |CRWWebController| should open the given URL. | 98 // Called to ask CRWWebDelegate if |CRWWebController| should open the given URL. |
| 109 // CRWWebDelegate can intercept the request by returning NO and processing URL | 99 // CRWWebDelegate can intercept the request by returning NO and processing URL |
| 110 // in own way. | 100 // in own way. |
| 111 - (BOOL)webController:(CRWWebController*)webController | 101 - (BOOL)webController:(CRWWebController*)webController |
| 112 shouldOpenURL:(const GURL&)url | 102 shouldOpenURL:(const GURL&)url |
| 113 mainDocumentURL:(const GURL&)mainDocumentURL | 103 mainDocumentURL:(const GURL&)mainDocumentURL |
| 114 linkClicked:(BOOL)linkClicked; | 104 linkClicked:(BOOL)linkClicked; |
| 115 | 105 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 133 // Called to ask the delegate for a controller to display the given url, | 123 // Called to ask the delegate for a controller to display the given url, |
| 134 // which contained content that the UIWebView couldn't display. Returns | 124 // which contained content that the UIWebView couldn't display. Returns |
| 135 // the native controller to display if the delegate can handle the url, | 125 // the native controller to display if the delegate can handle the url, |
| 136 // or nil otherwise. | 126 // or nil otherwise. |
| 137 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url; | 127 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url; |
| 138 | 128 |
| 139 // Called when the page supplies a new title. | 129 // Called when the page supplies a new title. |
| 140 - (void)webController:(CRWWebController*)webController | 130 - (void)webController:(CRWWebController*)webController |
| 141 titleDidChange:(NSString*)title; | 131 titleDidChange:(NSString*)title; |
| 142 | 132 |
| 143 // Called when CRWWebController has detected a popup. If NO is returned then | |
| 144 // popup will be shown, otherwise |webController:didBlockPopup:| will be called | |
| 145 // and CRWWebDelegate will have a chance to unblock the popup later. NO is | |
| 146 // assumed by default if this method is not implemented. | |
| 147 - (BOOL)webController:(CRWWebController*)webController | |
| 148 shouldBlockPopupWithURL:(const GURL&)popupURL | |
| 149 sourceURL:(const GURL&)sourceURL; | |
| 150 | |
| 151 // Called when CRWWebController has detected and blocked a popup. In order to | |
| 152 // allow the blocked pop up CRWWebDelegate must call | |
| 153 // |blockedPopupInfo.ShowPopup()| instead of attempting to open a new window. | |
| 154 - (void)webController:(CRWWebController*)webController | |
| 155 didBlockPopup:(const web::BlockedPopupInfo&)blockedPopupInfo; | |
| 156 | |
| 157 // Called when CRWWebController did suppress a dialog (JavaScript, HTTP | 133 // Called when CRWWebController did suppress a dialog (JavaScript, HTTP |
| 158 // authentication or window.open). | 134 // authentication or window.open). |
| 159 // NOTE: Called only if CRWWebController.shouldSuppressDialogs is set to YES. | 135 // NOTE: Called only if CRWWebController.shouldSuppressDialogs is set to YES. |
| 160 - (void)webControllerDidSuppressDialog:(CRWWebController*)webController; | 136 - (void)webControllerDidSuppressDialog:(CRWWebController*)webController; |
| 161 | 137 |
| 162 // Called to retrieve the height of any header that is overlaying on top of the | 138 // Called to retrieve the height of any header that is overlaying on top of the |
| 163 // web view. This can be used to implement, for e.g. a toolbar that changes | 139 // web view. This can be used to implement, for e.g. a toolbar that changes |
| 164 // height dynamically. Returning a non-zero height affects the visible frame | 140 // height dynamically. Returning a non-zero height affects the visible frame |
| 165 // shown by the CRWWebController. 0.0 is assumed if not implemented. | 141 // shown by the CRWWebController. 0.0 is assumed if not implemented. |
| 166 - (CGFloat)headerHeightForWebController:(CRWWebController*)webController; | 142 - (CGFloat)headerHeightForWebController:(CRWWebController*)webController; |
| 167 | 143 |
| 168 // Called when CRWWebController updated the SSL status for the current | 144 // Called when CRWWebController updated the SSL status for the current |
| 169 // NagivationItem. | 145 // NagivationItem. |
| 170 - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem: | 146 - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem: |
| 171 (CRWWebController*)webController; | 147 (CRWWebController*)webController; |
| 172 | 148 |
| 173 // Called when a PassKit file is downloaded. |data| should be the data from a | 149 // Called when a PassKit file is downloaded. |data| should be the data from a |
| 174 // PassKit file, but this is not guaranteed, and the delegate is responsible for | 150 // PassKit file, but this is not guaranteed, and the delegate is responsible for |
| 175 // error handling non PassKit data using -[PKPass initWithData:error:]. If the | 151 // error handling non PassKit data using -[PKPass initWithData:error:]. If the |
| 176 // download does not successfully complete, |data| will be nil. | 152 // download does not successfully complete, |data| will be nil. |
| 177 - (void)webController:(CRWWebController*)webController | 153 - (void)webController:(CRWWebController*)webController |
| 178 didLoadPassKitObject:(NSData*)data; | 154 didLoadPassKitObject:(NSData*)data; |
| 179 | 155 |
| 180 @end | 156 @end |
| 181 | 157 |
| 182 #endif // IOS_WEB_PUBLIC_WEB_STATE_UI_CRW_WEB_DELEGATE_H_ | 158 #endif // IOS_WEB_PUBLIC_WEB_STATE_UI_CRW_WEB_DELEGATE_H_ |
| OLD | NEW |