blob: 8c62373cc8b49f9c10aa40905ba93fc10102d52b [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <WebKit/WebKit.h>
#include "ios/web/public/navigation/referrer.h"
#import "ios/web/web_state/ui/crw_web_view_handler.h"
#import "ios/web/web_state/ui/crw_web_view_handler_delegate.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
@class CRWWebRequestController;
@class CRWWKNavigationHandler;
namespace web {
class NavigationContextImpl;
} // namespace web
@protocol CRWWebRequestControllerDelegate <CRWWebViewHandlerDelegate>
// The delegate should stop loading the page.
- (void)webRequestControllerStopLoading:
// The delegate is called when a page has actually started loading.
- (void)webRequestControllerDidStartLoading:
// Asks proxy to disable back forward navigation gestures until the current (in
// this case restore) navigation is complete. This is necessary as restore
// can trigger a large number of navigations, and when back/forward is enabled
// this can lead to an unbounded memory spike.
- (void)webRequestControllerDisableNavigationGesturesUntilFinishNavigation:
// Tells the delegate to restores the state for current page from session
// history.
- (void)webRequestControllerRestoreStateFromHistory:
- (CRWWKNavigationHandler*)webRequestControllerNavigationHandler:
// Controller in charge of preparing and handling web requests for the delegate,
// which should be |CRWWebController|.
@interface CRWWebRequestController : CRWWebViewHandler
@property(nonatomic, weak) id<CRWWebRequestControllerDelegate> delegate;
// Checks if a load request of the current navigation item should proceed. If
// this returns |YES|, caller should create a webView and call
// |loadRequestForCurrentNavigationItem|. Otherwise this will set the request
// state to finished and call |didFinishWithURL| with failure.
- (BOOL)maybeLoadRequestForCurrentNavigationItem;
// Sets up WebUI for URL.
- (void)createWebUIForURL:(const GURL&)URL;
// Clears WebUI, if one exists.
- (void)clearWebUI;
// Loads the URL indicated by current session state.
- (void)loadCurrentURLWithRendererInitiatedNavigation:(BOOL)rendererInitiated;
// Should be called by owner component after URL is finished loading and
// self.navigationHandler.navigationState is set to FINISHED. |context| contains
// information about the navigation associated with the URL. It is nil if
// currentURL is invalid.
- (void)didFinishWithURL:(const GURL&)currentURL
context:(const web::NavigationContextImpl*)context;
// Calls |registerLoadRequestForURL| with empty referrer and link or client
// redirect transition based on user interaction state. Returns navigation
// context for this request.
// TODO( Remove |placeholderNavigation|.
- (std::unique_ptr<web::NavigationContextImpl>)
registerLoadRequestForURL:(const GURL&)URL
// Creates a page change request and registers it with the navigation handler.
// Returns navigation context for this request.
// TODO( Remove |placeholderNavigation|.
- (std::unique_ptr<web::NavigationContextImpl>)
registerLoadRequestForURL:(const GURL&)requestURL
referrer:(const web::Referrer&)referrer
// Loads |data| of type |MIMEType| and replaces last committed URL with the
// given |URL|.
- (void)loadData:(NSData*)data
forURL:(const GURL&)URL;
// Loads |HTML| into the page and use |URL| to resolve relative URLs within the
// document.
- (void)loadHTML:(NSString*)HTML forURL:(const GURL&)URL;
// Reloads web view. |rendererInitiated| is YES for renderer-initiated
// navigation. |rendererInitiated| is NO for browser-initiated navigation.
- (void)reloadWithRendererInitiatedNavigation:(BOOL)rendererInitiated;