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 12 matching lines...) Expand all Loading... |
23 #include "content/test/test_notification_tracker.h" | 23 #include "content/test/test_notification_tracker.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "googleurl/src/url_util.h" | 25 #include "googleurl/src/url_util.h" |
26 #include "webkit/glue/webkit_glue.h" | 26 #include "webkit/glue/webkit_glue.h" |
27 | 27 |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
29 using content::BrowserThreadImpl; | 29 using content::BrowserThreadImpl; |
30 using content::NavigationController; | 30 using content::NavigationController; |
31 using content::NavigationEntry; | 31 using content::NavigationEntry; |
32 using content::NavigationEntryImpl; | 32 using content::NavigationEntryImpl; |
| 33 using content::WebContents; |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 const char kChromeUISchemeButNotWebUIURL[] = "chrome://not-webui"; | 37 const char kChromeUISchemeButNotWebUIURL[] = "chrome://not-webui"; |
37 | 38 |
38 class RenderViewHostManagerTestWebUIFactory | 39 class RenderViewHostManagerTestWebUIFactory |
39 : public content::EmptyWebUIFactory { | 40 : public content::EmptyWebUIFactory { |
40 public: | 41 public: |
41 RenderViewHostManagerTestWebUIFactory() | 42 RenderViewHostManagerTestWebUIFactory() |
42 : should_create_webui_(false) { | 43 : should_create_webui_(false) { |
43 } | 44 } |
44 virtual ~RenderViewHostManagerTestWebUIFactory() {} | 45 virtual ~RenderViewHostManagerTestWebUIFactory() {} |
45 | 46 |
46 void set_should_create_webui(bool should_create_webui) { | 47 void set_should_create_webui(bool should_create_webui) { |
47 should_create_webui_ = should_create_webui; | 48 should_create_webui_ = should_create_webui; |
48 } | 49 } |
49 | 50 |
50 // WebUIFactory implementation. | 51 // WebUIFactory implementation. |
51 virtual WebUI* CreateWebUIForURL(TabContents* source, | 52 virtual WebUI* CreateWebUIForURL(WebContents* source, |
52 const GURL& url) const OVERRIDE { | 53 const GURL& url) const OVERRIDE { |
53 if (!(should_create_webui_ && HasWebUIScheme(url))) | 54 if (!(should_create_webui_ && HasWebUIScheme(url))) |
54 return NULL; | 55 return NULL; |
55 return new WebUI(source); | 56 return new WebUI(source); |
56 } | 57 } |
57 | 58 |
58 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, | 59 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, |
59 const GURL& url) const OVERRIDE { | 60 const GURL& url) const OVERRIDE { |
60 return HasWebUIScheme(url); | 61 return HasWebUIScheme(url); |
61 } | 62 } |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 // current one. | 613 // current one. |
613 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 614 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
614 pending_render_view_host() == NULL); | 615 pending_render_view_host() == NULL); |
615 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); | 616 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); |
616 | 617 |
617 // Also we should not have a pending navigation entry. | 618 // Also we should not have a pending navigation entry. |
618 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); | 619 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); |
619 ASSERT_TRUE(entry != NULL); | 620 ASSERT_TRUE(entry != NULL); |
620 EXPECT_EQ(kUrl2, entry->GetURL()); | 621 EXPECT_EQ(kUrl2, entry->GetURL()); |
621 } | 622 } |
OLD | NEW |