| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 GetMainFrame()->SendBeforeUnloadACK(true); | 212 GetMainFrame()->SendBeforeUnloadACK(true); |
| 213 } | 213 } |
| 214 | 214 |
| 215 RenderViewHostDelegateView* TestWebContents::GetDelegateView() { | 215 RenderViewHostDelegateView* TestWebContents::GetDelegateView() { |
| 216 if (delegate_view_override_) | 216 if (delegate_view_override_) |
| 217 return delegate_view_override_; | 217 return delegate_view_override_; |
| 218 return WebContentsImpl::GetDelegateView(); | 218 return WebContentsImpl::GetDelegateView(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void TestWebContents::SetOpener(TestWebContents* opener) { | 221 void TestWebContents::SetOpener(TestWebContents* opener) { |
| 222 // This is normally only set in the WebContents constructor, which also | 222 frame_tree_.root()->SetOpener(opener->GetFrameTree()->root()); |
| 223 // registers an observer for when the opener gets closed. | |
| 224 opener_ = opener; | |
| 225 AddDestructionObserver(opener_); | |
| 226 } | 223 } |
| 227 | 224 |
| 228 void TestWebContents::AddPendingContents(TestWebContents* contents) { | 225 void TestWebContents::AddPendingContents(TestWebContents* contents) { |
| 229 // This is normally only done in WebContentsImpl::CreateNewWindow. | 226 // This is normally only done in WebContentsImpl::CreateNewWindow. |
| 230 pending_contents_[contents->GetRenderViewHost()->GetRoutingID()] = contents; | 227 pending_contents_[contents->GetRenderViewHost()->GetRoutingID()] = contents; |
| 231 AddDestructionObserver(contents); | 228 AddDestructionObserver(contents); |
| 232 } | 229 } |
| 233 | 230 |
| 234 void TestWebContents::ExpectSetHistoryOffsetAndLength(int history_offset, | 231 void TestWebContents::ExpectSetHistoryOffsetAndLength(int history_offset, |
| 235 int history_length) { | 232 int history_length) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { | 289 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { |
| 293 } | 290 } |
| 294 | 291 |
| 295 void TestWebContents::SaveFrameWithHeaders(const GURL& url, | 292 void TestWebContents::SaveFrameWithHeaders(const GURL& url, |
| 296 const Referrer& referrer, | 293 const Referrer& referrer, |
| 297 const std::string& headers) { | 294 const std::string& headers) { |
| 298 save_frame_headers_ = headers; | 295 save_frame_headers_ = headers; |
| 299 } | 296 } |
| 300 | 297 |
| 301 } // namespace content | 298 } // namespace content |
| OLD | NEW |