[email protected] | d4a8ca48 | 2013-10-30 21:06:40 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | d4a8ca48 | 2013-10-30 21:06:40 | [diff] [blame] | 5 | #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_ |
| 6 | #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_ |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 7 | |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
avi | f16f85a7 | 2015-11-13 18:25:03 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
[email protected] | c5b88d8 | 2012-10-06 17:03:33 | [diff] [blame] | 13 | #include "base/callback.h" |
[email protected] | 3c15fcbc | 2011-12-29 16:43:17 | [diff] [blame] | 14 | #include "base/compiler_specific.h" |
[email protected] | c5b88d8 | 2012-10-06 17:03:33 | [diff] [blame] | 15 | #include "base/gtest_prod_util.h" |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 16 | #include "base/macros.h" |
Lukasz Anforowicz | 63f3b943 | 2019-05-30 05:42:58 | [diff] [blame] | 17 | #include "base/optional.h" |
[email protected] | a43858f | 2013-06-28 15:18:37 | [diff] [blame] | 18 | #include "base/time/time.h" |
| 19 | #include "build/build_config.h" |
Arthur Sonzogni | 620cec6 | 2018-12-13 13:08:57 | [diff] [blame] | 20 | #include "content/browser/frame_host/back_forward_cache.h" |
[email protected] | d4a8ca48 | 2013-10-30 21:06:40 | [diff] [blame] | 21 | #include "content/browser/frame_host/navigation_controller_delegate.h" |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 22 | #include "content/browser/frame_host/navigation_entry_impl.h" |
[email protected] | 74b962a | 2011-06-03 21:22:54 | [diff] [blame] | 23 | #include "content/browser/ssl/ssl_manager.h" |
[email protected] | 71fde35 | 2011-12-29 03:29:56 | [diff] [blame] | 24 | #include "content/public/browser/navigation_controller.h" |
[email protected] | e6e646d | 2011-12-01 00:50:11 | [diff] [blame] | 25 | #include "content/public/browser/navigation_type.h" |
toyoshim | 0df1d3a | 2016-09-09 09:52:48 | [diff] [blame] | 26 | #include "content/public/browser/reload_type.h" |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 27 | |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 28 | struct FrameHostMsg_DidCommitProvisionalLoad_Params; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 29 | |
[email protected] | 8286f51a | 2011-05-31 17:39:13 | [diff] [blame] | 30 | namespace content { |
Owen Min | 45db3a5d | 2019-07-31 20:13:29 | [diff] [blame] | 31 | enum class WasActivatedOption; |
creis | 3cdc3b0 | 2015-05-29 23:00:47 | [diff] [blame] | 32 | class FrameTreeNode; |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 33 | class RenderFrameHostImpl; |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 34 | class SiteInstance; |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 35 | struct LoadCommittedDetails; |
[email protected] | 8286f51a | 2011-05-31 17:39:13 | [diff] [blame] | 36 | |
Nico Weber | 43ddd7a3 | 2017-08-15 19:19:27 | [diff] [blame] | 37 | class CONTENT_EXPORT NavigationControllerImpl : public NavigationController { |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 38 | public: |
[email protected] | adbfb8df | 2012-02-24 01:19:43 | [diff] [blame] | 39 | NavigationControllerImpl( |
[email protected] | ec6c05f | 2013-10-23 18:41:57 | [diff] [blame] | 40 | NavigationControllerDelegate* delegate, |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 41 | BrowserContext* browser_context); |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 42 | ~NavigationControllerImpl() override; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 43 | |
[email protected] | 71fde35 | 2011-12-29 03:29:56 | [diff] [blame] | 44 | // NavigationController implementation: |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 45 | WebContents* GetWebContents() override; |
| 46 | BrowserContext* GetBrowserContext() override; |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 47 | void Restore(int selected_navigation, |
| 48 | RestoreType type, |
dcheng | 9bfa516 | 2016-04-09 01:00:57 | [diff] [blame] | 49 | std::vector<std::unique_ptr<NavigationEntry>>* entries) override; |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 50 | NavigationEntryImpl* GetActiveEntry() override; |
| 51 | NavigationEntryImpl* GetVisibleEntry() override; |
| 52 | int GetCurrentEntryIndex() override; |
| 53 | NavigationEntryImpl* GetLastCommittedEntry() override; |
| 54 | int GetLastCommittedEntryIndex() override; |
| 55 | bool CanViewSource() override; |
| 56 | int GetEntryCount() override; |
| 57 | NavigationEntryImpl* GetEntryAtIndex(int index) override; |
| 58 | NavigationEntryImpl* GetEntryAtOffset(int offset) override; |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 59 | void DiscardNonCommittedEntries() override; |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 60 | NavigationEntryImpl* GetPendingEntry() override; |
| 61 | int GetPendingEntryIndex() override; |
| 62 | NavigationEntryImpl* GetTransientEntry() override; |
dcheng | 9bfa516 | 2016-04-09 01:00:57 | [diff] [blame] | 63 | void SetTransientEntry(std::unique_ptr<NavigationEntry> entry) override; |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 64 | void LoadURL(const GURL& url, |
| 65 | const Referrer& referrer, |
| 66 | ui::PageTransition type, |
| 67 | const std::string& extra_headers) override; |
| 68 | void LoadURLWithParams(const LoadURLParams& params) override; |
| 69 | void LoadIfNecessary() override; |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 70 | bool CanGoBack() override; |
| 71 | bool CanGoForward() override; |
| 72 | bool CanGoToOffset(int offset) override; |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 73 | void GoBack() override; |
| 74 | void GoForward() override; |
| 75 | void GoToIndex(int index) override; |
| 76 | void GoToOffset(int offset) override; |
| 77 | bool RemoveEntryAtIndex(int index) override; |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 78 | const SessionStorageNamespaceMap& GetSessionStorageNamespaceMap() override; |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 79 | SessionStorageNamespace* GetDefaultSessionStorageNamespace() override; |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 80 | bool NeedsReload() override; |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 81 | void SetNeedsReload() override; |
| 82 | void CancelPendingReload() override; |
| 83 | void ContinuePendingReload() override; |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 84 | bool IsInitialNavigation() override; |
| 85 | bool IsInitialBlankNavigation() override; |
toyoshim | 6142d96f | 2016-12-19 09:07:25 | [diff] [blame] | 86 | void Reload(ReloadType reload_type, bool check_for_repost) override; |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 87 | void NotifyEntryChanged(NavigationEntry* entry) override; |
| 88 | void CopyStateFrom(NavigationController* source, bool needs_reload) override; |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 89 | void CopyStateFromAndPrune(NavigationController* source, |
| 90 | bool replace_entry) override; |
| 91 | bool CanPruneAllButLastCommitted() override; |
| 92 | void PruneAllButLastCommitted() override; |
Christian Dullweber | 1af31e6 | 2018-02-22 11:49:48 | [diff] [blame] | 93 | void DeleteNavigationEntries( |
| 94 | const DeletionPredicate& deletionPredicate) override; |
Shivani Sharma | 883f5f3 | 2019-02-12 18:20:01 | [diff] [blame] | 95 | bool IsEntryMarkedToBeSkipped(int index) override; |
Christian Dullweber | 1af31e6 | 2018-02-22 11:49:48 | [diff] [blame] | 96 | |
clamy | 987a375 | 2018-05-03 17:36:26 | [diff] [blame] | 97 | // Starts a navigation in a newly created subframe as part of a history |
| 98 | // navigation. Returns true if the history navigation could start, false |
| 99 | // otherwise. If this returns false, the caller should do a regular |
Charlie Reis | 4d58b97 | 2019-07-15 19:32:40 | [diff] [blame] | 100 | // navigation to the default src URL for the frame instead. |
clamy | 987a375 | 2018-05-03 17:36:26 | [diff] [blame] | 101 | bool StartHistoryNavigationInNewSubframe( |
| 102 | RenderFrameHostImpl* render_frame_host, |
Arthur Hemery | 06173ce | 2019-05-29 12:11:41 | [diff] [blame] | 103 | mojom::NavigationClientAssociatedPtrInfo* navigation_client); |
clamy | 987a375 | 2018-05-03 17:36:26 | [diff] [blame] | 104 | |
Dave Tapuska | 8bfd84c | 2019-03-26 20:47:16 | [diff] [blame] | 105 | // Navigates to a specified offset from the "current entry". Currently records |
| 106 | // a histogram indicating whether the session history navigation would only |
| 107 | // affect frames within the subtree of |sandbox_frame_tree_node_id|, which |
| 108 | // initiated the navigation. |
| 109 | void GoToOffsetInSandboxedFrame(int offset, int sandbox_frame_tree_node_id); |
| 110 | |
clamy | 987a375 | 2018-05-03 17:36:26 | [diff] [blame] | 111 | // Called when a document requests a navigation through a |
| 112 | // RenderFrameProxyHost. |
| 113 | void NavigateFromFrameProxy( |
| 114 | RenderFrameHostImpl* render_frame_host, |
| 115 | const GURL& url, |
Lukasz Anforowicz | 63f3b943 | 2019-05-30 05:42:58 | [diff] [blame] | 116 | const base::Optional<url::Origin>& initiator_origin, |
clamy | 987a375 | 2018-05-03 17:36:26 | [diff] [blame] | 117 | bool is_renderer_initiated, |
| 118 | SiteInstance* source_site_instance, |
| 119 | const Referrer& referrer, |
| 120 | ui::PageTransition page_transition, |
| 121 | bool should_replace_current_entry, |
Charlie Harrison | 8c113a3 | 2019-01-07 16:08:29 | [diff] [blame] | 122 | NavigationDownloadPolicy download_policy, |
clamy | 987a375 | 2018-05-03 17:36:26 | [diff] [blame] | 123 | const std::string& method, |
| 124 | scoped_refptr<network::ResourceRequestBody> post_body, |
Marijn Kruisselbrink | 7a0d5e18 | 2018-05-24 22:55:09 | [diff] [blame] | 125 | const std::string& extra_headers, |
| 126 | scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory); |
clamy | 987a375 | 2018-05-03 17:36:26 | [diff] [blame] | 127 | |
[email protected] | aa62afd | 2014-04-22 19:22:46 | [diff] [blame] | 128 | // Whether this is the initial navigation in an unmodified new tab. In this |
| 129 | // case, we know there is no content displayed in the page. |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 130 | bool IsUnmodifiedBlankTab(); |
[email protected] | aa62afd | 2014-04-22 19:22:46 | [diff] [blame] | 131 | |
[email protected] | fdac6ade | 2013-07-20 01:06:30 | [diff] [blame] | 132 | // The session storage namespace that all child RenderViews belonging to |
| 133 | // |instance| should use. |
| 134 | SessionStorageNamespace* GetSessionStorageNamespace( |
| 135 | SiteInstance* instance); |
| 136 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 137 | // Returns the index of the specified entry, or -1 if entry is not contained |
| 138 | // in this NavigationController. |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 139 | int GetIndexOfEntry(const NavigationEntryImpl* entry) const; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 140 | |
avi | 7c6f35e | 2015-05-08 17:52:38 | [diff] [blame] | 141 | // Return the index of the entry with the given unique id, or -1 if not found. |
| 142 | int GetEntryIndexWithUniqueID(int nav_entry_id) const; |
| 143 | |
avi | 254eff0 | 2015-07-01 08:27:58 | [diff] [blame] | 144 | // Return the entry with the given unique id, or null if not found. |
| 145 | NavigationEntryImpl* GetEntryWithUniqueID(int nav_entry_id) const; |
| 146 | |
[email protected] | ec6c05f | 2013-10-23 18:41:57 | [diff] [blame] | 147 | NavigationControllerDelegate* delegate() const { |
| 148 | return delegate_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 149 | } |
| 150 | |
Alex Moshchuk | 7b4f065 | 2019-05-30 18:54:41 | [diff] [blame] | 151 | // These values are persisted to logs. Entries should not be renumbered and |
| 152 | // numeric values should never be reused. |
| 153 | enum class NeedsReloadType { |
| 154 | kRequestedByClient = 0, |
| 155 | kRestoreSession = 1, |
| 156 | kCopyStateFrom = 2, |
| 157 | kCrashedSubframe = 3, |
| 158 | kMaxValue = kCrashedSubframe |
| 159 | }; |
| 160 | |
| 161 | // Request a reload to happen when activated. Same as the public |
| 162 | // SetNeedsReload(), but takes in a |type| which specifies why the reload is |
| 163 | // being requested. |
| 164 | void SetNeedsReload(NeedsReloadType type); |
| 165 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 166 | // For use by WebContentsImpl ------------------------------------------------ |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 167 | |
[email protected] | 59167c2 | 2013-06-03 18:07:32 | [diff] [blame] | 168 | // Allow renderer-initiated navigations to create a pending entry when the |
| 169 | // provisional load starts. |
dcheng | 9bfa516 | 2016-04-09 01:00:57 | [diff] [blame] | 170 | void SetPendingEntry(std::unique_ptr<NavigationEntryImpl> entry); |
[email protected] | 59167c2 | 2013-06-03 18:07:32 | [diff] [blame] | 171 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 172 | // Handles updating the navigation state after the renderer has navigated. |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 173 | // This is used by the WebContentsImpl. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 174 | // |
| 175 | // If a new entry is created, it will return true and will have filled the |
| 176 | // given details structure and broadcast the NOTIFY_NAV_ENTRY_COMMITTED |
| 177 | // notification. The caller can then use the details without worrying about |
| 178 | // listening for the notification. |
| 179 | // |
| 180 | // In the case that nothing has changed, the details structure is undefined |
| 181 | // and it will return false. |
shivanisha | 41f04c5 | 2018-12-12 15:52:05 | [diff] [blame] | 182 | // |
Shivani Sharma | ffb32b8 | 2019-04-09 16:58:47 | [diff] [blame] | 183 | // |previous_document_was_activated| is true if the previous document had user |
shivanisha | 41f04c5 | 2018-12-12 15:52:05 | [diff] [blame] | 184 | // interaction. This is used for a new renderer-initiated navigation to decide |
| 185 | // if the page that initiated the navigation should be skipped on |
| 186 | // back/forward button. |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 187 | bool RendererDidNavigate( |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 188 | RenderFrameHostImpl* rfh, |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 189 | const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
peary2 | 1b0f797b | 2016-09-28 17:28:33 | [diff] [blame] | 190 | LoadCommittedDetails* details, |
Eugene But | 712f03d | 2018-05-22 16:03:44 | [diff] [blame] | 191 | bool is_same_document_navigation, |
Shivani Sharma | ffb32b8 | 2019-04-09 16:58:47 | [diff] [blame] | 192 | bool previous_document_was_activated, |
Camille Lamy | 10aafcd3 | 2018-12-05 15:48:13 | [diff] [blame] | 193 | NavigationRequest* navigation_request); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 194 | |
[email protected] | b172aee | 2012-04-10 17:05:26 | [diff] [blame] | 195 | // Notifies us that we just became active. This is used by the WebContentsImpl |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 196 | // so that we know to load URLs that were pending as "lazy" loads. |
| 197 | void SetActive(bool is_active); |
| 198 | |
Eugene But | 7cc259d | 2017-10-09 23:52:49 | [diff] [blame] | 199 | // Returns true if the given URL would be a same-document navigation (e.g., if |
| 200 | // the reference fragment is different, or after a pushState) from the last |
creis | f164daa | 2016-06-07 00:17:05 | [diff] [blame] | 201 | // committed URL in the specified frame. If there is no last committed entry, |
Eugene But | 7cc259d | 2017-10-09 23:52:49 | [diff] [blame] | 202 | // then nothing will be same-document. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 203 | // |
[email protected] | ce760d74 | 2012-08-30 22:31:10 | [diff] [blame] | 204 | // Special note: if the URLs are the same, it does NOT automatically count as |
Eugene But | 7cc259d | 2017-10-09 23:52:49 | [diff] [blame] | 205 | // a same-document navigation. Neither does an input URL that has no ref, even |
| 206 | // if the rest is the same. This may seem weird, but when we're considering |
[email protected] | ce760d74 | 2012-08-30 22:31:10 | [diff] [blame] | 207 | // whether a navigation happened without loading anything, the same URL could |
| 208 | // be a reload, while only a different ref would be in-page (pages can't clear |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 209 | // refs without reload, only change to "#" which we don't count as empty). |
[email protected] | 8d5cb21 | 2014-06-04 09:00:39 | [diff] [blame] | 210 | // |
[email protected] | ce760d74 | 2012-08-30 22:31:10 | [diff] [blame] | 211 | // The situation is made murkier by history.replaceState(), which could |
Eugene But | 7cc259d | 2017-10-09 23:52:49 | [diff] [blame] | 212 | // provide the same URL as part of a same-document navigation, not a reload. |
| 213 | // So we need to let the (untrustworthy) renderer resolve the ambiguity, but |
creis | f164daa | 2016-06-07 00:17:05 | [diff] [blame] | 214 | // only when the URLs are on the same origin. We rely on |origin|, which |
| 215 | // matters in cases like about:blank that otherwise look cross-origin. |
Eugene But | 7cc259d | 2017-10-09 23:52:49 | [diff] [blame] | 216 | bool IsURLSameDocumentNavigation(const GURL& url, |
| 217 | const url::Origin& origin, |
| 218 | bool renderer_says_same_document, |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 219 | RenderFrameHost* rfh); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 220 | |
[email protected] | fdac6ade | 2013-07-20 01:06:30 | [diff] [blame] | 221 | // Sets the SessionStorageNamespace for the given |partition_id|. This is |
| 222 | // used during initialization of a new NavigationController to allow |
| 223 | // pre-population of the SessionStorageNamespace objects. Session restore, |
| 224 | // prerendering, and the implementaion of window.open() are the primary users |
| 225 | // of this API. |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 226 | // |
| 227 | // Calling this function when a SessionStorageNamespace has already been |
[email protected] | fdac6ade | 2013-07-20 01:06:30 | [diff] [blame] | 228 | // associated with a |partition_id| will CHECK() fail. |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 229 | void SetSessionStorageNamespace( |
[email protected] | fdac6ade | 2013-07-20 01:06:30 | [diff] [blame] | 230 | const std::string& partition_id, |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 231 | SessionStorageNamespace* session_storage_namespace); |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 232 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 233 | // Random data --------------------------------------------------------------- |
| 234 | |
[email protected] | 330614de | 2012-02-13 17:07:18 | [diff] [blame] | 235 | SSLManager* ssl_manager() { return &ssl_manager_; } |
| 236 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 237 | // Maximum number of entries before we start removing entries from the front. |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 238 | static void set_max_entry_count_for_testing(size_t max_entry_count) { |
[email protected] | 9b51970d | 2011-12-09 23:10:23 | [diff] [blame] | 239 | max_entry_count_for_testing_ = max_entry_count; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 240 | } |
[email protected] | 9b51970d | 2011-12-09 23:10:23 | [diff] [blame] | 241 | static size_t max_entry_count(); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 242 | |
[email protected] | c5b88d8 | 2012-10-06 17:03:33 | [diff] [blame] | 243 | void SetGetTimestampCallbackForTest( |
| 244 | const base::Callback<base::Time()>& get_timestamp_callback); |
| 245 | |
avi | 45a7253 | 2015-04-07 21:01:45 | [diff] [blame] | 246 | // Discards only the pending entry. |was_failure| should be set if the pending |
| 247 | // entry is being discarded because it failed to load. |
| 248 | void DiscardPendingEntry(bool was_failure); |
[email protected] | ec6c05f | 2013-10-23 18:41:57 | [diff] [blame] | 249 | |
ananta | 3bdd8ae | 2016-12-22 17:11:55 | [diff] [blame] | 250 | // Sets a flag on the pending NavigationEntryImpl instance if any that the |
| 251 | // navigation failed due to an SSL error. |
| 252 | void SetPendingNavigationSSLError(bool error); |
| 253 | |
Arthur Sonzogni | 620cec6 | 2018-12-13 13:08:57 | [diff] [blame] | 254 | BackForwardCache& back_forward_cache() { return back_forward_cache_; } |
| 255 | |
Camille Lamy | 5193caa | 2018-10-12 11:59:42 | [diff] [blame] | 256 | // Returns true if the string corresponds to a valid data URL, false |
| 257 | // otherwise. |
| 258 | #if defined(OS_ANDROID) |
| 259 | static bool ValidateDataURLAsString( |
| 260 | const scoped_refptr<const base::RefCountedString>& data_url_as_string); |
| 261 | #endif |
| 262 | |
Shivani Sharma | 19487703 | 2019-03-07 17:52:47 | [diff] [blame] | 263 | // Invoked when a user activation occurs within the page, so that relevant |
| 264 | // entries can be updated as needed. |
| 265 | void NotifyUserActivation(); |
| 266 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 267 | private: |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 268 | friend class RestoreHelper; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 269 | |
[email protected] | c5b88d8 | 2012-10-06 17:03:33 | [diff] [blame] | 270 | FRIEND_TEST_ALL_PREFIXES(TimeSmoother, Basic); |
| 271 | FRIEND_TEST_ALL_PREFIXES(TimeSmoother, SingleDuplicate); |
| 272 | FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ManyDuplicates); |
| 273 | FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ClockBackwardsJump); |
| 274 | |
[email protected] | c5b88d8 | 2012-10-06 17:03:33 | [diff] [blame] | 275 | // Helper class to smooth out runs of duplicate timestamps while still |
| 276 | // allowing time to jump backwards. |
[email protected] | c5b88d8 | 2012-10-06 17:03:33 | [diff] [blame] | 277 | class CONTENT_EXPORT TimeSmoother { |
| 278 | public: |
| 279 | // Returns |t| with possibly some time added on. |
| 280 | base::Time GetSmoothedTime(base::Time t); |
| 281 | |
| 282 | private: |
| 283 | // |low_water_mark_| is the first time in a sequence of adjusted |
| 284 | // times and |high_water_mark_| is the last. |
| 285 | base::Time low_water_mark_; |
| 286 | base::Time high_water_mark_; |
| 287 | }; |
| 288 | |
Dave Tapuska | 8bfd84c | 2019-03-26 20:47:16 | [diff] [blame] | 289 | // Navigates in session history to the given index. If |
| 290 | // |sandbox_frame_tree_node_id| is valid, then this request came |
| 291 | // from a sandboxed iframe with top level navigation disallowed. This |
| 292 | // is currently only used for tracking metrics. |
| 293 | void GoToIndex(int index, int sandbox_frame_tree_node_id); |
| 294 | |
clamy | 3cb9bea9 | 2018-07-10 12:42:02 | [diff] [blame] | 295 | // Starts a navigation to an already existing pending NavigationEntry. |
Dave Tapuska | 8bfd84c | 2019-03-26 20:47:16 | [diff] [blame] | 296 | // Currently records a histogram indicating whether the session history |
| 297 | // navigation would only affect frames within the subtree of |
| 298 | // |sandbox_frame_tree_node_id|, which initiated the navigation. |
| 299 | void NavigateToExistingPendingEntry(ReloadType reload_type, |
| 300 | int sandboxed_source_frame_tree_node_id); |
creis | 4e2ecb7 | 2015-06-20 00:46:30 | [diff] [blame] | 301 | |
clamy | 3cb9bea9 | 2018-07-10 12:42:02 | [diff] [blame] | 302 | // Recursively identifies which frames need to be navigated for a navigation |
| 303 | // to |pending_entry_|, starting at |frame| and exploring its children. |
| 304 | // |same_document_loads| and |different_document_loads| will be filled with |
| 305 | // the NavigationRequests needed to navigate to |pending_entry_|. |
| 306 | void FindFramesToNavigate( |
| 307 | FrameTreeNode* frame, |
| 308 | ReloadType reload_type, |
| 309 | std::vector<std::unique_ptr<NavigationRequest>>* same_document_loads, |
| 310 | std::vector<std::unique_ptr<NavigationRequest>>* |
| 311 | different_document_loads); |
creis | 4e2ecb7 | 2015-06-20 00:46:30 | [diff] [blame] | 312 | |
clamy | 21718cc2 | 2018-06-13 13:34:24 | [diff] [blame] | 313 | // Starts a new navigation based on |load_params|, that doesn't correspond to |
| 314 | // an exisiting NavigationEntry. |
| 315 | void NavigateWithoutEntry(const LoadURLParams& load_params); |
| 316 | |
clamy | ea99ea1 | 2018-05-28 13:54:23 | [diff] [blame] | 317 | // Handles a navigation to a renderer-debug URL. |
| 318 | void HandleRendererDebugURL(FrameTreeNode* frame_tree_node, const GURL& url); |
| 319 | |
clamy | 21718cc2 | 2018-06-13 13:34:24 | [diff] [blame] | 320 | // Creates and returns a NavigationEntry based on |load_params| for a |
| 321 | // navigation in |node|. |
Camille Lamy | 5193caa | 2018-10-12 11:59:42 | [diff] [blame] | 322 | // |override_user_agent|, |should_replace_current_entry| and |
| 323 | // |has_user_gesture| will override the values from |load_params|. The same |
| 324 | // values should be passed to CreateNavigationRequestFromLoadParams. |
clamy | 21718cc2 | 2018-06-13 13:34:24 | [diff] [blame] | 325 | std::unique_ptr<NavigationEntryImpl> CreateNavigationEntryFromLoadParams( |
| 326 | FrameTreeNode* node, |
Camille Lamy | 5193caa | 2018-10-12 11:59:42 | [diff] [blame] | 327 | const LoadURLParams& load_params, |
| 328 | bool override_user_agent, |
| 329 | bool should_replace_current_entry, |
| 330 | bool has_user_gesture); |
clamy | 21718cc2 | 2018-06-13 13:34:24 | [diff] [blame] | 331 | |
Camille Lamy | 5193caa | 2018-10-12 11:59:42 | [diff] [blame] | 332 | // Creates and returns a NavigationRequest based on |load_params| for a |
| 333 | // new navigation in |node|. |
clamy | ea99ea1 | 2018-05-28 13:54:23 | [diff] [blame] | 334 | // Will return nullptr if the parameters are invalid and the navigation cannot |
| 335 | // start. |
Camille Lamy | 5193caa | 2018-10-12 11:59:42 | [diff] [blame] | 336 | // |override_user_agent|, |should_replace_current_entry| and |
| 337 | // |has_user_gesture| will override the values from |load_params|. The same |
| 338 | // values should be passed to CreateNavigationEntryFromLoadParams. |
| 339 | // TODO(clamy): Remove the dependency on NavigationEntry and |
| 340 | // FrameNavigationEntry. |
| 341 | std::unique_ptr<NavigationRequest> CreateNavigationRequestFromLoadParams( |
| 342 | FrameTreeNode* node, |
| 343 | const LoadURLParams& load_params, |
| 344 | bool override_user_agent, |
| 345 | bool should_replace_current_entry, |
| 346 | bool has_user_gesture, |
Charlie Harrison | 8c113a3 | 2019-01-07 16:08:29 | [diff] [blame] | 347 | NavigationDownloadPolicy download_policy, |
Camille Lamy | 5193caa | 2018-10-12 11:59:42 | [diff] [blame] | 348 | ReloadType reload_type, |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 349 | NavigationEntryImpl* entry, |
Camille Lamy | 5193caa | 2018-10-12 11:59:42 | [diff] [blame] | 350 | FrameNavigationEntry* frame_entry); |
| 351 | |
| 352 | // Creates and returns a NavigationRequest for a navigation to |entry|. Will |
| 353 | // return nullptr if the parameters are invalid and the navigation cannot |
| 354 | // start. |
| 355 | // TODO(clamy): Ensure this is only called for navigations to existing |
| 356 | // NavigationEntries. |
| 357 | std::unique_ptr<NavigationRequest> CreateNavigationRequestFromEntry( |
clamy | ea99ea1 | 2018-05-28 13:54:23 | [diff] [blame] | 358 | FrameTreeNode* frame_tree_node, |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 359 | NavigationEntryImpl* entry, |
clamy | ea99ea1 | 2018-05-28 13:54:23 | [diff] [blame] | 360 | FrameNavigationEntry* frame_entry, |
| 361 | ReloadType reload_type, |
| 362 | bool is_same_document_history_load, |
Arthur Hemery | bee4a75 | 2019-05-29 10:50:55 | [diff] [blame] | 363 | bool is_history_navigation_in_new_child_frame); |
clamy | ea99ea1 | 2018-05-28 13:54:23 | [diff] [blame] | 364 | |
creis | b4dc933 | 2016-03-14 21:39:19 | [diff] [blame] | 365 | // Returns whether there is a pending NavigationEntry whose unique ID matches |
| 366 | // the given NavigationHandle's pending_nav_entry_id. |
| 367 | bool PendingEntryMatchesHandle(NavigationHandleImpl* handle) const; |
| 368 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 369 | // Classifies the given renderer navigation (see the NavigationType enum). |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 370 | NavigationType ClassifyNavigation( |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 371 | RenderFrameHostImpl* rfh, |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 372 | const FrameHostMsg_DidCommitProvisionalLoad_Params& params); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 373 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 374 | // Handlers for the different types of navigation types. They will actually |
| 375 | // handle the navigations corresponding to the different NavClasses above. |
| 376 | // They will NOT broadcast the commit notification, that should be handled by |
| 377 | // the caller. |
| 378 | // |
| 379 | // RendererDidNavigateAutoSubframe is special, it may not actually change |
| 380 | // anything if some random subframe is loaded. It will return true if anything |
| 381 | // changed, or false if not. |
| 382 | // |
creis | 1857908a | 2016-02-25 20:31:52 | [diff] [blame] | 383 | // The NewPage and NewSubframe functions take in |replace_entry| to pass to |
| 384 | // InsertOrReplaceEntry, in case the newly created NavigationEntry is meant to |
| 385 | // replace the current one (e.g., for location.replace or successful loads |
| 386 | // after net errors), in contrast to updating a NavigationEntry in place |
| 387 | // (e.g., for history.replaceState). |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 388 | void RendererDidNavigateToNewPage( |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 389 | RenderFrameHostImpl* rfh, |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 390 | const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
eugenebut | 604866f | 2017-05-10 21:35:36 | [diff] [blame] | 391 | bool is_same_document, |
clamy | 3bf35e3c | 2016-11-10 15:59:44 | [diff] [blame] | 392 | bool replace_entry, |
Shivani Sharma | ffb32b8 | 2019-04-09 16:58:47 | [diff] [blame] | 393 | bool previous_document_was_activated, |
clamy | 3bf35e3c | 2016-11-10 15:59:44 | [diff] [blame] | 394 | NavigationHandleImpl* handle); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 395 | void RendererDidNavigateToExistingPage( |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 396 | RenderFrameHostImpl* rfh, |
jam | 0576b13 | 2016-09-07 05:13:10 | [diff] [blame] | 397 | const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
eugenebut | 604866f | 2017-05-10 21:35:36 | [diff] [blame] | 398 | bool is_same_document, |
jam | 48cea908 | 2017-02-15 06:13:29 | [diff] [blame] | 399 | bool was_restored, |
Peter Boström | d759213 | 2019-01-30 04:50:31 | [diff] [blame] | 400 | NavigationHandleImpl* handle, |
| 401 | bool keep_pending_entry); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 402 | void RendererDidNavigateToSamePage( |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 403 | RenderFrameHostImpl* rfh, |
clamy | 3bf35e3c | 2016-11-10 15:59:44 | [diff] [blame] | 404 | const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
Joe DeBlasio | 531e3d9 | 2018-11-06 06:26:12 | [diff] [blame] | 405 | bool is_same_document, |
clamy | 3bf35e3c | 2016-11-10 15:59:44 | [diff] [blame] | 406 | NavigationHandleImpl* handle); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 407 | void RendererDidNavigateNewSubframe( |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 408 | RenderFrameHostImpl* rfh, |
creis | 1857908a | 2016-02-25 20:31:52 | [diff] [blame] | 409 | const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
eugenebut | 604866f | 2017-05-10 21:35:36 | [diff] [blame] | 410 | bool is_same_document, |
Shivani Sharma | ffb32b8 | 2019-04-09 16:58:47 | [diff] [blame] | 411 | bool replace_entry, |
| 412 | bool previous_document_was_activated, |
| 413 | NavigationHandleImpl* handle); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 414 | bool RendererDidNavigateAutoSubframe( |
creis | 3da0387 | 2015-02-20 21:12:32 | [diff] [blame] | 415 | RenderFrameHostImpl* rfh, |
Lukasz Anforowicz | 435bcb58 | 2019-07-12 20:50:06 | [diff] [blame] | 416 | const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 417 | NavigationHandleImpl* handle); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 418 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 419 | // Allows the derived class to issue notifications that a load has been |
| 420 | // committed. This will fill in the active entry to the details structure. |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 421 | void NotifyNavigationEntryCommitted(LoadCommittedDetails* details); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 422 | |
| 423 | // Updates the virtual URL of an entry to match a new URL, for cases where |
| 424 | // the real renderer URL is derived from the virtual URL, like view-source: |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 425 | void UpdateVirtualURLToURL(NavigationEntryImpl* entry, |
[email protected] | 10f417c5 | 2011-12-28 21:04:23 | [diff] [blame] | 426 | const GURL& new_url); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 427 | |
| 428 | // Invoked after session/tab restore or cloning a tab. Resets the transition |
| 429 | // type of the entries, updates the max page id and creates the active |
[email protected] | 2ca1ea66 | 2012-10-04 02:26:36 | [diff] [blame] | 430 | // contents. |
| 431 | void FinishRestore(int selected_index, RestoreType type); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 432 | |
| 433 | // Inserts a new entry or replaces the current entry with a new one, removing |
| 434 | // all entries after it. The new entry will become the active one. |
dcheng | 9bfa516 | 2016-04-09 01:00:57 | [diff] [blame] | 435 | void InsertOrReplaceEntry(std::unique_ptr<NavigationEntryImpl> entry, |
avi | 2576470 | 2015-06-23 15:43:37 | [diff] [blame] | 436 | bool replace); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 437 | |
[email protected] | 6a13a6c | 2011-12-20 21:47:12 | [diff] [blame] | 438 | // Removes the entry at |index|, as long as it is not the current entry. |
[email protected] | 4303234 | 2011-03-21 14:10:31 | [diff] [blame] | 439 | void RemoveEntryAtIndexInternal(int index); |
| 440 | |
[email protected] | b12eb22 | 2013-09-10 00:11:48 | [diff] [blame] | 441 | // Discards both the pending and transient entries. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 442 | void DiscardNonCommittedEntriesInternal(); |
| 443 | |
[email protected] | b12eb22 | 2013-09-10 00:11:48 | [diff] [blame] | 444 | // Discards only the transient entry. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 445 | void DiscardTransientEntry(); |
| 446 | |
Shivani Sharma | d8c8d65 | 2019-02-13 17:27:57 | [diff] [blame] | 447 | // If we have the maximum number of entries, remove the oldest entry that is |
| 448 | // marked to be skipped on back/forward button, in preparation to add another. |
| 449 | // If no entry is skippable, then the oldest entry will be pruned. |
| 450 | void PruneOldestSkippableEntryIfFull(); |
[email protected] | 944822b | 2012-03-02 20:57:25 | [diff] [blame] | 451 | |
[email protected] | 474f851 | 2013-05-31 22:31:16 | [diff] [blame] | 452 | // Removes all entries except the last committed entry. If there is a new |
[email protected] | 7936898 | 2013-11-13 01:11:01 | [diff] [blame] | 453 | // pending navigation it is preserved. In contrast to |
| 454 | // PruneAllButLastCommitted() this does not update the session history of the |
| 455 | // RenderView. Callers must ensure that |CanPruneAllButLastCommitted| returns |
| 456 | // true before calling this. |
| 457 | void PruneAllButLastCommittedInternal(); |
[email protected] | 9350602e | 2013-02-26 23:27:44 | [diff] [blame] | 458 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 459 | // Inserts up to |max_index| entries from |source| into this. This does NOT |
| 460 | // adjust any of the members that reference entries_ |
| 461 | // (last_committed_entry_index_, pending_entry_index_ or |
| 462 | // transient_entry_index_). |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 463 | void InsertEntriesFrom(NavigationControllerImpl* source, int max_index); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 464 | |
[email protected] | 9ba1405 | 2012-06-22 23:50:03 | [diff] [blame] | 465 | // Returns the navigation index that differs from the current entry by the |
| 466 | // specified |offset|. The index returned is not guaranteed to be valid. |
Lucas Furukawa Gadani | 5553a15 | 2019-01-08 18:55:57 | [diff] [blame] | 467 | int GetIndexForOffset(int offset); |
[email protected] | 9ba1405 | 2012-06-22 23:50:03 | [diff] [blame] | 468 | |
Arthur Sonzogni | 620cec6 | 2018-12-13 13:08:57 | [diff] [blame] | 469 | // BackForwardCache: |
| 470 | // Notify observers a document was restored from the bfcache. |
| 471 | // This updates the URL bar and the history buttons. |
| 472 | void CommitRestoreFromBackForwardCache(); |
| 473 | |
Shivani Sharma | ffb32b8 | 2019-04-09 16:58:47 | [diff] [blame] | 474 | // History Manipulation intervention: |
| 475 | // The previous document that started this navigation needs to be skipped in |
| 476 | // subsequent back/forward UI navigations if it never received any user |
| 477 | // gesture. This is to intervene against pages that manipulate the history |
| 478 | // such that the user is not able to go back to the last site they interacted |
| 479 | // with (crbug.com/907167). |
| 480 | // Note that this function must be called before the new navigation entry is |
| 481 | // inserted in |entries_| to make sure UKM reports the URL of the document |
| 482 | // adding the entry. |
| 483 | void SetShouldSkipOnBackForwardUIIfNeeded( |
| 484 | RenderFrameHostImpl* rfh, |
| 485 | bool replace_entry, |
| 486 | bool previous_document_was_activated, |
| 487 | bool is_renderer_initiated); |
| 488 | |
Shivani Sharma | c4cc892 | 2019-04-18 03:11:17 | [diff] [blame] | 489 | // This function sets all same document entries with the same value |
| 490 | // of skippable flag. This is to avoid back button abuse by inserting |
| 491 | // multiple history entries and also to help valid cases where a user gesture |
| 492 | // on the document should apply to all same document history entries and none |
| 493 | // should be skipped. All entries belonging to the same document as the entry |
| 494 | // at |reference_index| will get their skippable flag set to |skippable|. |
| 495 | void SetSkippableForSameDocumentEntries(int reference_index, bool skippable); |
| 496 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 497 | // --------------------------------------------------------------------------- |
| 498 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 499 | // The user browser context associated with this controller. |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 500 | BrowserContext* browser_context_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 501 | |
avi | f16f85a7 | 2015-11-13 18:25:03 | [diff] [blame] | 502 | // List of |NavigationEntry|s for this controller. |
dcheng | 9bfa516 | 2016-04-09 01:00:57 | [diff] [blame] | 503 | std::vector<std::unique_ptr<NavigationEntryImpl>> entries_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 504 | |
| 505 | // An entry we haven't gotten a response for yet. This will be discarded |
| 506 | // when we navigate again. It's used only so we know what the currently |
| 507 | // displayed tab is. |
| 508 | // |
| 509 | // This may refer to an item in the entries_ list if the pending_entry_index_ |
arthursonzogni | 02084c7 | 2017-05-03 22:52:39 | [diff] [blame] | 510 | // != -1, or it may be its own entry that should be deleted. Be careful with |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 511 | // the memory management. |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 512 | NavigationEntryImpl* pending_entry_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 513 | |
avi | 45a7253 | 2015-04-07 21:01:45 | [diff] [blame] | 514 | // If a new entry fails loading, details about it are temporarily held here |
creis | 865ad44 | 2016-03-15 16:43:09 | [diff] [blame] | 515 | // until the error page is shown (or 0 otherwise). |
avi | 45a7253 | 2015-04-07 21:01:45 | [diff] [blame] | 516 | // |
| 517 | // TODO(avi): We need a better way to handle the connection between failed |
| 518 | // loads and the subsequent load of the error page. This current approach has |
| 519 | // issues: 1. This might hang around longer than we'd like if there is no |
| 520 | // error page loaded, and 2. This doesn't work very well for frames. |
| 521 | // http://crbug.com/474261 |
| 522 | int failed_pending_entry_id_; |
avi | 45a7253 | 2015-04-07 21:01:45 | [diff] [blame] | 523 | |
| 524 | // The index of the currently visible entry. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 525 | int last_committed_entry_index_; |
| 526 | |
avi | 45a7253 | 2015-04-07 21:01:45 | [diff] [blame] | 527 | // The index of the pending entry if it is in entries_, or -1 if |
| 528 | // pending_entry_ is a new entry (created by LoadURL). |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 529 | int pending_entry_index_; |
| 530 | |
| 531 | // The index for the entry that is shown until a navigation occurs. This is |
| 532 | // used for interstitial pages. -1 if there are no such entry. |
| 533 | // Note that this entry really appears in the list of entries, but only |
| 534 | // temporarily (until the next navigation). Any index pointing to an entry |
| 535 | // after the transient entry will become invalid if you navigate forward. |
| 536 | int transient_entry_index_; |
| 537 | |
[email protected] | ec6c05f | 2013-10-23 18:41:57 | [diff] [blame] | 538 | // The delegate associated with the controller. Possibly NULL during |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 539 | // setup. |
[email protected] | ec6c05f | 2013-10-23 18:41:57 | [diff] [blame] | 540 | NavigationControllerDelegate* delegate_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 541 | |
[email protected] | b0f724c | 2013-09-05 04:21:13 | [diff] [blame] | 542 | // Manages the SSL security UI. |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 543 | SSLManager ssl_manager_; |
| 544 | |
| 545 | // Whether we need to be reloaded when made active. |
| 546 | bool needs_reload_; |
| 547 | |
Bo Liu | cdfa4b1 | 2018-11-06 00:21:44 | [diff] [blame] | 548 | // Source of when |needs_reload_| is set. Only valid when |needs_reload_| |
| 549 | // is set. |
| 550 | NeedsReloadType needs_reload_type_ = NeedsReloadType::kRequestedByClient; |
| 551 | |
[email protected] | 27ba81c | 2012-08-21 17:04:09 | [diff] [blame] | 552 | // Whether this is the initial navigation. |
[email protected] | cd2e1574 | 2013-03-08 04:08:31 | [diff] [blame] | 553 | // Becomes false when initial navigation commits. |
[email protected] | 27ba81c | 2012-08-21 17:04:09 | [diff] [blame] | 554 | bool is_initial_navigation_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 555 | |
[email protected] | 40fd303 | 2014-02-28 22:16:28 | [diff] [blame] | 556 | // Prevent unsafe re-entrant calls to NavigateToPendingEntry. |
| 557 | bool in_navigate_to_pending_entry_; |
| 558 | |
[email protected] | fdac6ade | 2013-07-20 01:06:30 | [diff] [blame] | 559 | // Used to find the appropriate SessionStorageNamespace for the storage |
| 560 | // partition of a NavigationEntry. |
| 561 | // |
| 562 | // A NavigationController may contain NavigationEntries that correspond to |
| 563 | // different StoragePartitions. Even though they are part of the same |
| 564 | // NavigationController, only entries in the same StoragePartition may |
| 565 | // share session storage state with one another. |
| 566 | SessionStorageNamespaceMap session_storage_namespace_map_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 567 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 568 | // The maximum number of entries that a navigation controller can store. |
[email protected] | 9b51970d | 2011-12-09 23:10:23 | [diff] [blame] | 569 | static size_t max_entry_count_for_testing_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 570 | |
toyoshim | 7dad4b118 | 2016-04-01 14:28:05 | [diff] [blame] | 571 | // If a repost is pending, its type (RELOAD or RELOAD_BYPASSING_CACHE), |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 572 | // NO_RELOAD otherwise. |
| 573 | ReloadType pending_reload_; |
| 574 | |
[email protected] | c5b88d8 | 2012-10-06 17:03:33 | [diff] [blame] | 575 | // Used to get timestamps for newly-created navigation entries. |
| 576 | base::Callback<base::Time()> get_timestamp_callback_; |
| 577 | |
| 578 | // Used to smooth out timestamps from |get_timestamp_callback_|. |
| 579 | // Without this, whenever there is a run of redirects or |
| 580 | // code-generated navigations, those navigations may occur within |
| 581 | // the timer resolution, leading to things sometimes showing up in |
| 582 | // the wrong order in the history view. |
| 583 | TimeSmoother time_smoother_; |
| 584 | |
Arthur Sonzogni | 620cec6 | 2018-12-13 13:08:57 | [diff] [blame] | 585 | // BackForwardCache: |
| 586 | // |
| 587 | // Stores frozen RenderFrameHost. Restores them on history navigation. |
| 588 | // See BackForwardCache class documentation. |
| 589 | BackForwardCache back_forward_cache_; |
| 590 | |
[email protected] | d202a7c | 2012-01-04 07:53:47 | [diff] [blame] | 591 | DISALLOW_COPY_AND_ASSIGN(NavigationControllerImpl); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 592 | }; |
| 593 | |
[email protected] | 8ff00d7 | 2012-10-23 19:12:21 | [diff] [blame] | 594 | } // namespace content |
| 595 | |
[email protected] | d4a8ca48 | 2013-10-30 21:06:40 | [diff] [blame] | 596 | #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_ |