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 "content/browser/web_contents/test_web_contents.h" | 5 #include "content/browser/web_contents/test_web_contents.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "content/browser/browser_url_handler_impl.h" | 9 #include "content/browser/browser_url_handler_impl.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
11 #include "content/browser/renderer_host/test_render_view_host.h" | 11 #include "content/browser/renderer_host/test_render_view_host.h" |
12 #include "content/browser/site_instance_impl.h" | 12 #include "content/browser/site_instance_impl.h" |
13 #include "content/browser/web_contents/navigation_entry_impl.h" | 13 #include "content/browser/web_contents/navigation_entry_impl.h" |
14 #include "content/common/view_messages.h" | 14 #include "content/common/view_messages.h" |
15 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
16 #include "content/test/mock_render_process_host.h" | 16 #include "content/test/mock_render_process_host.h" |
17 #include "webkit/forms/password_form.h" | 17 #include "webkit/forms/password_form.h" |
18 #include "webkit/glue/webkit_glue.h" | 18 #include "webkit/glue/webkit_glue.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 TestWebContents::TestWebContents(BrowserContext* browser_context, | 22 TestWebContents::TestWebContents(BrowserContext* browser_context, |
23 SiteInstance* instance) | 23 SiteInstance* instance) |
24 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), | 24 : WebContentsImpl(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), |
25 transition_cross_site(false), | 25 transition_cross_site(false), |
26 delegate_view_override_(NULL), | 26 delegate_view_override_(NULL), |
27 expect_set_history_length_and_prune_(false), | 27 expect_set_history_length_and_prune_(false), |
28 expect_set_history_length_and_prune_site_instance_(NULL), | 28 expect_set_history_length_and_prune_site_instance_(NULL), |
29 expect_set_history_length_and_prune_history_length_(0), | 29 expect_set_history_length_and_prune_history_length_(0), |
30 expect_set_history_length_and_prune_min_page_id_(-1) { | 30 expect_set_history_length_and_prune_min_page_id_(-1) { |
31 } | 31 } |
32 | 32 |
33 TestWebContents::~TestWebContents() { | 33 TestWebContents::~TestWebContents() { |
34 } | 34 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 bool TestWebContents::CreateRenderViewForRenderManager( | 85 bool TestWebContents::CreateRenderViewForRenderManager( |
86 RenderViewHost* render_view_host) { | 86 RenderViewHost* render_view_host) { |
87 // This will go to a TestRenderViewHost. | 87 // This will go to a TestRenderViewHost. |
88 static_cast<RenderViewHostImpl*>( | 88 static_cast<RenderViewHostImpl*>( |
89 render_view_host)->CreateRenderView(string16(), -1); | 89 render_view_host)->CreateRenderView(string16(), -1); |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 WebContents* TestWebContents::Clone() { | 93 WebContents* TestWebContents::Clone() { |
94 TabContents* tc = new TestWebContents( | 94 WebContentsImpl* contents = new TestWebContents( |
95 GetBrowserContext(), | 95 GetBrowserContext(), |
96 SiteInstance::Create(GetBrowserContext())); | 96 SiteInstance::Create(GetBrowserContext())); |
97 tc->GetControllerImpl().CopyStateFrom(controller_); | 97 contents->GetControllerImpl().CopyStateFrom(controller_); |
98 return tc; | 98 return contents; |
99 } | 99 } |
100 | 100 |
101 void TestWebContents::NavigateAndCommit(const GURL& url) { | 101 void TestWebContents::NavigateAndCommit(const GURL& url) { |
102 GetController().LoadURL( | 102 GetController().LoadURL( |
103 url, Referrer(), PAGE_TRANSITION_LINK, std::string()); | 103 url, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
104 GURL loaded_url(url); | 104 GURL loaded_url(url); |
105 bool reverse_on_redirect = false; | 105 bool reverse_on_redirect = false; |
106 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary( | 106 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary( |
107 &loaded_url, GetBrowserContext(), &reverse_on_redirect); | 107 &loaded_url, GetBrowserContext(), &reverse_on_redirect); |
108 | 108 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 if (!GetPendingRenderViewHost()) | 146 if (!GetPendingRenderViewHost()) |
147 return; | 147 return; |
148 TestRenderViewHost* rvh = static_cast<TestRenderViewHost*>( | 148 TestRenderViewHost* rvh = static_cast<TestRenderViewHost*>( |
149 render_manager_.current_host()); | 149 render_manager_.current_host()); |
150 rvh->SendShouldCloseACK(true); | 150 rvh->SendShouldCloseACK(true); |
151 } | 151 } |
152 | 152 |
153 RenderViewHostDelegate::View* TestWebContents::GetViewDelegate() { | 153 RenderViewHostDelegate::View* TestWebContents::GetViewDelegate() { |
154 if (delegate_view_override_) | 154 if (delegate_view_override_) |
155 return delegate_view_override_; | 155 return delegate_view_override_; |
156 return TabContents::GetViewDelegate(); | 156 return WebContentsImpl::GetViewDelegate(); |
157 } | 157 } |
158 | 158 |
159 void TestWebContents::ExpectSetHistoryLengthAndPrune( | 159 void TestWebContents::ExpectSetHistoryLengthAndPrune( |
160 const SiteInstance* site_instance, | 160 const SiteInstance* site_instance, |
161 int history_length, | 161 int history_length, |
162 int32 min_page_id) { | 162 int32 min_page_id) { |
163 expect_set_history_length_and_prune_ = true; | 163 expect_set_history_length_and_prune_ = true; |
164 expect_set_history_length_and_prune_site_instance_ = | 164 expect_set_history_length_and_prune_site_instance_ = |
165 static_cast<const SiteInstanceImpl*>(site_instance); | 165 static_cast<const SiteInstanceImpl*>(site_instance); |
166 expect_set_history_length_and_prune_history_length_ = history_length; | 166 expect_set_history_length_and_prune_history_length_ = history_length; |
167 expect_set_history_length_and_prune_min_page_id_ = min_page_id; | 167 expect_set_history_length_and_prune_min_page_id_ = min_page_id; |
168 } | 168 } |
169 | 169 |
170 void TestWebContents::SetHistoryLengthAndPrune( | 170 void TestWebContents::SetHistoryLengthAndPrune( |
171 const SiteInstance* site_instance, int history_length, | 171 const SiteInstance* site_instance, int history_length, |
172 int32 min_page_id) { | 172 int32 min_page_id) { |
173 EXPECT_TRUE(expect_set_history_length_and_prune_); | 173 EXPECT_TRUE(expect_set_history_length_and_prune_); |
174 expect_set_history_length_and_prune_ = false; | 174 expect_set_history_length_and_prune_ = false; |
175 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); | 175 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); |
176 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, | 176 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, |
177 history_length); | 177 history_length); |
178 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); | 178 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); |
179 } | 179 } |
180 | 180 |
181 } // namespace content | 181 } // namespace content |
OLD | NEW |