| 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" |
| 11 #include "content/browser/tab_contents/navigation_entry_impl.h" | 11 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 12 #include "content/browser/tab_contents/render_view_host_manager.h" | 12 #include "content/browser/tab_contents/render_view_host_manager.h" |
| 13 #include "content/browser/tab_contents/test_tab_contents.h" | 13 #include "content/browser/tab_contents/test_tab_contents.h" |
| 14 #include "content/browser/webui/empty_web_ui_factory.h" | 14 #include "content/browser/webui/empty_web_ui_factory.h" |
| 15 #include "content/common/test_url_constants.h" | 15 #include "content/common/test_url_constants.h" |
| 16 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 20 #include "content/public/browser/web_ui_controller.h" |
| 20 #include "content/public/common/page_transition_types.h" | 21 #include "content/public/common/page_transition_types.h" |
| 21 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
| 22 #include "content/test/test_browser_context.h" | 23 #include "content/test/test_browser_context.h" |
| 23 #include "content/test/test_notification_tracker.h" | 24 #include "content/test/test_notification_tracker.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "googleurl/src/url_util.h" | 26 #include "googleurl/src/url_util.h" |
| 26 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
| 27 | 28 |
| 28 using content::BrowserThread; | 29 using content::BrowserThread; |
| 29 using content::BrowserThreadImpl; | 30 using content::BrowserThreadImpl; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 46 | 47 |
| 47 void set_should_create_webui(bool should_create_webui) { | 48 void set_should_create_webui(bool should_create_webui) { |
| 48 should_create_webui_ = should_create_webui; | 49 should_create_webui_ = should_create_webui; |
| 49 } | 50 } |
| 50 | 51 |
| 51 // WebUIFactory implementation. | 52 // WebUIFactory implementation. |
| 52 virtual WebUI* CreateWebUIForURL(WebContents* source, | 53 virtual WebUI* CreateWebUIForURL(WebContents* source, |
| 53 const GURL& url) const OVERRIDE { | 54 const GURL& url) const OVERRIDE { |
| 54 if (!(should_create_webui_ && HasWebUIScheme(url))) | 55 if (!(should_create_webui_ && HasWebUIScheme(url))) |
| 55 return NULL; | 56 return NULL; |
| 56 return new WebUI(source); | 57 static content::WebUIController temp_controller; |
| 58 return new WebUI(source, &temp_controller); |
| 57 } | 59 } |
| 58 | 60 |
| 59 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, | 61 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, |
| 60 const GURL& url) const OVERRIDE { | 62 const GURL& url) const OVERRIDE { |
| 61 return HasWebUIScheme(url); | 63 return HasWebUIScheme(url); |
| 62 } | 64 } |
| 63 | 65 |
| 64 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, | 66 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, |
| 65 const GURL& url) const OVERRIDE { | 67 const GURL& url) const OVERRIDE { |
| 66 return HasWebUIScheme(url); | 68 return HasWebUIScheme(url); |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // current one. | 615 // current one. |
| 614 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 616 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
| 615 pending_render_view_host() == NULL); | 617 pending_render_view_host() == NULL); |
| 616 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); | 618 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); |
| 617 | 619 |
| 618 // Also we should not have a pending navigation entry. | 620 // Also we should not have a pending navigation entry. |
| 619 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); | 621 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); |
| 620 ASSERT_TRUE(entry != NULL); | 622 ASSERT_TRUE(entry != NULL); |
| 621 EXPECT_EQ(kUrl2, entry->GetURL()); | 623 EXPECT_EQ(kUrl2, entry->GetURL()); |
| 622 } | 624 } |
| OLD | NEW |