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" |
| 8 #include "content/common/frame.mojom.h" |
7 #include "content/common/navigation_params.h" | 9 #include "content/common/navigation_params.h" |
8 #include "content/common/resource_request_body_impl.h" | 10 #include "content/common/resource_request_body_impl.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() = default; |
| 21 ~MockFrameHostIPC() override = default; |
| 22 |
| 23 void CreateNewWindow(mojom::CreateNewWindowParamsPtr params, |
| 24 const CreateNewWindowCallback& callback) override { |
| 25 // NOTE: This implementation of mojom::FrameHostIPC is used client- |
| 26 // side only. Because sync mojom methods have a different interface for |
| 27 // bindings- and client-side, we only implement the client-side interface |
| 28 // on this object. |
| 29 NOTREACHED(); |
| 30 } |
| 31 |
| 32 bool CreateNewWindow(mojom::CreateNewWindowParamsPtr params, |
| 33 mojom::CreateNewWindowReplyPtr* reply) override { |
| 34 *reply = mojom::CreateNewWindowReply::New(); |
| 35 |
| 36 // It is not very nice to reach directly into the MockRenderThread here. The |
| 37 // logic to create mock frames/windows should potentially live here. |
| 38 MockRenderThread* mock_render_thread = |
| 39 static_cast<MockRenderThread*>(RenderThread::Get()); |
| 40 mock_render_thread->OnCreateWindow(*params, reply->get()); |
| 41 return true; |
| 42 } |
| 43 |
| 44 private: |
| 45 DISALLOW_COPY_AND_ASSIGN(MockFrameHostIPC); |
| 46 }; |
| 47 |
15 // static | 48 // static |
16 RenderFrameImpl* TestRenderFrame::CreateTestRenderFrame( | 49 RenderFrameImpl* TestRenderFrame::CreateTestRenderFrame( |
17 const RenderFrameImpl::CreateParams& params) { | 50 const RenderFrameImpl::CreateParams& params) { |
18 return new TestRenderFrame(params); | 51 return new TestRenderFrame(params); |
19 } | 52 } |
20 | 53 |
21 TestRenderFrame::TestRenderFrame(const RenderFrameImpl::CreateParams& params) | 54 TestRenderFrame::TestRenderFrame(const RenderFrameImpl::CreateParams& params) |
22 : RenderFrameImpl(params) { | 55 : RenderFrameImpl(params) { |
| 56 mock_frame_host_ipc_ = base::MakeUnique<MockFrameHostIPC>(); |
23 } | 57 } |
24 | 58 |
25 TestRenderFrame::~TestRenderFrame() { | 59 TestRenderFrame::~TestRenderFrame() { |
26 } | 60 } |
27 | 61 |
28 void TestRenderFrame::Navigate(const CommonNavigationParams& common_params, | 62 void TestRenderFrame::Navigate(const CommonNavigationParams& common_params, |
29 const StartNavigationParams& start_params, | 63 const StartNavigationParams& start_params, |
30 const RequestNavigationParams& request_params) { | 64 const RequestNavigationParams& request_params) { |
31 // PlzNavigate | 65 // PlzNavigate |
32 if (IsBrowserSideNavigationEnabled()) { | 66 if (IsBrowserSideNavigationEnabled()) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 info.url_request.CheckForBrowserSideNavigation() && | 116 info.url_request.CheckForBrowserSideNavigation() && |
83 GetWebFrame()->Parent() && info.form.IsNull()) { | 117 GetWebFrame()->Parent() && info.form.IsNull()) { |
84 // RenderViewTest::LoadHTML already disables PlzNavigate for the main frame | 118 // RenderViewTest::LoadHTML already disables PlzNavigate for the main frame |
85 // requests. However if the loaded html has a subframe, the WebURLRequest | 119 // 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. | 120 // will be created inside Blink and it won't have this flag set. |
87 info.url_request.SetCheckForBrowserSideNavigation(false); | 121 info.url_request.SetCheckForBrowserSideNavigation(false); |
88 } | 122 } |
89 return RenderFrameImpl::DecidePolicyForNavigation(info); | 123 return RenderFrameImpl::DecidePolicyForNavigation(info); |
90 } | 124 } |
91 | 125 |
| 126 mojom::FrameHostIPC* TestRenderFrame::GetFrameHostIPC() { |
| 127 return mock_frame_host_ipc_.get(); |
| 128 } |
| 129 |
92 } // namespace content | 130 } // namespace content |
OLD | NEW |