| Index: content/renderer/render_view_browsertest.cc
|
| ===================================================================
|
| --- content/renderer/render_view_browsertest.cc (revision 175856)
|
| +++ content/renderer/render_view_browsertest.cc (working copy)
|
| @@ -96,11 +96,11 @@
|
| }
|
| virtual bool UseWebUIForURL(BrowserContext* browser_context,
|
| const GURL& url) const OVERRIDE {
|
| - return HasWebUIScheme(url);
|
| + return GetContentClient()->HasWebUIScheme(url);
|
| }
|
| virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
|
| const GURL& url) const OVERRIDE {
|
| - return HasWebUIScheme(url);
|
| + return GetContentClient()->HasWebUIScheme(url);
|
| }
|
| virtual bool IsURLAcceptableForWebUI(
|
| BrowserContext* browser_context,
|
| @@ -110,6 +110,28 @@
|
| }
|
| };
|
|
|
| +class WebUITestClient : public ShellContentClient {
|
| + public:
|
| + WebUITestClient() {
|
| + }
|
| +
|
| + virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE {
|
| + return url.SchemeIs(chrome::kChromeUIScheme);
|
| + }
|
| +};
|
| +
|
| +class WebUITestBrowserClient : public ShellContentBrowserClient {
|
| + public:
|
| + WebUITestBrowserClient() {}
|
| +
|
| + virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE {
|
| + return &factory_;
|
| + }
|
| +
|
| + private:
|
| + WebUITestWebUIControllerFactory factory_;
|
| +};
|
| +
|
| } // namespace
|
|
|
| class RenderViewImplTest : public RenderViewTest {
|
| @@ -320,9 +342,15 @@
|
| }
|
|
|
| TEST_F(RenderViewImplTest, DecideNavigationPolicy) {
|
| - WebUITestWebUIControllerFactory factory;
|
| - WebUIControllerFactory::RegisterFactory(&factory);
|
| + WebUITestClient client;
|
| + WebUITestBrowserClient browser_client;
|
| + ContentClient* old_client = GetContentClient();
|
| + ContentBrowserClient* old_browser_client = GetContentClient()->browser();
|
|
|
| + SetContentClient(&client);
|
| + GetContentClient()->set_browser_for_testing(&browser_client);
|
| + client.set_renderer_for_testing(old_client->renderer());
|
| +
|
| // Navigations to normal HTTP URLs can be handled locally.
|
| WebKit::WebURLRequest request(GURL("http://foo.com"));
|
| WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation(
|
| @@ -356,6 +384,9 @@
|
| WebKit::WebNavigationPolicyNewForegroundTab,
|
| false);
|
| EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy);
|
| +
|
| + GetContentClient()->set_browser_for_testing(old_browser_client);
|
| + SetContentClient(old_client);
|
| }
|
|
|
| TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) {
|
|
|