OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_render_frame.h" | 5 #include "content/test/test_render_frame.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "content/common/navigation_params.h" | 8 #include "content/common/navigation_params.h" |
8 #include "content/common/resource_request_body_impl.h" | 9 #include "content/common/resource_request_body_impl.h" |
| 10 #include "content/public/common/associated_interface_provider.h" |
9 #include "content/public/common/browser_side_navigation_policy.h" | 11 #include "content/public/common/browser_side_navigation_policy.h" |
10 #include "content/public/common/resource_response.h" | 12 #include "content/public/common/resource_response.h" |
| 13 #include "content/public/test/mock_render_thread.h" |
11 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 14 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
12 | 15 |
13 namespace content { | 16 namespace content { |
14 | 17 |
| 18 class MockFrameHostIPC : public mojom::FrameHostIPC { |
| 19 public: |
| 20 MockFrameHostIPC() : binding_(this) {} |
| 21 ~MockFrameHostIPC() override = default; |
| 22 |
| 23 void CreateNewWindow(mojom::CreateNewWindowParamsPtr params, |
| 24 const CreateNewWindowCallback& callback) override { |
| 25 mojom::CreateNewWindowReplyPtr reply = mojom::CreateNewWindowReply::New(); |
| 26 MockRenderThread* mock_render_thread = |
| 27 static_cast<MockRenderThread*>(RenderThread::Get()); |
| 28 mock_render_thread->OnCreateWindow(*params, reply.get()); |
| 29 callback.Run(std::move(reply)); |
| 30 } |
| 31 |
| 32 void Bind(mojo::ScopedInterfaceEndpointHandle handle) { |
| 33 binding_.Bind( |
| 34 mojo::MakeAssociatedRequest<mojom::FrameHostIPC>(std::move(handle))); |
| 35 } |
| 36 |
| 37 private: |
| 38 mojo::AssociatedBinding<mojom::FrameHostIPC> binding_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(MockFrameHostIPC); |
| 41 }; |
| 42 |
15 // static | 43 // static |
16 RenderFrameImpl* TestRenderFrame::CreateTestRenderFrame( | 44 RenderFrameImpl* TestRenderFrame::CreateTestRenderFrame( |
17 const RenderFrameImpl::CreateParams& params) { | 45 const RenderFrameImpl::CreateParams& params) { |
18 return new TestRenderFrame(params); | 46 return new TestRenderFrame(params); |
19 } | 47 } |
20 | 48 |
21 TestRenderFrame::TestRenderFrame(const RenderFrameImpl::CreateParams& params) | 49 TestRenderFrame::TestRenderFrame(const RenderFrameImpl::CreateParams& params) |
22 : RenderFrameImpl(params) { | 50 : RenderFrameImpl(params), |
| 51 mock_frame_host_ipc_(base::MakeUnique<MockFrameHostIPC>()) { |
| 52 GetRemoteAssociatedInterfaces()->OverrideBinderForTesting( |
| 53 mojom::FrameHostIPC::Name_, |
| 54 base::Bind(&MockFrameHostIPC::Bind, |
| 55 base::Unretained(mock_frame_host_ipc_.get()))); |
23 } | 56 } |
24 | 57 |
25 TestRenderFrame::~TestRenderFrame() { | 58 TestRenderFrame::~TestRenderFrame() { |
26 } | 59 } |
27 | 60 |
28 void TestRenderFrame::Navigate(const CommonNavigationParams& common_params, | 61 void TestRenderFrame::Navigate(const CommonNavigationParams& common_params, |
29 const StartNavigationParams& start_params, | 62 const StartNavigationParams& start_params, |
30 const RequestNavigationParams& request_params) { | 63 const RequestNavigationParams& request_params) { |
31 // PlzNavigate | 64 // PlzNavigate |
32 if (IsBrowserSideNavigationEnabled()) { | 65 if (IsBrowserSideNavigationEnabled()) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 GetWebFrame()->Parent() && info.form.IsNull()) { | 116 GetWebFrame()->Parent() && info.form.IsNull()) { |
84 // RenderViewTest::LoadHTML already disables PlzNavigate for the main frame | 117 // RenderViewTest::LoadHTML already disables PlzNavigate for the main frame |
85 // requests. However if the loaded html has a subframe, the WebURLRequest | 118 // requests. However if the loaded html has a subframe, the WebURLRequest |
86 // will be created inside Blink and it won't have this flag set. | 119 // will be created inside Blink and it won't have this flag set. |
87 info.url_request.SetCheckForBrowserSideNavigation(false); | 120 info.url_request.SetCheckForBrowserSideNavigation(false); |
88 } | 121 } |
89 return RenderFrameImpl::DecidePolicyForNavigation(info); | 122 return RenderFrameImpl::DecidePolicyForNavigation(info); |
90 } | 123 } |
91 | 124 |
92 } // namespace content | 125 } // namespace content |
OLD | NEW |