Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / content / browser / frame_host / navigator.h
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_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "content/common/content_export.h"
10 #include "content/public/browser/navigation_controller.h"
11 #include "ui/base/window_open_disposition.h"
12
13 class GURL;
14 struct FrameHostMsg_BeginNavigation_Params;
15 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
16 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
17
18 namespace base {
19 class TimeTicks;
20 }
21
22 namespace content {
23
24 class NavigationControllerImpl;
25 class NavigationEntryImpl;
26 class NavigatorDelegate;
27 class RenderFrameHostImpl;
28 struct NavigationBeforeCommitInfo;
29
30 // Implementations of this interface are responsible for performing navigations
31 // in a node of the FrameTree. Its lifetime is bound to all FrameTreeNode
32 // objects that are using it and will be released once all nodes that use it are
33 // freed. The Navigator is bound to a single frame tree and cannot be used by
34 // multiple instances of FrameTree.
35 // TODO(nasko): Move all navigation methods, such as didStartProvisionalLoad
36 // from WebContentsImpl to this interface.
37 class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> {
38  public:
39   // Returns the NavigationController associated with this Navigator.
40   virtual NavigationController* GetController();
41
42   // Notifications coming from the RenderFrameHosts ----------------------------
43
44   // The RenderFrameHostImpl started a provisional load.
45   virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
46                                        const GURL& url,
47                                        bool is_transition_navigation) {};
48
49   // The RenderFrameHostImpl has failed a provisional load.
50   virtual void DidFailProvisionalLoadWithError(
51       RenderFrameHostImpl* render_frame_host,
52       const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {};
53
54   // The RenderFrameHostImpl has failed to load the document.
55   virtual void DidFailLoadWithError(
56       RenderFrameHostImpl* render_frame_host,
57       const GURL& url,
58       int error_code,
59       const base::string16& error_description) {}
60
61   // The RenderFrameHostImpl has committed a navigation.
62   virtual void DidNavigate(
63       RenderFrameHostImpl* render_frame_host,
64       const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
65
66   // Called by the NavigationController to cause the Navigator to navigate
67   // to the current pending entry. The NavigationController should be called
68   // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
69   // The callbacks can be inside of this function, or at some future time.
70   //
71   // The entry has a PageID of -1 if newly created (corresponding to navigation
72   // to a new URL).
73   //
74   // If this method returns false, then the navigation is discarded (equivalent
75   // to calling DiscardPendingEntry on the NavigationController).
76   //
77   // TODO(nasko): Remove this method from the interface, since Navigator and
78   // NavigationController know about each other. This will be possible once
79   // initialization of Navigator and NavigationController is properly done.
80   virtual bool NavigateToPendingEntry(
81       RenderFrameHostImpl* render_frame_host,
82       NavigationController::ReloadType reload_type);
83
84
85   // Navigation requests -------------------------------------------------------
86
87   virtual base::TimeTicks GetCurrentLoadStart();
88
89   // The RenderFrameHostImpl has received a request to open a URL with the
90   // specified |disposition|.
91   virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
92                               const GURL& url,
93                               const Referrer& referrer,
94                               WindowOpenDisposition disposition,
95                               bool should_replace_current_entry,
96                               bool user_gesture) {}
97
98   // The RenderFrameHostImpl wants to transfer the request to a new renderer.
99   // |redirect_chain| contains any redirect URLs (excluding |url|) that happened
100   // before the transfer.
101   virtual void RequestTransferURL(
102       RenderFrameHostImpl* render_frame_host,
103       const GURL& url,
104       const std::vector<GURL>& redirect_chain,
105       const Referrer& referrer,
106       ui::PageTransition page_transition,
107       WindowOpenDisposition disposition,
108       const GlobalRequestID& transferred_global_request_id,
109       bool should_replace_current_entry,
110       bool user_gesture) {}
111
112   // PlzNavigate
113   // Signal |render_frame_host| that a navigation is ready to commit (the
114   // response to the navigation request has been received).
115   virtual void CommitNavigation(RenderFrameHostImpl* render_frame_host,
116                                 const NavigationBeforeCommitInfo& info) {};
117
118  protected:
119   friend class base::RefCounted<Navigator>;
120   virtual ~Navigator() {}
121 };
122
123 }  // namespace content
124
125 #endif  // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_