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

Unified Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 11818036: Revert 175822 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl_unittest.cc
===================================================================
--- content/browser/web_contents/web_contents_impl_unittest.cc (revision 175856)
+++ content/browser/web_contents/web_contents_impl_unittest.cc (working copy)
@@ -10,7 +10,6 @@
#include "content/browser/web_contents/interstitial_page_impl.h"
#include "content/browser/web_contents/navigation_entry_impl.h"
#include "content/browser/web_contents/test_web_contents.h"
-#include "content/browser/webui/web_ui_controller_factory_registry.h"
#include "content/common/view_messages.h"
#include "content/public/browser/interstitial_page_delegate.h"
#include "content/public/browser/navigation_details.h"
@@ -20,6 +19,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui_controller.h"
+#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/url_constants.h"
@@ -28,20 +28,19 @@
#include "content/public/test/test_utils.h"
#include "content/test/test_content_browser_client.h"
#include "content/test/test_content_client.h"
+#include "googleurl/src/url_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/glue/webkit_glue.h"
namespace content {
namespace {
-const char kTestWebUIUrl[] = "chrome://blah";
-
class WebContentsImplTestWebUIControllerFactory
: public WebUIControllerFactory {
public:
virtual WebUIController* CreateWebUIControllerForURL(
WebUI* web_ui, const GURL& url) const OVERRIDE {
- if (!UseWebUI(url))
+ if (!GetContentClient()->HasWebUIScheme(url))
return NULL;
return new WebUIController(web_ui);
@@ -54,27 +53,45 @@
virtual bool UseWebUIForURL(BrowserContext* browser_context,
const GURL& url) const OVERRIDE {
- return UseWebUI(url);
+ return GetContentClient()->HasWebUIScheme(url);
}
virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
const GURL& url) const OVERRIDE {
- return UseWebUI(url);
+ return GetContentClient()->HasWebUIScheme(url);
}
virtual bool IsURLAcceptableForWebUI(
BrowserContext* browser_context,
const GURL& url,
bool data_urls_allowed) const {
- return UseWebUI(url);
+ return GetContentClient()->HasWebUIScheme(url);
}
+};
- private:
- bool UseWebUI(const GURL& url) const {
- return url == GURL(kTestWebUIUrl);
+class WebContentsImplTestContentClient : public TestContentClient {
+ public:
+ WebContentsImplTestContentClient() {
}
+
+ virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE {
+ return url.SchemeIs("webcontentsimpltest");
+ }
};
+class WebContentsImplTestBrowserClient : public TestContentBrowserClient {
+ public:
+ WebContentsImplTestBrowserClient() {
+ }
+
+ virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE {
+ return &factory_;
+ }
+
+ private:
+ WebContentsImplTestWebUIControllerFactory factory_;
+};
+
class TestInterstitialPage;
class TestInterstitialPageDelegate : public InterstitialPageDelegate {
@@ -240,24 +257,37 @@
class WebContentsImplTest : public RenderViewHostImplTestHarness {
public:
WebContentsImplTest()
- : ui_thread_(BrowserThread::UI, &message_loop_),
+ : old_client_(NULL),
+ old_browser_client_(NULL),
+ ui_thread_(BrowserThread::UI, &message_loop_),
file_user_blocking_thread_(
BrowserThread::FILE_USER_BLOCKING, &message_loop_),
io_thread_(BrowserThread::IO, &message_loop_) {
}
virtual void SetUp() {
+ // These tests treat webcontentsimpltest as a privileged WebUI scheme.
+ // We must register it similarly to kChromeUIScheme.
+ url_util::AddStandardScheme("webcontentsimpltest");
+
+ old_client_ = GetContentClient();
+ old_browser_client_ = GetContentClient()->browser();
+ SetContentClient(&client_);
+ GetContentClient()->set_browser_for_testing(&browser_client_);
RenderViewHostImplTestHarness::SetUp();
- WebUIControllerFactory::RegisterFactory(&factory_);
}
virtual void TearDown() {
+ GetContentClient()->set_browser_for_testing(old_browser_client_);
+ SetContentClient(old_client_);
RenderViewHostImplTestHarness::TearDown();
- WebUIControllerFactoryRegistry::UnregisterFactoryForTesting(&factory_);
}
private:
- WebContentsImplTestWebUIControllerFactory factory_;
+ WebContentsImplTestContentClient client_;
+ WebContentsImplTestBrowserClient browser_client_;
+ ContentClient* old_client_;
+ ContentBrowserClient* old_browser_client_;
TestBrowserThread ui_thread_;
TestBrowserThread file_user_blocking_thread_;
TestBrowserThread io_thread_;
@@ -315,7 +345,7 @@
TEST_F(WebContentsImplTest, NTPViewSource) {
NavigationControllerImpl& cont =
static_cast<NavigationControllerImpl&>(controller());
- const char kUrl[] = "view-source:chrome://blah";
+ const char kUrl[] = "view-source:webcontentsimpltest://blah";
const GURL kGURL(kUrl);
process()->sink().ClearMessages();
@@ -729,7 +759,7 @@
contents()->transition_cross_site = true;
// Start with a web ui page, which gets a new RVH with WebUI bindings.
- const GURL url1("chrome://blah");
+ const GURL url1("webcontentsimpltest://blah");
controller().LoadURL(
url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
TestRenderViewHost* ntp_rvh = test_rvh();
@@ -866,7 +896,7 @@
contents()->transition_cross_site = true;
// Navigate to NTP URL.
- const GURL url("chrome://blah");
+ const GURL url("webcontentsimpltest://blah");
controller().LoadURL(
url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
TestRenderViewHost* orig_rvh = test_rvh();
@@ -884,7 +914,7 @@
// Suppose the first navigation tries to commit now, with a
// ViewMsg_Stop in flight. This should not cancel the pending navigation,
// but it should act as if the beforeunload ack arrived.
- orig_rvh->SendNavigate(1, GURL("chrome://blah"));
+ orig_rvh->SendNavigate(1, GURL("webcontentsimpltest://blah"));
EXPECT_TRUE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost());
EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack());
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/browser/webui/web_ui_controller_factory_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698