OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.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/render_view_host.h" | 8 #include "content/browser/renderer_host/render_view_host.h" |
9 #include "content/browser/renderer_host/render_widget_host_view.h" | 9 #include "content/browser/renderer_host/render_widget_host_view.h" |
10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
11 #include "content/browser/site_instance_impl.h" | 11 #include "content/browser/site_instance_impl.h" |
12 #include "content/browser/tab_contents/interstitial_page.h" | 12 #include "content/browser/tab_contents/interstitial_page.h" |
13 #include "content/browser/tab_contents/navigation_entry_impl.h" | 13 #include "content/browser/tab_contents/navigation_entry_impl.h" |
14 #include "content/browser/tab_contents/test_tab_contents.h" | 14 #include "content/browser/tab_contents/test_tab_contents.h" |
15 #include "content/browser/webui/empty_web_ui_factory.h" | |
16 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
17 #include "content/public/browser/navigation_details.h" | 16 #include "content/public/browser/navigation_details.h" |
18 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
21 #include "content/public/browser/web_ui_controller.h" | 20 #include "content/public/browser/web_ui_controller.h" |
| 21 #include "content/public/browser/web_ui_controller_factory.h" |
22 #include "content/public/common/bindings_policy.h" | 22 #include "content/public/common/bindings_policy.h" |
23 #include "content/public/common/content_constants.h" | 23 #include "content/public/common/content_constants.h" |
24 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
25 #include "content/test/test_browser_thread.h" | 25 #include "content/test/test_browser_thread.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
28 | 28 |
| 29 using content::BrowserContext; |
29 using content::BrowserThread; | 30 using content::BrowserThread; |
30 using content::NavigationEntry; | 31 using content::NavigationEntry; |
31 using content::NavigationEntryImpl; | 32 using content::NavigationEntryImpl; |
32 using content::SiteInstance; | 33 using content::SiteInstance; |
33 using content::WebContents; | 34 using content::WebContents; |
| 35 using content::WebUI; |
34 using content::WebUIController; | 36 using content::WebUIController; |
35 using webkit::forms::PasswordForm; | 37 using webkit::forms::PasswordForm; |
36 | 38 |
37 namespace { | 39 namespace { |
38 | 40 |
39 class TabContentsTestWebUIFactory : public content::EmptyWebUIFactory { | 41 class TabContentsTestWebUIControllerFactory |
| 42 : public content::WebUIControllerFactory { |
40 public: | 43 public: |
41 virtual WebUIController* CreateWebUIForURL(content::WebUI* web_ui, | 44 virtual WebUIController* CreateWebUIControllerForURL( |
42 const GURL& url) const OVERRIDE { | 45 content::WebUI* web_ui, const GURL& url) const OVERRIDE { |
43 if (!HasWebUIScheme(url)) | 46 if (!HasWebUIScheme(url)) |
44 return NULL; | 47 return NULL; |
45 | 48 |
46 return new WebUIController(web_ui); | 49 return new WebUIController(web_ui); |
47 } | 50 } |
48 | 51 |
49 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, | 52 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, |
| 53 const GURL& url) const OVERRIDE { |
| 54 return WebUI::kNoWebUI; |
| 55 } |
| 56 |
| 57 virtual bool UseWebUIForURL(BrowserContext* browser_context, |
50 const GURL& url) const OVERRIDE { | 58 const GURL& url) const OVERRIDE { |
51 return HasWebUIScheme(url); | 59 return HasWebUIScheme(url); |
52 } | 60 } |
53 | 61 |
| 62 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, |
| 63 const GURL& url) const OVERRIDE { |
| 64 return HasWebUIScheme(url); |
| 65 } |
| 66 |
54 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { | 67 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
55 return url.SchemeIs("tabcontentstest"); | 68 return url.SchemeIs("tabcontentstest"); |
56 } | 69 } |
57 | 70 |
58 virtual bool IsURLAcceptableForWebUI(content::BrowserContext* browser_context, | 71 virtual bool IsURLAcceptableForWebUI( |
59 const GURL& url) const { | 72 BrowserContext* browser_context, const GURL& url) const { |
60 return HasWebUIScheme(url); | 73 return HasWebUIScheme(url); |
61 } | 74 } |
62 }; | 75 }; |
63 | 76 |
64 class TabContentsTestBrowserClient : public content::MockContentBrowserClient { | 77 class TabContentsTestBrowserClient : public content::MockContentBrowserClient { |
65 public: | 78 public: |
66 TabContentsTestBrowserClient() { | 79 TabContentsTestBrowserClient() { |
67 } | 80 } |
68 | 81 |
69 virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE { | 82 virtual content::WebUIControllerFactory* |
| 83 GetWebUIControllerFactory() OVERRIDE { |
70 return &factory_; | 84 return &factory_; |
71 } | 85 } |
72 | 86 |
73 private: | 87 private: |
74 TabContentsTestWebUIFactory factory_; | 88 TabContentsTestWebUIControllerFactory factory_; |
75 }; | 89 }; |
76 | 90 |
77 class TestInterstitialPage : public InterstitialPage { | 91 class TestInterstitialPage : public InterstitialPage { |
78 public: | 92 public: |
79 enum InterstitialState { | 93 enum InterstitialState { |
80 UNDECIDED = 0, // No decision taken yet. | 94 UNDECIDED = 0, // No decision taken yet. |
81 OKED, // Proceed was called. | 95 OKED, // Proceed was called. |
82 CANCELED // DontProceed was called. | 96 CANCELED // DontProceed was called. |
83 }; | 97 }; |
84 | 98 |
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 | 1838 |
1825 // It should have a transient entry. | 1839 // It should have a transient entry. |
1826 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1840 EXPECT_TRUE(other_controller.GetTransientEntry()); |
1827 | 1841 |
1828 // And the interstitial should be showing. | 1842 // And the interstitial should be showing. |
1829 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); | 1843 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); |
1830 | 1844 |
1831 // And the interstitial should do a reload on don't proceed. | 1845 // And the interstitial should do a reload on don't proceed. |
1832 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); | 1846 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); |
1833 } | 1847 } |
OLD | NEW |