[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 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_IMPL_H_ |
| 6 | #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_ |
| 7 | |
clamy | 71a42ec | 2014-10-02 18:43:22 | [diff] [blame] | 8 | #include "base/containers/scoped_ptr_hash_map.h" |
[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
clamy | 9bfeef4 | 2014-09-30 20:50:42 | [diff] [blame] | 10 | #include "base/memory/scoped_ptr.h" |
carlosk | bb156a04 | 2014-09-30 11:55:10 | [diff] [blame] | 11 | #include "base/time/time.h" |
| 12 | #include "base/tuple.h" |
[email protected] | 3691e5cf | 2014-01-22 10:16:20 | [diff] [blame] | 13 | #include "content/browser/frame_host/navigation_controller_impl.h" |
[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 14 | #include "content/browser/frame_host/navigator.h" |
| 15 | #include "content/common/content_export.h" |
carlosk | bb156a04 | 2014-09-30 11:55:10 | [diff] [blame] | 16 | #include "url/gurl.h" |
[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 17 | |
clamy | 9bfeef4 | 2014-09-30 20:50:42 | [diff] [blame] | 18 | class GURL; |
[email protected] | 8a58a8e | 2014-08-19 15:59:08 | [diff] [blame] | 19 | struct FrameMsg_Navigate_Params; |
| 20 | |
[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 21 | namespace content { |
| 22 | |
| 23 | class NavigationControllerImpl; |
| 24 | class NavigatorDelegate; |
clamy | 71a42ec | 2014-10-02 18:43:22 | [diff] [blame] | 25 | class NavigatorTest; |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 26 | struct LoadCommittedDetails; |
clamy | 9bfeef4 | 2014-09-30 20:50:42 | [diff] [blame] | 27 | struct CommitNavigationParams; |
| 28 | struct CommonNavigationParams; |
| 29 | struct RequestNavigationParams; |
[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 30 | |
| 31 | // This class is an implementation of Navigator, responsible for managing |
| 32 | // navigations in regular browser tabs. |
| 33 | class CONTENT_EXPORT NavigatorImpl : public Navigator { |
| 34 | public: |
| 35 | NavigatorImpl(NavigationControllerImpl* navigation_controller, |
| 36 | NavigatorDelegate* delegate); |
| 37 | |
[email protected] | 5291380 | 2013-12-10 05:52:18 | [diff] [blame] | 38 | // Navigator implementation. |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 39 | virtual NavigationController* GetController() override; |
[email protected] | 5291380 | 2013-12-10 05:52:18 | [diff] [blame] | 40 | virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host, |
[email protected] | 0c3c54f | 2014-07-31 01:29:00 | [diff] [blame] | 41 | const GURL& url, |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 42 | bool is_transition_navigation) override; |
[email protected] | 3109fbb7 | 2014-01-06 23:57:15 | [diff] [blame] | 43 | virtual void DidFailProvisionalLoadWithError( |
| 44 | RenderFrameHostImpl* render_frame_host, |
| 45 | const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 46 | override; |
[email protected] | b80624c | 2014-02-09 02:46:55 | [diff] [blame] | 47 | virtual void DidFailLoadWithError( |
| 48 | RenderFrameHostImpl* render_frame_host, |
[email protected] | b80624c | 2014-02-09 02:46:55 | [diff] [blame] | 49 | const GURL& url, |
[email protected] | b80624c | 2014-02-09 02:46:55 | [diff] [blame] | 50 | int error_code, |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 51 | const base::string16& error_description) override; |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 52 | virtual void DidNavigate( |
| 53 | RenderFrameHostImpl* render_frame_host, |
| 54 | const FrameHostMsg_DidCommitProvisionalLoad_Params& |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 55 | input_params) override; |
[email protected] | 3691e5cf | 2014-01-22 10:16:20 | [diff] [blame] | 56 | virtual bool NavigateToPendingEntry( |
| 57 | RenderFrameHostImpl* render_frame_host, |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 58 | NavigationController::ReloadType reload_type) override; |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 59 | virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host, |
| 60 | const GURL& url, |
| 61 | const Referrer& referrer, |
| 62 | WindowOpenDisposition disposition, |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 63 | bool should_replace_current_entry, |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 64 | bool user_gesture) override; |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 65 | virtual void RequestTransferURL( |
| 66 | RenderFrameHostImpl* render_frame_host, |
| 67 | const GURL& url, |
| 68 | const std::vector<GURL>& redirect_chain, |
| 69 | const Referrer& referrer, |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 70 | ui::PageTransition page_transition, |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 71 | WindowOpenDisposition disposition, |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 72 | const GlobalRequestID& transferred_global_request_id, |
| 73 | bool should_replace_current_entry, |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 74 | bool user_gesture) override; |
clamy | 71a42ec | 2014-10-02 18:43:22 | [diff] [blame] | 75 | virtual void OnBeginNavigation( |
| 76 | FrameTreeNode* frame_tree_node, |
| 77 | const FrameHostMsg_BeginNavigation_Params& params, |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 78 | const CommonNavigationParams& common_params) override; |
davidben | a5496d6 | 2014-10-07 18:52:04 | [diff] [blame] | 79 | virtual void CommitNavigation(FrameTreeNode* frame_tree_node, |
| 80 | ResourceResponse* response, |
| 81 | scoped_ptr<StreamHandle> body) override; |
carlosk | bb156a04 | 2014-09-30 11:55:10 | [diff] [blame] | 82 | virtual void LogResourceRequestTime( |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 83 | base::TimeTicks timestamp, const GURL& url) override; |
carlosk | a045c8c | 2014-10-14 10:43:18 | [diff] [blame^] | 84 | virtual void LogBeforeUnloadTime( |
| 85 | const base::TimeTicks& renderer_before_unload_start_time, |
| 86 | const base::TimeTicks& renderer_before_unload_end_time) override; |
mohan.reddy | 383f53b3 | 2014-10-07 05:56:28 | [diff] [blame] | 87 | virtual void CancelNavigation(FrameTreeNode* frame_tree_node) override; |
carlosk | bb156a04 | 2014-09-30 11:55:10 | [diff] [blame] | 88 | |
[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 89 | private: |
carlosk | a045c8c | 2014-10-14 10:43:18 | [diff] [blame^] | 90 | // Holds data used to track browser side navigation metrics. |
| 91 | struct NavigationMetricsData; |
| 92 | |
clamy | 71a42ec | 2014-10-02 18:43:22 | [diff] [blame] | 93 | friend class NavigatorTest; |
carlosk | bb156a04 | 2014-09-30 11:55:10 | [diff] [blame] | 94 | virtual ~NavigatorImpl(); |
[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 95 | |
[email protected] | 0449c3f | 2014-02-28 20:31:22 | [diff] [blame] | 96 | // Navigates to the given entry, which must be the pending entry. Private |
| 97 | // because all callers should use NavigateToPendingEntry. |
| 98 | bool NavigateToEntry( |
| 99 | RenderFrameHostImpl* render_frame_host, |
| 100 | const NavigationEntryImpl& entry, |
| 101 | NavigationController::ReloadType reload_type); |
| 102 | |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 103 | bool ShouldAssignSiteForURL(const GURL& url); |
| 104 | |
[email protected] | 8a58a8e | 2014-08-19 15:59:08 | [diff] [blame] | 105 | void CheckWebUIRendererDoesNotDisplayNormalURL( |
| 106 | RenderFrameHostImpl* render_frame_host, |
| 107 | const GURL& url); |
| 108 | |
clamy | 71a42ec | 2014-10-02 18:43:22 | [diff] [blame] | 109 | // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to |
| 110 | // navigate. If no live renderer is present, then the navigation request will |
| 111 | // be sent directly to the ResourceDispatcherHost. |
| 112 | bool RequestNavigation(FrameTreeNode* frame_tree_node, |
| 113 | const NavigationEntryImpl& entry, |
| 114 | NavigationController::ReloadType reload_type, |
| 115 | base::TimeTicks navigation_start); |
| 116 | |
carlosk | a045c8c | 2014-10-14 10:43:18 | [diff] [blame^] | 117 | void RecordNavigationMetrics( |
| 118 | const LoadCommittedDetails& details, |
| 119 | const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 120 | SiteInstance* site_instance); |
| 121 | |
[email protected] | 5291380 | 2013-12-10 05:52:18 | [diff] [blame] | 122 | // The NavigationController that will keep track of session history for all |
| 123 | // RenderFrameHost objects using this NavigatorImpl. |
| 124 | // TODO(nasko): Move ownership of the NavigationController from |
| 125 | // WebContentsImpl to this class. |
| 126 | NavigationControllerImpl* controller_; |
| 127 | |
| 128 | // Used to notify the object embedding this Navigator about navigation |
| 129 | // events. Can be NULL in tests. |
| 130 | NavigatorDelegate* delegate_; |
| 131 | |
carlosk | a045c8c | 2014-10-14 10:43:18 | [diff] [blame^] | 132 | scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_; |
carlosk | bb156a04 | 2014-09-30 11:55:10 | [diff] [blame] | 133 | |
clamy | 71a42ec | 2014-10-02 18:43:22 | [diff] [blame] | 134 | // PlzNavigate: used to track the various ongoing NavigationRequests in the |
| 135 | // different FrameTreeNodes, based on the frame_tree_node_id. |
| 136 | typedef base::ScopedPtrHashMap<int64, NavigationRequest> NavigationRequestMap; |
| 137 | NavigationRequestMap navigation_request_map_; |
| 138 | |
[email protected] | 6ea6bdf | 2013-12-06 13:35:01 | [diff] [blame] | 139 | DISALLOW_COPY_AND_ASSIGN(NavigatorImpl); |
| 140 | }; |
| 141 | |
| 142 | } // namespace content |
| 143 | |
| 144 | #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_ |