• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_DELEGATE_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_DELEGATE_H_
7 
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"
13 
14 class GURL;
15 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
16 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
17 
18 namespace content {
19 
20 class RenderFrameHostImpl;
21 struct LoadCommittedDetails;
22 struct OpenURLParams;
23 
24 // A delegate API used by Navigator to notify its embedder of navigation
25 // related events.
26 class CONTENT_EXPORT NavigatorDelegate {
27  public:
28   // The RenderFrameHost started a provisional load for the frame
29   // represented by |render_frame_host|.
DidStartProvisionalLoad(RenderFrameHostImpl * render_frame_host,const GURL & validated_url,bool is_error_page,bool is_iframe_srcdoc)30   virtual void DidStartProvisionalLoad(
31       RenderFrameHostImpl* render_frame_host,
32       const GURL& validated_url,
33       bool is_error_page,
34       bool is_iframe_srcdoc) {}
35 
36   // The |render_frame_host| started a transition-flagged navigation.
DidStartNavigationTransition(RenderFrameHostImpl * render_frame_host)37   virtual void DidStartNavigationTransition(
38       RenderFrameHostImpl* render_frame_host) {}
39 
40   // A provisional load in |render_frame_host| failed.
DidFailProvisionalLoadWithError(RenderFrameHostImpl * render_frame_host,const FrameHostMsg_DidFailProvisionalLoadWithError_Params & params)41   virtual void DidFailProvisionalLoadWithError(
42       RenderFrameHostImpl* render_frame_host,
43       const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {}
44 
45   // Document load in |render_frame_host| failed.
DidFailLoadWithError(RenderFrameHostImpl * render_frame_host,const GURL & url,int error_code,const base::string16 & error_description)46   virtual void DidFailLoadWithError(
47       RenderFrameHostImpl* render_frame_host,
48       const GURL& url,
49       int error_code,
50       const base::string16& error_description) {}
51 
52   // A navigation was committed in |render_frame_host|.
DidCommitProvisionalLoad(RenderFrameHostImpl * render_frame_host,const GURL & url,ui::PageTransition transition_type)53   virtual void DidCommitProvisionalLoad(
54       RenderFrameHostImpl* render_frame_host,
55       const GURL& url,
56       ui::PageTransition transition_type) {}
57 
58   // Handles post-navigation tasks in navigation BEFORE the entry has been
59   // committed to the NavigationController.
DidNavigateMainFramePreCommit(bool navigation_is_within_page)60   virtual void DidNavigateMainFramePreCommit(bool navigation_is_within_page) {}
61 
62   // Handles post-navigation tasks in navigation AFTER the entry has been
63   // committed to the NavigationController. Note that the NavigationEntry is
64   // not provided since it may be invalid/changed after being committed. The
65   // NavigationController's last committed entry is for this navigation.
DidNavigateMainFramePostCommit(const LoadCommittedDetails & details,const FrameHostMsg_DidCommitProvisionalLoad_Params & params)66   virtual void DidNavigateMainFramePostCommit(
67       const LoadCommittedDetails& details,
68       const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
DidNavigateAnyFramePostCommit(RenderFrameHostImpl * render_frame_host,const LoadCommittedDetails & details,const FrameHostMsg_DidCommitProvisionalLoad_Params & params)69   virtual void DidNavigateAnyFramePostCommit(
70       RenderFrameHostImpl* render_frame_host,
71       const LoadCommittedDetails& details,
72       const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
73 
SetMainFrameMimeType(const std::string & mime_type)74   virtual void SetMainFrameMimeType(const std::string& mime_type) {}
75   virtual bool CanOverscrollContent() const;
76 
77   // Notification to the Navigator embedder that navigation state has
78   // changed. This method corresponds to
79   // WebContents::NotifyNavigationStateChanged.
NotifyChangedNavigationState(InvalidateTypes changed_flags)80   virtual void NotifyChangedNavigationState(InvalidateTypes changed_flags) {}
81 
82   // Notifies the Navigator embedder that it is beginning to navigate a frame.
AboutToNavigateRenderFrame(RenderFrameHostImpl * render_frame_host)83   virtual void AboutToNavigateRenderFrame(
84       RenderFrameHostImpl* render_frame_host) {}
85 
86   // Notifies the Navigator embedder that a navigation to pending
87   // NavigationEntry has started in the browser process.
DidStartNavigationToPendingEntry(RenderFrameHostImpl * render_frame_host,const GURL & url,NavigationController::ReloadType reload_type)88   virtual void DidStartNavigationToPendingEntry(
89       RenderFrameHostImpl* render_frame_host,
90       const GURL& url,
91       NavigationController::ReloadType reload_type) {}
92 
93   // Opens a URL with the given parameters. See PageNavigator::OpenURL, which
94   // this forwards to.
RequestOpenURL(RenderFrameHostImpl * render_frame_host,const OpenURLParams & params)95   virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
96                               const OpenURLParams& params) {}
97 
98   // Returns whether URLs for aborted browser-initiated navigations should be
99   // preserved in the omnibox.  Defaults to false.
100   virtual bool ShouldPreserveAbortedURLs();
101 };
102 
103 }  // namspace content
104 
105 #endif  // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_DELEGATE_H_
106