Decouple NavigationControllerImpl and WebContentsImpl.
This CL is the first step in breaking dependencies between WebContents and navigation logic. It creates a NavigationControllerDelegate interface, which contains all the methods NavController needs to call on WebContentsImpl.
More details and roadmap of the changes to come are in https://docs.google.com/a/chromium.org/document/d/127ODQnXaoMtHdu2WXTR6iHg411bXa_8zRTb3kXlwArA/edit.
BUG=304341
Review URL: https://codereview.chromium.org/29693008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230480 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index fb81399..0ab09cc 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -18,6 +18,7 @@
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
+#include "content/browser/web_contents/navigation_controller_delegate.h"
#include "content/browser/web_contents/navigation_controller_impl.h"
#include "content/browser/web_contents/render_view_host_manager.h"
#include "content/common/content_export.h"
@@ -76,7 +77,8 @@
public RenderViewHostDelegate,
public RenderWidgetHostDelegate,
public RenderViewHostManager::Delegate,
- public NotificationObserver {
+ public NotificationObserver,
+ public NON_EXPORTED_BASE(NavigationControllerDelegate) {
public:
virtual ~WebContentsImpl();
@@ -112,32 +114,6 @@
// Returns the SavePackage which manages the page saving job. May be NULL.
SavePackage* save_package() const { return save_package_.get(); }
- // Updates the max page ID for the current SiteInstance in this
- // WebContentsImpl to be at least |page_id|.
- void UpdateMaxPageID(int32 page_id);
-
- // Updates the max page ID for the given SiteInstance in this WebContentsImpl
- // to be at least |page_id|.
- void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance,
- int32 page_id);
-
- // Copy the current map of SiteInstance ID to max page ID from another tab.
- // This is necessary when this tab adopts the NavigationEntries from
- // |web_contents|.
- void CopyMaxPageIDsFrom(WebContentsImpl* web_contents);
-
- // Called by the NavigationController to cause the WebContentsImpl to navigate
- // to the current pending entry. The NavigationController should be called
- // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
- // The callbacks can be inside of this function, or at some future time.
- //
- // The entry has a PageID of -1 if newly created (corresponding to navigation
- // to a new URL).
- //
- // If this method returns false, then the navigation is discarded (equivalent
- // to calling DiscardPendingEntry on the NavigationController).
- bool NavigateToPendingEntry(NavigationController::ReloadType reload_type);
-
// Called by InterstitialPageImpl when it creates a RenderViewHost.
void RenderViewForInterstitialPageCreated(RenderViewHost* render_view_host);
@@ -188,10 +164,6 @@
// Invoked when visible SSL state (as defined by SSLStatus) changes.
void DidChangeVisibleSSLState();
- // Invoked before a form repost warning is shown.
- void NotifyBeforeFormRepostWarningShow();
-
-
// Informs the render view host and the BrowserPluginEmbedder, if present, of
// a Drag Source End.
void DragSourceEndedAt(int client_x, int client_y, int screen_x,
@@ -510,6 +482,53 @@
const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
+ // NavigationControllerDelegate ----------------------------------------------
+
+ virtual WebContents* GetWebContents() OVERRIDE;
+ virtual void NotifyNavigationEntryCommitted(
+ const LoadCommittedDetails& load_details) OVERRIDE;
+
+ // Invoked before a form repost warning is shown.
+ virtual void NotifyBeforeFormRepostWarningShow() OVERRIDE;
+
+ // Activate this WebContents and show a form repost warning.
+ virtual void ActivateAndShowRepostFormWarningDialog() OVERRIDE;
+
+ // Updates the max page ID for the current SiteInstance in this
+ // WebContentsImpl to be at least |page_id|.
+ virtual void UpdateMaxPageID(int32 page_id) OVERRIDE;
+
+ // Updates the max page ID for the given SiteInstance in this WebContentsImpl
+ // to be at least |page_id|.
+ virtual void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance,
+ int32 page_id) OVERRIDE;
+
+ // Copy the current map of SiteInstance ID to max page ID from another tab.
+ // This is necessary when this tab adopts the NavigationEntries from
+ // |web_contents|.
+ virtual void CopyMaxPageIDsFrom(WebContents* web_contents) OVERRIDE;
+
+ // Called by the NavigationController to cause the WebContentsImpl to navigate
+ // to the current pending entry. The NavigationController should be called
+ // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
+ // The callbacks can be inside of this function, or at some future time.
+ //
+ // The entry has a PageID of -1 if newly created (corresponding to navigation
+ // to a new URL).
+ //
+ // If this method returns false, then the navigation is discarded (equivalent
+ // to calling DiscardPendingEntry on the NavigationController).
+ virtual bool NavigateToPendingEntry(
+ NavigationController::ReloadType reload_type) OVERRIDE;
+
+ // Sets the history for this WebContentsImpl to |history_length| entries, and
+ // moves the current page_id to the last entry in the list if it's valid.
+ // This is mainly used when a prerendered page is swapped into the current
+ // tab. The method is virtual for testing.
+ virtual void SetHistoryLengthAndPrune(
+ const SiteInstance* site_instance,
+ int merge_history_length,
+ int32 minimum_page_id) OVERRIDE;
private:
friend class NavigationControllerImpl;
@@ -693,15 +712,6 @@
bool NavigateToEntry(const NavigationEntryImpl& entry,
NavigationController::ReloadType reload_type);
- // Sets the history for this WebContentsImpl to |history_length| entries, and
- // moves the current page_id to the last entry in the list if it's valid.
- // This is mainly used when a prerendered page is swapped into the current
- // tab. The method is virtual for testing.
- virtual void SetHistoryLengthAndPrune(
- const SiteInstance* site_instance,
- int merge_history_length,
- int32 minimum_page_id);
-
// Recursively creates swapped out RenderViews for this tab's opener chain
// (including this tab) in the given SiteInstance, allowing other tabs to send
// cross-process JavaScript calls to their opener(s). Returns the route ID of
@@ -739,7 +749,6 @@
// Helper functions for sending notifications.
void NotifySwapped(RenderViewHost* old_host, RenderViewHost* new_host);
void NotifyDisconnected();
- void NotifyNavigationEntryCommitted(const LoadCommittedDetails& load_details);
void SetEncoding(const std::string& encoding);