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/test/test_web_contents.h" | 5 #include "content/test/test_web_contents.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "content/browser/browser_url_handler_impl.h" | 10 #include "content/browser/browser_url_handler_impl.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "content/public/common/page_state.h" | 23 #include "content/public/common/page_state.h" |
24 #include "content/public/test/mock_render_process_host.h" | 24 #include "content/public/test/mock_render_process_host.h" |
25 #include "content/test/test_render_view_host.h" | 25 #include "content/test/test_render_view_host.h" |
26 #include "ui/base/page_transition_types.h" | 26 #include "ui/base/page_transition_types.h" |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 | 29 |
30 TestWebContents::TestWebContents(BrowserContext* browser_context) | 30 TestWebContents::TestWebContents(BrowserContext* browser_context) |
31 : WebContentsImpl(browser_context, NULL), | 31 : WebContentsImpl(browser_context), |
32 delegate_view_override_(NULL), | 32 delegate_view_override_(NULL), |
33 expect_set_history_offset_and_length_(false), | 33 expect_set_history_offset_and_length_(false), |
34 expect_set_history_offset_and_length_history_length_(0) { | 34 expect_set_history_offset_and_length_history_length_(0) { |
35 } | 35 } |
36 | 36 |
37 TestWebContents* TestWebContents::Create(BrowserContext* browser_context, | 37 TestWebContents* TestWebContents::Create(BrowserContext* browser_context, |
38 SiteInstance* instance) { | 38 SiteInstance* instance) { |
39 TestWebContents* test_web_contents = new TestWebContents(browser_context); | 39 TestWebContents* test_web_contents = new TestWebContents(browser_context); |
40 test_web_contents->Init(WebContents::CreateParams(browser_context, instance)); | 40 test_web_contents->Init(WebContents::CreateParams(browser_context, instance)); |
41 return test_web_contents; | 41 return test_web_contents; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 GetMainFrame()->SendBeforeUnloadACK(true); | 209 GetMainFrame()->SendBeforeUnloadACK(true); |
210 } | 210 } |
211 | 211 |
212 RenderViewHostDelegateView* TestWebContents::GetDelegateView() { | 212 RenderViewHostDelegateView* TestWebContents::GetDelegateView() { |
213 if (delegate_view_override_) | 213 if (delegate_view_override_) |
214 return delegate_view_override_; | 214 return delegate_view_override_; |
215 return WebContentsImpl::GetDelegateView(); | 215 return WebContentsImpl::GetDelegateView(); |
216 } | 216 } |
217 | 217 |
218 void TestWebContents::SetOpener(TestWebContents* opener) { | 218 void TestWebContents::SetOpener(TestWebContents* opener) { |
219 // This is normally only set in the WebContents constructor, which also | 219 frame_tree_.root()->SetOpener(opener->GetFrameTree()->root()); |
220 // registers an observer for when the opener gets closed. | |
221 opener_ = opener; | |
222 AddDestructionObserver(opener_); | |
223 } | 220 } |
224 | 221 |
225 void TestWebContents::AddPendingContents(TestWebContents* contents) { | 222 void TestWebContents::AddPendingContents(TestWebContents* contents) { |
226 // This is normally only done in WebContentsImpl::CreateNewWindow. | 223 // This is normally only done in WebContentsImpl::CreateNewWindow. |
227 pending_contents_[contents->GetRenderViewHost()->GetRoutingID()] = contents; | 224 pending_contents_[contents->GetRenderViewHost()->GetRoutingID()] = contents; |
228 AddDestructionObserver(contents); | 225 AddDestructionObserver(contents); |
229 } | 226 } |
230 | 227 |
231 void TestWebContents::ExpectSetHistoryOffsetAndLength(int history_offset, | 228 void TestWebContents::ExpectSetHistoryOffsetAndLength(int history_offset, |
232 int history_length) { | 229 int history_length) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { | 286 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { |
290 } | 287 } |
291 | 288 |
292 void TestWebContents::SaveFrameWithHeaders(const GURL& url, | 289 void TestWebContents::SaveFrameWithHeaders(const GURL& url, |
293 const Referrer& referrer, | 290 const Referrer& referrer, |
294 const std::string& headers) { | 291 const std::string& headers) { |
295 save_frame_headers_ = headers; | 292 save_frame_headers_ = headers; |
296 } | 293 } |
297 | 294 |
298 } // namespace content | 295 } // namespace content |
OLD | NEW |