summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/renderer_host/test_render_view_host.cc2
-rw-r--r--content/browser/renderer_host/test_render_view_host.h3
-rw-r--r--content/browser/tab_contents/interstitial_page.cc2
-rw-r--r--content/browser/tab_contents/navigation_controller.cc42
-rw-r--r--content/browser/tab_contents/navigation_controller.h21
-rw-r--r--content/browser/tab_contents/navigation_controller_unittest.cc10
-rw-r--r--content/browser/tab_contents/tab_contents.cc16
-rw-r--r--content/browser/tab_contents/tab_contents.h7
-rw-r--r--content/browser/tab_contents/tab_contents_unittest.cc4
-rw-r--r--content/browser/tab_contents/test_tab_contents.cc2
10 files changed, 58 insertions, 51 deletions
diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc
index f0e6030..ff4756b 100644
--- a/content/browser/renderer_host/test_render_view_host.cc
+++ b/content/browser/renderer_host/test_render_view_host.cc
@@ -311,7 +311,7 @@ RenderViewHostTestHarness::~RenderViewHostTestHarness() {
}
NavigationController& RenderViewHostTestHarness::controller() {
- return contents()->GetController();
+ return contents()->GetControllerImpl();
}
TestTabContents* RenderViewHostTestHarness::contents() {
diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h
index 1be401e..40e21b2 100644
--- a/content/browser/renderer_host/test_render_view_host.h
+++ b/content/browser/renderer_host/test_render_view_host.h
@@ -17,6 +17,8 @@
#include "content/public/common/page_transition_types.h"
#include "testing/gtest/include/gtest/gtest.h"
+class NavigationController;
+
namespace content {
class BrowserContext;
class RenderProcessHostFactory;
@@ -26,7 +28,6 @@ namespace gfx {
class Rect;
}
-class NavigationController;
class SiteInstance;
class TestTabContents;
struct ViewHostMsg_FrameNavigate_Params;
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc
index 41d9a32..439130f 100644
--- a/content/browser/tab_contents/interstitial_page.cc
+++ b/content/browser/tab_contents/interstitial_page.cc
@@ -196,7 +196,7 @@ void InterstitialPage::Show() {
// Give sub-classes a chance to set some states on the navigation entry.
UpdateEntry(entry);
- tab_->GetController().AddTransientEntry(entry);
+ tab_->GetControllerImpl().AddTransientEntry(entry);
}
DCHECK(!render_view_host_);
diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc
index dbbf9d4..307a694 100644
--- a/content/browser/tab_contents/navigation_controller.cc
+++ b/content/browser/tab_contents/navigation_controller.cc
@@ -31,6 +31,7 @@
#include "net/base/net_util.h"
#include "webkit/glue/webkit_glue.h"
+using content::BrowserContext;
using content::GlobalRequestID;
using content::NavigationEntry;
using content::NavigationEntryImpl;
@@ -115,17 +116,19 @@ const size_t kMaxEntryCountForTestingNotSet = -1;
size_t NavigationController::max_entry_count_for_testing_ =
kMaxEntryCountForTestingNotSet;
-// static
-bool NavigationController::check_for_repost_ = true;
+ // Should Reload check for post data? The default is true, but is set to false
+// when testing.
+static bool g_check_for_repost = true;
+namespace content {
// static
-NavigationEntry* content::NavigationController::CreateNavigationEntry(
+NavigationEntry* NavigationController::CreateNavigationEntry(
const GURL& url,
- const content::Referrer& referrer,
- content::PageTransition transition,
+ const Referrer& referrer,
+ PageTransition transition,
bool is_renderer_initiated,
const std::string& extra_headers,
- content::BrowserContext* browser_context) {
+ BrowserContext* browser_context) {
// Allow the browser URL handler to rewrite the URL. This will, for example,
// remove "view-source:" from the beginning of the URL to get the URL that
// will actually be loaded. This real URL won't be shown to the user, just
@@ -151,9 +154,16 @@ NavigationEntry* content::NavigationController::CreateNavigationEntry(
return entry;
}
+// static
+void NavigationController::DisablePromptOnRepost() {
+ g_check_for_repost = false;
+}
+
+} // namespace content
+
NavigationController::NavigationController(
TabContents* contents,
- content::BrowserContext* browser_context,
+ BrowserContext* browser_context,
SessionStorageNamespace* session_storage_namespace)
: browser_context_(browser_context),
pending_entry_(NULL),
@@ -186,10 +196,14 @@ WebContents* NavigationController::GetWebContents() const {
return tab_contents_;
}
-content::BrowserContext* NavigationController::GetBrowserContext() const {
+BrowserContext* NavigationController::GetBrowserContext() const {
return browser_context_;
}
+void NavigationController::SetBrowserContext(BrowserContext* browser_context) {
+ browser_context_ = browser_context;
+}
+
void NavigationController::Restore(
int selected_navigation,
bool from_last_session,
@@ -232,7 +246,7 @@ void NavigationController::ReloadInternal(bool check_for_repost,
return;
}
- if (check_for_repost_ && check_for_repost &&
+ if (g_check_for_repost && check_for_repost &&
GetEntryAtIndex(current_index)->GetHasPostData()) {
// The user is asking to reload a page with POST data. Prompt to make sure
// they really want to do this. If they do, the dialog will call us back
@@ -957,7 +971,10 @@ bool NavigationController::IsURLInPageNavigation(const GURL& url) const {
return AreURLsInPageNavigation(last_committed->GetURL(), url);
}
-void NavigationController::CopyStateFrom(const NavigationController& source) {
+void NavigationController::CopyStateFrom(
+ const content::NavigationController& temp) {
+ const NavigationController& source =
+ static_cast<const NavigationController&>(temp);
// Verify that we look new.
DCHECK(GetEntryCount() == 0 && !GetPendingEntry());
@@ -1234,11 +1251,6 @@ void NavigationController::NotifyNavigationEntryCommitted(
}
// static
-void NavigationController::DisablePromptOnRepost() {
- check_for_repost_ = false;
-}
-
-// static
size_t NavigationController::max_entry_count() {
if (max_entry_count_for_testing_ != kMaxEntryCountForTestingNotSet)
return max_entry_count_for_testing_;
diff --git a/content/browser/tab_contents/navigation_controller.h b/content/browser/tab_contents/navigation_controller.h
index 2699d88..7625906 100644
--- a/content/browser/tab_contents/navigation_controller.h
+++ b/content/browser/tab_contents/navigation_controller.h
@@ -35,6 +35,8 @@ class CONTENT_EXPORT NavigationController
// NavigationController implementation:
virtual content::WebContents* GetWebContents() const OVERRIDE;
virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
+ virtual void SetBrowserContext(
+ content::BrowserContext* browser_context) OVERRIDE;
virtual void Restore(
int selected_navigation,
bool from_last_session,
@@ -87,15 +89,12 @@ class CONTENT_EXPORT NavigationController
virtual void ReloadIgnoringCache(bool check_for_repost) OVERRIDE;
virtual void NotifyEntryChanged(const content::NavigationEntry* entry,
int index) OVERRIDE;
+ virtual void CopyStateFrom(
+ const content::NavigationController& source) OVERRIDE;
virtual void CopyStateFromAndPrune(
content::NavigationController* source) OVERRIDE;
virtual void PruneAllButActive() OVERRIDE;
- // Sets the browser context for this controller.
- void set_browser_context(content::BrowserContext* browser_context) {
- browser_context_ = browser_context;
- }
-
// Returns the index of the specified entry, or -1 if entry is not contained
// in this NavigationController.
int GetIndexOfEntry(const content::NavigationEntryImpl* entry) const;
@@ -165,16 +164,8 @@ class CONTENT_EXPORT NavigationController
// refs without reload, only change to "#" which we don't count as empty).
bool IsURLInPageNavigation(const GURL& url) const;
- // Copies the navigation state from the given controller to this one. This
- // one should be empty (just created).
- void CopyStateFrom(const NavigationController& source);
-
// Random data ---------------------------------------------------------------
- // Disables checking for a repost and prompting the user. This is used during
- // testing.
- static void DisablePromptOnRepost();
-
// Maximum number of entries before we start removing entries from the front.
static void set_max_entry_count_for_testing(size_t max_entry_count) {
max_entry_count_for_testing_ = max_entry_count;
@@ -320,10 +311,6 @@ class CONTENT_EXPORT NavigationController
// The session storage id that any (indirectly) owned RenderView should use.
scoped_refptr<SessionStorageNamespace> session_storage_namespace_;
- // Should Reload check for post data? The default is true, but is set to false
- // when testing.
- static bool check_for_repost_;
-
// The maximum number of entries that a navigation controller can store.
static size_t max_entry_count_for_testing_;
diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc
index e0d6827..b109b324 100644
--- a/content/browser/tab_contents/navigation_controller_unittest.cc
+++ b/content/browser/tab_contents/navigation_controller_unittest.cc
@@ -1491,7 +1491,7 @@ TEST_F(NavigationControllerTest, RestoreNavigate) {
entries.push_back(entry);
TabContents our_contents(
browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL);
- NavigationController& our_controller = our_contents.GetController();
+ NavigationController& our_controller = our_contents.GetControllerImpl();
our_controller.Restore(0, true, &entries);
ASSERT_EQ(0u, entries.size());
@@ -1558,7 +1558,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
entries.push_back(entry);
TabContents our_contents(
browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL);
- NavigationController& our_controller = our_contents.GetController();
+ NavigationController& our_controller = our_contents.GetControllerImpl();
our_controller.Restore(0, true, &entries);
ASSERT_EQ(0u, entries.size());
@@ -2012,7 +2012,7 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune) {
NavigateAndCommit(url2);
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
- NavigationController& other_controller = other_contents->GetController();
+ NavigationController& other_controller = other_contents->GetControllerImpl();
other_contents->NavigateAndCommit(url3);
other_contents->ExpectSetHistoryLengthAndPrune(
NavigationEntryImpl::FromNavigationEntry(
@@ -2043,7 +2043,7 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) {
controller().GoBack();
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
- NavigationController& other_controller = other_contents->GetController();
+ NavigationController& other_controller = other_contents->GetControllerImpl();
other_contents->ExpectSetHistoryLengthAndPrune(NULL, 1, -1);
other_controller.CopyStateFromAndPrune(&controller());
@@ -2068,7 +2068,7 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) {
controller().GoBack();
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
- NavigationController& other_controller = other_contents->GetController();
+ NavigationController& other_controller = other_contents->GetControllerImpl();
other_controller.LoadURL(
url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
other_contents->ExpectSetHistoryLengthAndPrune(NULL, 1, -1);
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 88638a6..7683fd2 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -291,6 +291,10 @@ TabContents::~TabContents() {
SetDelegate(NULL);
}
+NavigationController& TabContents::GetControllerImpl() {
+ return controller_;
+}
+
bool TabContents::OnMessageReceived(const IPC::Message& message) {
if (GetWebUI() && GetWebUI()->OnMessageReceived(message))
return true;
@@ -352,11 +356,11 @@ void TabContents::RunFileChooser(
delegate_->RunFileChooser(this, params);
}
-NavigationController& TabContents::GetController() {
+content::NavigationController& TabContents::GetController() {
return controller_;
}
-const NavigationController& TabContents::GetController() const {
+const content::NavigationController& TabContents::GetController() const {
return controller_;
}
@@ -642,7 +646,7 @@ TabContents* TabContents::Clone() {
GetBrowserContext(),
SiteInstance::CreateSiteInstance(GetBrowserContext()),
MSG_ROUTING_NONE, this, NULL);
- tc->GetController().CopyStateFrom(controller_);
+ tc->GetControllerImpl().CopyStateFrom(controller_);
return tc;
}
@@ -1283,7 +1287,7 @@ void TabContents::OnDidLoadResourceFromMemoryCache(
void TabContents::OnDidDisplayInsecureContent() {
content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent"));
displayed_insecure_content_ = true;
- SSLManager::NotifySSLInternalStateChanged(&GetController());
+ SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl());
}
void TabContents::OnDidRunInsecureContent(
@@ -1297,7 +1301,7 @@ void TabContents::OnDidRunInsecureContent(
}
controller_.GetSSLManager()->DidRunInsecureContent(security_origin);
displayed_insecure_content_ = true;
- SSLManager::NotifySSLInternalStateChanged(&GetController());
+ SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl());
}
void TabContents::OnDocumentLoadedInFrame(int64 frame_id) {
@@ -2158,7 +2162,7 @@ void TabContents::NotifySwappedFromRenderManager() {
}
NavigationController& TabContents::GetControllerForRenderManager() {
- return GetController();
+ return GetControllerImpl();
}
WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) {
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 8438e52..0904d33 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -118,13 +118,16 @@ class CONTENT_EXPORT TabContents
return java_bridge_dispatcher_host_manager_.get();
}
+ // Like GetController from WebContents, but returns the concrete object.
+ NavigationController& GetControllerImpl();
+
// content::WebContents ------------------------------------------------------
virtual const base::PropertyBag* GetPropertyBag() const OVERRIDE;
virtual base::PropertyBag* GetPropertyBag() OVERRIDE;
virtual content::WebContentsDelegate* GetDelegate() OVERRIDE;
virtual void SetDelegate(content::WebContentsDelegate* delegate) OVERRIDE;
- virtual NavigationController& GetController() OVERRIDE;
- virtual const NavigationController& GetController() const OVERRIDE;
+ virtual content::NavigationController& GetController() OVERRIDE;
+ virtual const content::NavigationController& GetController() const OVERRIDE;
virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
virtual void SetViewType(content::ViewType type) OVERRIDE;
virtual content::ViewType GetViewType() const OVERRIDE;
diff --git a/content/browser/tab_contents/tab_contents_unittest.cc b/content/browser/tab_contents/tab_contents_unittest.cc
index 248cc17..c4b73db 100644
--- a/content/browser/tab_contents/tab_contents_unittest.cc
+++ b/content/browser/tab_contents/tab_contents_unittest.cc
@@ -1755,7 +1755,7 @@ TEST_F(TabContentsTest, CopyStateFromAndPruneSourceInterstitial) {
// Create another NavigationController.
GURL url3("http://foo2");
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
- NavigationController& other_controller = other_contents->GetController();
+ NavigationController& other_controller = other_contents->GetControllerImpl();
other_contents->NavigateAndCommit(url3);
other_contents->ExpectSetHistoryLengthAndPrune(
NavigationEntryImpl::FromNavigationEntry(
@@ -1782,7 +1782,7 @@ TEST_F(TabContentsTest, CopyStateFromAndPruneTargetInterstitial) {
// Create another NavigationController.
scoped_ptr<TestTabContents> other_contents(CreateTestTabContents());
- NavigationController& other_controller = other_contents->GetController();
+ NavigationController& other_controller = other_contents->GetControllerImpl();
// Navigate it to url2.
GURL url2("http://foo2");
diff --git a/content/browser/tab_contents/test_tab_contents.cc b/content/browser/tab_contents/test_tab_contents.cc
index 8b664f9..2589d1f 100644
--- a/content/browser/tab_contents/test_tab_contents.cc
+++ b/content/browser/tab_contents/test_tab_contents.cc
@@ -86,7 +86,7 @@ TabContents* TestTabContents::Clone() {
TabContents* tc = new TestTabContents(
GetBrowserContext(),
SiteInstance::CreateSiteInstance(GetBrowserContext()));
- tc->GetController().CopyStateFrom(controller_);
+ tc->GetControllerImpl().CopyStateFrom(controller_);
return tc;
}