1 // Copyright 2013 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 CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_DELEGATE_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_DELEGATE_H_
8 #include "base/strings/string16.h"
9 #include "content/public/browser/invalidate_type.h"
10 #include "content/public/browser/navigation_controller.h"
11 #include "ui/base/page_transition_types.h"
12 #include "ui/base/window_open_disposition.h"
15 struct FrameHostMsg_DidCommitProvisionalLoad_Params
;
16 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params
;
21 class NavigationHandle
;
22 class RenderFrameHostImpl
;
23 struct LoadCommittedDetails
;
26 // A delegate API used by Navigator to notify its embedder of navigation
28 class CONTENT_EXPORT NavigatorDelegate
{
30 // Called when a navigation started. The same NavigationHandle will be
31 // provided for events related to the same navigation.
32 virtual void DidStartNavigation(NavigationHandle
* navigation_handle
) {}
34 // Called when a navigation was redirected.
35 virtual void DidRedirectNavigation(NavigationHandle
* navigation_handle
) {}
37 // Called when a navigation committed.
38 virtual void DidCommitNavigation(NavigationHandle
* navigation_handle
) {}
40 // Called when a document load resulting from the navigation stopped. Note
41 // that |navigation_handle| will be destroyed at the end of this call.
42 virtual void DidFinishNavigation(NavigationHandle
* navigation_handle
) {}
44 // TODO(clamy): all methods below that are related to navigation
45 // events should go away in favor of the ones above.
47 // The RenderFrameHost started a provisional load for the frame
48 // represented by |render_frame_host|.
49 virtual void DidStartProvisionalLoad(
50 RenderFrameHostImpl
* render_frame_host
,
51 const GURL
& validated_url
,
53 bool is_iframe_srcdoc
) {}
55 // A provisional load in |render_frame_host| failed.
56 virtual void DidFailProvisionalLoadWithError(
57 RenderFrameHostImpl
* render_frame_host
,
58 const FrameHostMsg_DidFailProvisionalLoadWithError_Params
& params
) {}
60 // Document load in |render_frame_host| failed.
61 virtual void DidFailLoadWithError(
62 RenderFrameHostImpl
* render_frame_host
,
65 const base::string16
& error_description
,
66 bool was_ignored_by_handler
) {}
68 // A navigation was committed in |render_frame_host|.
69 virtual void DidCommitProvisionalLoad(
70 RenderFrameHostImpl
* render_frame_host
,
72 ui::PageTransition transition_type
) {}
74 // Handles post-navigation tasks in navigation BEFORE the entry has been
75 // committed to the NavigationController.
76 virtual void DidNavigateMainFramePreCommit(bool navigation_is_within_page
) {}
78 // Handles post-navigation tasks in navigation AFTER the entry has been
79 // committed to the NavigationController. Note that the NavigationEntry is
80 // not provided since it may be invalid/changed after being committed. The
81 // NavigationController's last committed entry is for this navigation.
82 virtual void DidNavigateMainFramePostCommit(
83 RenderFrameHostImpl
* render_frame_host
,
84 const LoadCommittedDetails
& details
,
85 const FrameHostMsg_DidCommitProvisionalLoad_Params
& params
) {}
86 virtual void DidNavigateAnyFramePostCommit(
87 RenderFrameHostImpl
* render_frame_host
,
88 const LoadCommittedDetails
& details
,
89 const FrameHostMsg_DidCommitProvisionalLoad_Params
& params
) {}
91 virtual void SetMainFrameMimeType(const std::string
& mime_type
) {}
92 virtual bool CanOverscrollContent() const;
94 // Notification to the Navigator embedder that navigation state has
95 // changed. This method corresponds to
96 // WebContents::NotifyNavigationStateChanged.
97 virtual void NotifyChangedNavigationState(InvalidateTypes changed_flags
) {}
99 // Notifies the Navigator embedder that it is beginning to navigate a frame.
100 virtual void AboutToNavigateRenderFrame(
101 RenderFrameHostImpl
* old_host
,
102 RenderFrameHostImpl
* new_host
) {}
104 // Notifies the Navigator embedder that a navigation to the pending
105 // NavigationEntry has started in the browser process.
106 virtual void DidStartNavigationToPendingEntry(
108 NavigationController::ReloadType reload_type
) {}
110 // Opens a URL with the given parameters. See PageNavigator::OpenURL, which
112 virtual void RequestOpenURL(RenderFrameHostImpl
* render_frame_host
,
113 const OpenURLParams
& params
) {}
115 // Returns whether URLs for aborted browser-initiated navigations should be
116 // preserved in the omnibox. Defaults to false.
117 virtual bool ShouldPreserveAbortedURLs();
119 // A RenderFrameHost in the specified |frame_tree_node| started loading a new
120 // document. This correponds to Blink's notion of the throbber starting.
121 // |to_different_document| will be true unless the load is a fragment
122 // navigation, or triggered by history.pushState/replaceState.
123 virtual void DidStartLoading(FrameTreeNode
* frame_tree_node
,
124 bool to_different_document
) {}
126 // A document stopped loading. This corresponds to Blink's notion of the
127 // throbber stopping.
128 virtual void DidStopLoading() {}
130 // The load progress was changed.
131 virtual void DidChangeLoadProgress() {}
134 } // namspace content
136 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_DELEGATE_H_