Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/browser_thread_impl.h" | 5 #include "content/browser/browser_thread_impl.h" |
| 6 #include "content/browser/browser_url_handler.h" | 6 #include "content/browser/browser_url_handler.h" |
| 7 #include "content/browser/mock_content_browser_client.h" | 7 #include "content/browser/mock_content_browser_client.h" |
| 8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
| 9 #include "content/browser/site_instance.h" | 9 #include "content/browser/site_instance.h" |
| 10 #include "content/browser/tab_contents/navigation_controller_impl.h" | 10 #include "content/browser/tab_contents/navigation_controller_impl.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "googleurl/src/url_util.h" | 26 #include "googleurl/src/url_util.h" |
| 27 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
| 28 | 28 |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 using content::BrowserThreadImpl; | 30 using content::BrowserThreadImpl; |
| 31 using content::NavigationController; | 31 using content::NavigationController; |
| 32 using content::NavigationEntry; | 32 using content::NavigationEntry; |
| 33 using content::NavigationEntryImpl; | 33 using content::NavigationEntryImpl; |
| 34 using content::WebContents; | 34 using content::WebContents; |
| 35 using content::WebUIController; | |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 const char kChromeUISchemeButNotWebUIURL[] = "chrome://not-webui"; | 39 const char kChromeUISchemeButNotWebUIURL[] = "chrome://not-webui"; |
| 39 | 40 |
| 40 class RenderViewHostManagerTestWebUIFactory | 41 class RenderViewHostManagerTestWebUIFactory |
| 41 : public content::EmptyWebUIFactory { | 42 : public content::EmptyWebUIFactory { |
| 42 public: | 43 public: |
| 43 RenderViewHostManagerTestWebUIFactory() | 44 RenderViewHostManagerTestWebUIFactory() |
| 44 : should_create_webui_(false) { | 45 : should_create_webui_(false) { |
| 45 } | 46 } |
| 46 virtual ~RenderViewHostManagerTestWebUIFactory() {} | 47 virtual ~RenderViewHostManagerTestWebUIFactory() {} |
| 47 | 48 |
| 48 void set_should_create_webui(bool should_create_webui) { | 49 void set_should_create_webui(bool should_create_webui) { |
| 49 should_create_webui_ = should_create_webui; | 50 should_create_webui_ = should_create_webui; |
| 50 } | 51 } |
| 51 | 52 |
| 52 // WebUIFactory implementation. | 53 // WebUIFactory implementation. |
| 53 virtual WebUI* CreateWebUIForURL(WebContents* source, | 54 virtual WebUIController* CreateWebUIForURL(WebUI* web_ui, |
|
Evan Stade
2012/01/17 19:14:56
ditto
| |
| 54 const GURL& url) const OVERRIDE { | 55 const GURL& url) const OVERRIDE { |
| 55 if (!(should_create_webui_ && HasWebUIScheme(url))) | 56 if (!(should_create_webui_ && HasWebUIScheme(url))) |
| 56 return NULL; | 57 return NULL; |
| 57 static content::WebUIController temp_controller; | 58 return new WebUIController(web_ui); |
| 58 return new WebUI(source, &temp_controller); | |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, | 61 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, |
| 62 const GURL& url) const OVERRIDE { | 62 const GURL& url) const OVERRIDE { |
| 63 return HasWebUIScheme(url); | 63 return HasWebUIScheme(url); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, | 66 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, |
| 67 const GURL& url) const OVERRIDE { | 67 const GURL& url) const OVERRIDE { |
| 68 return HasWebUIScheme(url); | 68 return HasWebUIScheme(url); |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 // current one. | 615 // current one. |
| 616 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 616 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
| 617 pending_render_view_host() == NULL); | 617 pending_render_view_host() == NULL); |
| 618 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); | 618 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); |
| 619 | 619 |
| 620 // Also we should not have a pending navigation entry. | 620 // Also we should not have a pending navigation entry. |
| 621 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); | 621 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); |
| 622 ASSERT_TRUE(entry != NULL); | 622 ASSERT_TRUE(entry != NULL); |
| 623 EXPECT_EQ(kUrl2, entry->GetURL()); | 623 EXPECT_EQ(kUrl2, entry->GetURL()); |
| 624 } | 624 } |
| OLD | NEW |