Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 TestRenderViewHost* TestWebContents::GetRenderViewHost() const { | 55 TestRenderViewHost* TestWebContents::GetRenderViewHost() const { |
| 56 return static_cast<TestRenderViewHost*>( | 56 return static_cast<TestRenderViewHost*>( |
| 57 WebContentsImpl::GetRenderViewHost()); | 57 WebContentsImpl::GetRenderViewHost()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 TestRenderFrameHost* TestWebContents::GetPendingMainFrame() const { | 60 TestRenderFrameHost* TestWebContents::GetPendingMainFrame() const { |
| 61 return static_cast<TestRenderFrameHost*>( | 61 return static_cast<TestRenderFrameHost*>( |
| 62 GetRenderManager()->pending_frame_host()); | 62 GetRenderManager()->pending_frame_host()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 TestRenderFrameHost* TestWebContents::GetSpeculativeMainFrame() const { | |
| 66 return static_cast<TestRenderFrameHost*>( | |
| 67 GetRenderManager()->speculative_render_frame_host_.get()); | |
| 68 } | |
| 69 | |
| 65 void TestWebContents::TestDidNavigate(RenderFrameHost* render_frame_host, | 70 void TestWebContents::TestDidNavigate(RenderFrameHost* render_frame_host, |
| 66 int page_id, | 71 int page_id, |
| 67 const GURL& url, | 72 const GURL& url, |
| 68 ui::PageTransition transition) { | 73 ui::PageTransition transition) { |
| 69 TestDidNavigateWithReferrer(render_frame_host, | 74 TestDidNavigateWithReferrer(render_frame_host, |
| 70 page_id, | 75 page_id, |
| 71 url, | 76 url, |
| 72 Referrer(), | 77 Referrer(), |
| 73 transition); | 78 transition); |
| 74 } | 79 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 void TestWebContents::TestSetIsLoading(bool value) { | 169 void TestWebContents::TestSetIsLoading(bool value) { |
| 165 SetIsLoading(GetRenderViewHost(), value, true, NULL); | 170 SetIsLoading(GetRenderViewHost(), value, true, NULL); |
| 166 } | 171 } |
| 167 | 172 |
| 168 void TestWebContents::CommitPendingNavigation() { | 173 void TestWebContents::CommitPendingNavigation() { |
| 169 // If we are doing a cross-site navigation, this simulates the current RVH | 174 // If we are doing a cross-site navigation, this simulates the current RVH |
| 170 // notifying that it has unloaded so the pending RVH is resumed and can | 175 // notifying that it has unloaded so the pending RVH is resumed and can |
| 171 // navigate. | 176 // navigate. |
| 172 ProceedWithCrossSiteNavigation(); | 177 ProceedWithCrossSiteNavigation(); |
| 173 TestRenderFrameHost* old_rfh = GetMainFrame(); | 178 TestRenderFrameHost* old_rfh = GetMainFrame(); |
| 174 TestRenderFrameHost* rfh = GetPendingMainFrame(); | 179 TestRenderFrameHost* rfh; |
| 180 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 181 switches::kEnableBrowserSideNavigation)) { | |
| 182 rfh = GetSpeculativeMainFrame(); | |
|
clamy
2014/12/19 13:35:57
This is one of the cases where having a method tha
carlosk
2014/12/29 16:40:16
Done.
| |
| 183 } else { | |
| 184 rfh = GetPendingMainFrame(); | |
| 185 } | |
| 186 | |
| 175 if (!rfh) | 187 if (!rfh) |
| 176 rfh = old_rfh; | 188 rfh = old_rfh; |
| 177 | 189 |
| 178 const NavigationEntry* entry = GetController().GetPendingEntry(); | 190 const NavigationEntry* entry = GetController().GetPendingEntry(); |
| 179 DCHECK(entry); | 191 DCHECK(entry); |
| 180 int page_id = entry->GetPageID(); | 192 int page_id = entry->GetPageID(); |
| 181 if (page_id == -1) { | 193 if (page_id == -1) { |
| 182 // It's a new navigation, assign a never-seen page id to it. | 194 // It's a new navigation, assign a never-seen page id to it. |
| 183 page_id = GetMaxPageIDForSiteInstance(rfh->GetSiteInstance()) + 1; | 195 page_id = GetMaxPageIDForSiteInstance(rfh->GetSiteInstance()) + 1; |
| 184 } | 196 } |
| 185 | 197 |
| 186 rfh->SendNavigate(page_id, entry->GetURL()); | 198 rfh->SendNavigate(page_id, entry->GetURL()); |
| 187 // Simulate the SwapOut_ACK. This is needed when cross-site navigation happens | 199 // Simulate the SwapOut_ACK. This is needed when cross-site navigation happens |
| 188 // (old_rfh != rfh). | 200 // (old_rfh != rfh). |
| 189 if (old_rfh != rfh) | 201 if (old_rfh != rfh) |
| 190 old_rfh->OnSwappedOut(); | 202 old_rfh->OnSwappedOut(); |
| 191 } | 203 } |
| 192 | 204 |
| 193 void TestWebContents::ProceedWithCrossSiteNavigation() { | 205 void TestWebContents::ProceedWithCrossSiteNavigation() { |
| 194 if (!GetPendingMainFrame()) | 206 // Note: At the moment in the navigation process when this method is called |
|
nasko
2014/12/20 00:09:09
nit: s/process/progress/
carlosk
2014/12/29 16:40:17
(comment was removed)
| |
| 207 // (after the RenderFrameHost committed), the speculative RenderFrameHost, if | |
|
nasko
2014/12/20 00:09:09
"(after the RenderFrameHost committed)" Is this ac
carlosk
2014/12/29 16:40:17
What I meant was that the call to RFH::CommitNavig
clamy
2014/12/29 17:36:21
In the current code path this function is called b
carlosk
2014/12/30 15:54:50
Acknowledged. What I said before was wrong...
| |
| 208 // any, is already guaranteed to be the one that will be made active. That's | |
| 209 // why this works. | |
| 210 if (!GetPendingMainFrame() && !GetSpeculativeMainFrame()) | |
|
clamy
2014/12/19 13:35:57
This function should only be called at the beginni
carlosk
2014/12/29 16:40:17
Done the 1st option as it eases things.
| |
| 195 return; | 211 return; |
| 196 GetMainFrame()->SendBeforeUnloadACK(true); | 212 GetMainFrame()->SendBeforeUnloadACK(true); |
| 197 } | 213 } |
| 198 | 214 |
| 199 RenderViewHostDelegateView* TestWebContents::GetDelegateView() { | 215 RenderViewHostDelegateView* TestWebContents::GetDelegateView() { |
| 200 if (delegate_view_override_) | 216 if (delegate_view_override_) |
| 201 return delegate_view_override_; | 217 return delegate_view_override_; |
| 202 return WebContentsImpl::GetDelegateView(); | 218 return WebContentsImpl::GetDelegateView(); |
| 203 } | 219 } |
| 204 | 220 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 } | 286 } |
| 271 | 287 |
| 272 void TestWebContents::ShowCreatedWidget(int route_id, | 288 void TestWebContents::ShowCreatedWidget(int route_id, |
| 273 const gfx::Rect& initial_pos) { | 289 const gfx::Rect& initial_pos) { |
| 274 } | 290 } |
| 275 | 291 |
| 276 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { | 292 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { |
| 277 } | 293 } |
| 278 | 294 |
| 279 } // namespace content | 295 } // namespace content |
| OLD | NEW |