Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl.h

Issue 281653003: DRAFT CL: Add FrameNavigationEntry and track subframe session histories. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/browser/frame_host/navigation_controller_delegate.h" 14 #include "content/browser/frame_host/navigation_controller_delegate.h"
15 #include "content/browser/frame_host/navigation_entry_impl.h" 15 #include "content/browser/frame_host/navigation_entry_impl.h"
16 #include "content/browser/ssl/ssl_manager.h" 16 #include "content/browser/ssl/ssl_manager.h"
17 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/navigation_type.h" 18 #include "content/public/browser/navigation_type.h"
19 19
20 struct FrameHostMsg_DidCommitProvisionalLoad_Params; 20 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
21 21
22 namespace content { 22 namespace content {
23 class FrameTreeNode;
23 class RenderFrameHostImpl; 24 class RenderFrameHostImpl;
24 class NavigationEntryScreenshotManager; 25 class NavigationEntryScreenshotManager;
25 class SiteInstance; 26 class SiteInstance;
26 struct LoadCommittedDetails; 27 struct LoadCommittedDetails;
27 28
28 class CONTENT_EXPORT NavigationControllerImpl 29 class CONTENT_EXPORT NavigationControllerImpl
29 : public NON_EXPORTED_BASE(NavigationController) { 30 : public NON_EXPORTED_BASE(NavigationController) {
30 public: 31 public:
31 NavigationControllerImpl( 32 NavigationControllerImpl(
32 NavigationControllerDelegate* delegate, 33 NavigationControllerDelegate* delegate,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 // The session storage namespace that all child RenderViews belonging to 97 // The session storage namespace that all child RenderViews belonging to
97 // |instance| should use. 98 // |instance| should use.
98 SessionStorageNamespace* GetSessionStorageNamespace( 99 SessionStorageNamespace* GetSessionStorageNamespace(
99 SiteInstance* instance); 100 SiteInstance* instance);
100 101
101 // Returns the index of the specified entry, or -1 if entry is not contained 102 // Returns the index of the specified entry, or -1 if entry is not contained
102 // in this NavigationController. 103 // in this NavigationController.
103 int GetIndexOfEntry(const NavigationEntryImpl* entry) const; 104 int GetIndexOfEntry(const NavigationEntryImpl* entry) const;
104 105
105 // Return the index of the entry with the corresponding instance and page_id, 106 // Return the index of the entry with the corresponding page_id, or -1 if not
106 // or -1 if not found. 107 // found.
107 int GetEntryIndexWithPageID(SiteInstance* instance, 108 int GetEntryIndexWithPageID(int32 page_id) const;
108 int32 page_id) const;
109 109
110 // Return the entry with the corresponding instance and page_id, or NULL if 110 // TODO(creis): Private? const?
111 // not found. 111 int GetFrameEntryIndex(int64 frame_tree_node_id,
112 NavigationEntryImpl* GetEntryWithPageID( 112 SiteInstance* site_instance,
113 SiteInstance* instance, 113 int64 item_sequence_number);
114 int32 page_id) const; 114
115 // Return the entry with the corresponding page_id, or NULL if not found.
116 NavigationEntryImpl* GetEntryWithPageID(int32 page_id) const;
115 117
116 NavigationControllerDelegate* delegate() const { 118 NavigationControllerDelegate* delegate() const {
117 return delegate_; 119 return delegate_;
118 } 120 }
119 121
120 // For use by WebContentsImpl ------------------------------------------------ 122 // For use by WebContentsImpl ------------------------------------------------
121 123
122 // Allow renderer-initiated navigations to create a pending entry when the 124 // Allow renderer-initiated navigations to create a pending entry when the
123 // provisional load starts. 125 // provisional load starts.
124 void SetPendingEntry(content::NavigationEntryImpl* entry); 126 void SetPendingEntry(content::NavigationEntryImpl* entry);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 private: 207 private:
206 friend class RestoreHelper; 208 friend class RestoreHelper;
207 209
208 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, 210 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest,
209 PurgeScreenshot); 211 PurgeScreenshot);
210 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, Basic); 212 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, Basic);
211 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, SingleDuplicate); 213 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, SingleDuplicate);
212 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ManyDuplicates); 214 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ManyDuplicates);
213 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ClockBackwardsJump); 215 FRIEND_TEST_ALL_PREFIXES(TimeSmoother, ClockBackwardsJump);
214 216
217 typedef std::vector<std::pair<FrameTreeNode*, FrameNavigationEntry*> >
218 FrameLoadVector;
219
215 // Helper class to smooth out runs of duplicate timestamps while still 220 // Helper class to smooth out runs of duplicate timestamps while still
216 // allowing time to jump backwards. 221 // allowing time to jump backwards.
217 class CONTENT_EXPORT TimeSmoother { 222 class CONTENT_EXPORT TimeSmoother {
218 public: 223 public:
219 // Returns |t| with possibly some time added on. 224 // Returns |t| with possibly some time added on.
220 base::Time GetSmoothedTime(base::Time t); 225 base::Time GetSmoothedTime(base::Time t);
221 226
222 private: 227 private:
223 // |low_water_mark_| is the first time in a sequence of adjusted 228 // |low_water_mark_| is the first time in a sequence of adjusted
224 // times and |high_water_mark_| is the last. 229 // times and |high_water_mark_| is the last.
225 base::Time low_water_mark_; 230 base::Time low_water_mark_;
226 base::Time high_water_mark_; 231 base::Time high_water_mark_;
227 }; 232 };
228 233
234 // TODO(creis): Remove and share code with CreateNavigationEntry.
235 NavigationEntryImpl* CreateSubframeNavigationEntry(
236 int64 frame_tree_node_id,
237 const GURL& url,
238 const Referrer& referrer,
239 ui::PageTransition transition,
240 bool is_renderer_initiated,
241 const std::string& extra_headers,
242 BrowserContext* browser_context);
243
229 // Classifies the given renderer navigation (see the NavigationType enum). 244 // Classifies the given renderer navigation (see the NavigationType enum).
230 NavigationType ClassifyNavigation( 245 NavigationType ClassifyNavigation(
231 RenderFrameHostImpl* rfh, 246 RenderFrameHostImpl* rfh,
232 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const; 247 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const;
233 248
234 // Causes the controller to load the specified entry. The function assumes 249 // Causes the controller to load the specified entry. The function assumes
235 // ownership of the pointer since it is put in the navigation list. 250 // ownership of the pointer since it is put in the navigation list.
236 // NOTE: Do not pass an entry that the controller already owns! 251 // NOTE: Do not pass an entry that the controller already owns!
237 void LoadEntry(NavigationEntryImpl* entry); 252 void LoadEntry(NavigationEntryImpl* entry);
238 253
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 void UpdateVirtualURLToURL(NavigationEntryImpl* entry, 299 void UpdateVirtualURLToURL(NavigationEntryImpl* entry,
285 const GURL& new_url); 300 const GURL& new_url);
286 301
287 // Invoked after session/tab restore or cloning a tab. Resets the transition 302 // Invoked after session/tab restore or cloning a tab. Resets the transition
288 // type of the entries, updates the max page id and creates the active 303 // type of the entries, updates the max page id and creates the active
289 // contents. 304 // contents.
290 void FinishRestore(int selected_index, RestoreType type); 305 void FinishRestore(int selected_index, RestoreType type);
291 306
292 // Inserts a new entry or replaces the current entry with a new one, removing 307 // Inserts a new entry or replaces the current entry with a new one, removing
293 // all entries after it. The new entry will become the active one. 308 // all entries after it. The new entry will become the active one.
294 void InsertOrReplaceEntry(NavigationEntryImpl* entry, bool replace); 309 void InsertOrReplaceEntry(RenderFrameHostImpl* render_frame_host,
310 NavigationEntryImpl* entry,
311 FrameNavigationEntry* frame_entry,
312 bool replace);
295 313
296 // Removes the entry at |index|, as long as it is not the current entry. 314 // Removes the entry at |index|, as long as it is not the current entry.
297 void RemoveEntryAtIndexInternal(int index); 315 void RemoveEntryAtIndexInternal(int index);
298 316
299 // Discards both the pending and transient entries. 317 // Discards both the pending and transient entries.
300 void DiscardNonCommittedEntriesInternal(); 318 void DiscardNonCommittedEntriesInternal();
301 319
302 // Discards only the transient entry. 320 // Discards only the transient entry.
303 void DiscardTransientEntry(); 321 void DiscardTransientEntry();
304 322
(...skipping 15 matching lines...) Expand all
320 // Inserts up to |max_index| entries from |source| into this. This does NOT 338 // Inserts up to |max_index| entries from |source| into this. This does NOT
321 // adjust any of the members that reference entries_ 339 // adjust any of the members that reference entries_
322 // (last_committed_entry_index_, pending_entry_index_ or 340 // (last_committed_entry_index_, pending_entry_index_ or
323 // transient_entry_index_). 341 // transient_entry_index_).
324 void InsertEntriesFrom(const NavigationControllerImpl& source, int max_index); 342 void InsertEntriesFrom(const NavigationControllerImpl& source, int max_index);
325 343
326 // Returns the navigation index that differs from the current entry by the 344 // Returns the navigation index that differs from the current entry by the
327 // specified |offset|. The index returned is not guaranteed to be valid. 345 // specified |offset|. The index returned is not guaranteed to be valid.
328 int GetIndexForOffset(int offset) const; 346 int GetIndexForOffset(int offset) const;
329 347
348 // Recursively add FrameNavigationEntry pointers for the current entries in
349 // each frame's session history to the tree in the top-level NavigationEntry.
350 void AddFramesToNavigationEntry(
351 NavigationEntryImpl::TreeNode* entry_node,
352 FrameTreeNode* frame_tree_node);
353
354 // Recursively identifies which frames need to be navigated for the pending
355 // NavigationEntry, then tells each such frame to navigate.
356 bool NavigateToPendingEntryInternal(ReloadType reload_type);
357 void RecursiveNavigateToPendingEntry(FrameTreeNode* frame,
358 FrameLoadVector* sameDocumentLoads,
359 FrameLoadVector* differentDocumentLoads);
360
330 // --------------------------------------------------------------------------- 361 // ---------------------------------------------------------------------------
331 362
332 // The user browser context associated with this controller. 363 // The user browser context associated with this controller.
333 BrowserContext* browser_context_; 364 BrowserContext* browser_context_;
334 365
335 // List of NavigationEntry for this tab 366 // List of NavigationEntry for this tab
336 typedef std::vector<linked_ptr<NavigationEntryImpl> > NavigationEntries; 367 typedef std::vector<linked_ptr<NavigationEntryImpl> > NavigationEntries;
337 NavigationEntries entries_; 368 NavigationEntries entries_;
338 369
339 // An entry we haven't gotten a response for yet. This will be discarded 370 // An entry we haven't gotten a response for yet. This will be discarded
(...skipping 16 matching lines...) Expand all
356 // used for interstitial pages. -1 if there are no such entry. 387 // used for interstitial pages. -1 if there are no such entry.
357 // Note that this entry really appears in the list of entries, but only 388 // Note that this entry really appears in the list of entries, but only
358 // temporarily (until the next navigation). Any index pointing to an entry 389 // temporarily (until the next navigation). Any index pointing to an entry
359 // after the transient entry will become invalid if you navigate forward. 390 // after the transient entry will become invalid if you navigate forward.
360 int transient_entry_index_; 391 int transient_entry_index_;
361 392
362 // The delegate associated with the controller. Possibly NULL during 393 // The delegate associated with the controller. Possibly NULL during
363 // setup. 394 // setup.
364 NavigationControllerDelegate* delegate_; 395 NavigationControllerDelegate* delegate_;
365 396
397 // The next available page ID, which identifies joint session history items.
398 // TODO(creis): Copy when cloning tabs.
399 int32 next_page_id_;
400
366 // The max restored page ID in this controller, if it was restored. We must 401 // The max restored page ID in this controller, if it was restored. We must
367 // store this so that WebContentsImpl can tell any renderer in charge of one 402 // store this so that WebContentsImpl can tell any renderer in charge of one
368 // of the restored entries to update its max page ID. 403 // of the restored entries to update its max page ID.
369 int32 max_restored_page_id_; 404 int32 max_restored_page_id_;
370 405
371 // Manages the SSL security UI. 406 // Manages the SSL security UI.
372 SSLManager ssl_manager_; 407 SSLManager ssl_manager_;
373 408
374 // Whether we need to be reloaded when made active. 409 // Whether we need to be reloaded when made active.
375 bool needs_reload_; 410 bool needs_reload_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 TimeSmoother time_smoother_; 443 TimeSmoother time_smoother_;
409 444
410 scoped_ptr<NavigationEntryScreenshotManager> screenshot_manager_; 445 scoped_ptr<NavigationEntryScreenshotManager> screenshot_manager_;
411 446
412 DISALLOW_COPY_AND_ASSIGN(NavigationControllerImpl); 447 DISALLOW_COPY_AND_ASSIGN(NavigationControllerImpl);
413 }; 448 };
414 449
415 } // namespace content 450 } // namespace content
416 451
417 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_ 452 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_delegate.h ('k') | content/browser/frame_host/navigation_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698