navigator.h revision 5c02ac1a9c1b504631c0a3d2b6e737b5d738bae1
1f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// found in the LICENSE file.
4f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
5f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_
6f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_
7f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
8f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "base/memory/ref_counted.h"
9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "content/common/content_export.h"
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "content/public/browser/navigation_controller.h"
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/base/window_open_disposition.h"
12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class GURL;
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct FrameHostMsg_DidCommitProvisionalLoad_Params;
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace base {
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class TimeTicks;
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
20a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace content {
22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class NavigationControllerImpl;
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class NavigationEntryImpl;
25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class NavigatorDelegate;
26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class RenderFrameHostImpl;
27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
28a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Implementations of this interface are responsible for performing navigations
29a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// in a node of the FrameTree. Its lifetime is bound to all FrameTreeNode
30a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// objects that are using it and will be released once all nodes that use it are
31a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// freed. The Navigator is bound to a single frame tree and cannot be used by
32a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// multiple instances of FrameTree.
33f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// TODO(nasko): Move all navigation methods, such as didStartProvisionalLoad
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// from WebContentsImpl to this interface.
35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> {
36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) public:
375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Returns the NavigationController associated with this Navigator.
385c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual NavigationController* GetController();
395c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
40a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // The RenderFrameHostImpl started a provisional load.
41a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                       int parent_routing_id,
43a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                       const GURL& url) {};
44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The RenderFrameHostImpl has failed a provisional load.
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DidFailProvisionalLoadWithError(
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      RenderFrameHostImpl* render_frame_host,
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {};
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The RenderFrameHostImpl has failed to load the document.
515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DidFailLoadWithError(
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      RenderFrameHostImpl* render_frame_host,
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const GURL& url,
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      int error_code,
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::string16& error_description) {}
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The RenderFrameHostImpl processed a redirect during a provisional load.
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  //
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(creis): Remove this method and have the pre-rendering code listen to
605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // WebContentsObserver::DidGetRedirectForResourceRequest instead.
615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // See http://crbug.com/78512.
625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DidRedirectProvisionalLoad(
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      RenderFrameHostImpl* render_frame_host,
645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      int32 page_id,
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const GURL& source_url,
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const GURL& target_url) {}
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The RenderFrameHostImpl has committed a navigation.
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DidNavigate(
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      RenderFrameHostImpl* render_frame_host,
715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Called by the NavigationController to cause the Navigator to navigate
745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // to the current pending entry. The NavigationController should be called
755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The callbacks can be inside of this function, or at some future time.
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  //
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The entry has a PageID of -1 if newly created (corresponding to navigation
795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // to a new URL).
805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  //
815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // If this method returns false, then the navigation is discarded (equivalent
825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // to calling DiscardPendingEntry on the NavigationController).
835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  //
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(nasko): Remove this method from the interface, since Navigator and
855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // NavigationController know about each other. This will be possible once
865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // initialization of Navigator and NavigationController is properly done.
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual bool NavigateToPendingEntry(
885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      RenderFrameHostImpl* render_frame_host,
895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      NavigationController::ReloadType reload_type);
905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual base::TimeTicks GetCurrentLoadStart();
925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // The RenderFrameHostImpl has received a request to open a URL with the
94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // specified |disposition|.
95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
96a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                              const GURL& url,
97a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                              const Referrer& referrer,
98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                              WindowOpenDisposition disposition,
99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                              bool should_replace_current_entry,
100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                              bool user_gesture) {}
101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // The RenderFrameHostImpl wants to transfer the request to a new renderer.
103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // |redirect_chain| contains any redirect URLs (excluding |url|) that happened
104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // before the transfer.
105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual void RequestTransferURL(
106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      RenderFrameHostImpl* render_frame_host,
107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const GURL& url,
108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const std::vector<GURL>& redirect_chain,
109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const Referrer& referrer,
110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      PageTransition page_transition,
111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      WindowOpenDisposition disposition,
112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const GlobalRequestID& transferred_global_request_id,
113a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      bool should_replace_current_entry,
114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      bool user_gesture) {}
115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
116a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) protected:
117f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  friend class base::RefCounted<Navigator>;
118f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual ~Navigator() {}
119f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)};
120f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
121f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}  // namespace content
122f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
123f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#endif  // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_
124