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