diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-28 22:10:17 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-28 22:10:17 +0000 |
commit | ecd9d87092866d04c00b5695ac56f0a026a6a2c8 (patch) | |
tree | 8af05cf2b9c524db3d40a7007ed5ec137a820d12 /chrome/browser/navigation_controller.h | |
parent | 7ea9cbb1f61ea1b6990011d076bc09c05b9e72e8 (diff) | |
download | chromium_src-ecd9d87092866d04c00b5695ac56f0a026a6a2c8.zip chromium_src-ecd9d87092866d04c00b5695ac56f0a026a6a2c8.tar.gz chromium_src-ecd9d87092866d04c00b5695ac56f0a026a6a2c8.tar.bz2 |
Make a step on refactoring navigation. The eventual plan is to have the NavigationController create and commit the new NavigationEntries (currently WebContents does a bunch of the details of this which is hard to understand and not easily testable).
This tries to consolidate the logic that I want to move to the NavigationController without actually moving it there yet. I removed all of the "PreCommit" functions in WebContents, since when the NavigationController does
all of the committing, there won't be a phase where the NavigationEntry exists but isn't committed.
Most of the logic could be moved to the PostCommit functions without any problem, which is an indication that the current design was busted anyway. I had to precompute some data and pass it to the *PostCommit function to work around some of the components that required old data. I had to change InfoBars around since it relied on having both the committed and uncommitted entries, but I think the new design is much better anyway.
BUG=1343593,1343146
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1506 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/navigation_controller.h')
-rw-r--r-- | chrome/browser/navigation_controller.h | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/chrome/browser/navigation_controller.h b/chrome/browser/navigation_controller.h index c2c517d..e43bfe1 100644 --- a/chrome/browser/navigation_controller.h +++ b/chrome/browser/navigation_controller.h @@ -48,6 +48,46 @@ class NavigationController { int index; }; + struct LoadCommittedDetails { + // By default, the entry will be filled according to a new main frame + // navigation. + LoadCommittedDetails() + : entry(NULL), + is_auto(false), + is_in_page(false), + is_main_frame(true) { + } + + // The committed entry. This will be the active entry in the controller. + NavigationEntry* entry; + + // The previous URL that the user was on. This may be empty if none. + GURL previous_url; + + // True when this load was non-user initated. This corresponds to a + // a NavigationGestureAuto call from WebKit (see webview_delegate.h). + // We also count reloads and meta-refreshes as "auto" to account for the + // fact that WebKit doesn't always set the user gesture properly in these + // cases (see bug 1051891). + bool is_auto; + + // True if the navigation was in-page. This means that the active entry's + // URL and the |previous_url| are the same except for reference fragments. + bool is_in_page; + + // True when the main frame was navigated. False means the navigation was a + // sub-frame. + bool is_main_frame; + + // Returns whether the user probably felt like they navigated somewhere new. + // We often need this logic for showing or hiding something, and this + // returns true only for main frame loads that the user initiated, that go + // to a new page. + bool is_user_initiated_main_frame_load() const { + return !is_auto && !is_in_page && is_main_frame; + } + }; + NavigationController(TabContents* initial_contents, Profile* profile); // Creates a NavigationController from the specified history. Processing // for this is asynchronous and handled via the RestoreHelper (in @@ -208,7 +248,15 @@ class NavigationController { // for a tab. The controller takes ownership of the entry. Any entry located // forward to the current entry will be deleted. The new entry becomes the // current entry. - void DidNavigateToEntry(NavigationEntry* entry); + // + // The details are populated by the caller except for the new NavigationEntry + // pointer and the previous URL. We will fill these in before using it to + // broadcast notifications, so it can also be used by the caller. + // + // TODO(brettw) bug 1343146: The NavigationController should internally make + // the entry and the notification details. + void DidNavigateToEntry(NavigationEntry* entry, + LoadCommittedDetails* details); // Calling this may cause the active tab contents to switch if the current // entry corresponds to a different tab contents type. @@ -284,8 +332,8 @@ class NavigationController { void NavigateToPendingEntry(bool reload); // Allows the derived class to issue notifications that a load has been - // committed. - void NotifyNavigationEntryCommitted(); + // committed. This will fill in the active entry to the details structure. + void NotifyNavigationEntryCommitted(LoadCommittedDetails* details); // Invoked when entries have been pruned, or removed. For example, if the // current entries are [google, digg, yahoo], with the current entry google, |