OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_host.h" | 5 #include "content/test/test_render_frame_host.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" |
9 #include "content/browser/frame_host/navigation_handle_impl.h" | 9 #include "content/browser/frame_host/navigation_handle_impl.h" |
10 #include "content/browser/frame_host/navigation_request.h" | 10 #include "content/browser/frame_host/navigation_request.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 222 } |
223 | 223 |
224 void TestRenderFrameHost::SimulateSwapOutACK() { | 224 void TestRenderFrameHost::SimulateSwapOutACK() { |
225 OnSwappedOut(); | 225 OnSwappedOut(); |
226 } | 226 } |
227 | 227 |
228 void TestRenderFrameHost::SendNavigate(int page_id, | 228 void TestRenderFrameHost::SendNavigate(int page_id, |
229 int nav_entry_id, | 229 int nav_entry_id, |
230 bool did_create_new_entry, | 230 bool did_create_new_entry, |
231 const GURL& url) { | 231 const GURL& url) { |
232 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, url, | 232 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, false, |
233 ui::PAGE_TRANSITION_LINK, 200, | 233 url, ui::PAGE_TRANSITION_LINK, 200, |
234 ModificationCallback()); | 234 ModificationCallback()); |
235 } | 235 } |
236 | 236 |
237 void TestRenderFrameHost::SendFailedNavigate(int page_id, | 237 void TestRenderFrameHost::SendFailedNavigate(int page_id, |
238 int nav_entry_id, | 238 int nav_entry_id, |
239 bool did_create_new_entry, | 239 bool did_create_new_entry, |
240 const GURL& url) { | 240 const GURL& url) { |
241 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, url, | 241 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, false, |
242 ui::PAGE_TRANSITION_RELOAD, 500, | 242 url, ui::PAGE_TRANSITION_RELOAD, 500, |
243 ModificationCallback()); | 243 ModificationCallback()); |
244 } | 244 } |
245 | 245 |
246 void TestRenderFrameHost::SendNavigateWithTransition( | 246 void TestRenderFrameHost::SendNavigateWithTransition( |
247 int page_id, | 247 int page_id, |
248 int nav_entry_id, | 248 int nav_entry_id, |
249 bool did_create_new_entry, | 249 bool did_create_new_entry, |
250 const GURL& url, | 250 const GURL& url, |
251 ui::PageTransition transition) { | 251 ui::PageTransition transition) { |
252 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, url, | 252 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, false, |
253 transition, 200, ModificationCallback()); | 253 url, transition, 200, ModificationCallback()); |
| 254 } |
| 255 |
| 256 void TestRenderFrameHost::SendNavigateWithReplacement(int page_id, |
| 257 int nav_entry_id, |
| 258 bool did_create_new_entry, |
| 259 const GURL& url) { |
| 260 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, true, |
| 261 url, ui::PAGE_TRANSITION_LINK, 200, |
| 262 ModificationCallback()); |
254 } | 263 } |
255 | 264 |
256 void TestRenderFrameHost::SendNavigateWithModificationCallback( | 265 void TestRenderFrameHost::SendNavigateWithModificationCallback( |
257 int page_id, | 266 int page_id, |
258 int nav_entry_id, | 267 int nav_entry_id, |
259 bool did_create_new_entry, | 268 bool did_create_new_entry, |
260 const GURL& url, | 269 const GURL& url, |
261 const ModificationCallback& callback) { | 270 const ModificationCallback& callback) { |
262 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, url, | 271 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, false, |
263 ui::PAGE_TRANSITION_LINK, 200, callback); | 272 url, ui::PAGE_TRANSITION_LINK, 200, callback); |
264 } | 273 } |
265 | 274 |
266 void TestRenderFrameHost::SendNavigateWithParameters( | 275 void TestRenderFrameHost::SendNavigateWithParameters( |
267 int page_id, | 276 int page_id, |
268 int nav_entry_id, | 277 int nav_entry_id, |
269 bool did_create_new_entry, | 278 bool did_create_new_entry, |
| 279 bool should_replace_entry, |
270 const GURL& url, | 280 const GURL& url, |
271 ui::PageTransition transition, | 281 ui::PageTransition transition, |
272 int response_code, | 282 int response_code, |
273 const ModificationCallback& callback) { | 283 const ModificationCallback& callback) { |
274 if (!IsBrowserSideNavigationEnabled()) | 284 if (!IsBrowserSideNavigationEnabled()) |
275 OnDidStartLoading(true); | 285 OnDidStartLoading(true); |
276 | 286 |
277 // DidStartProvisionalLoad may delete the pending entry that holds |url|, | 287 // DidStartProvisionalLoad may delete the pending entry that holds |url|, |
278 // so we keep a copy of it to use below. | 288 // so we keep a copy of it to use below. |
279 GURL url_copy(url); | 289 GURL url_copy(url); |
280 OnDidStartProvisionalLoad(url_copy, base::TimeTicks::Now()); | 290 OnDidStartProvisionalLoad(url_copy, base::TimeTicks::Now()); |
281 | 291 |
282 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 292 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
283 params.page_id = page_id; | 293 params.page_id = page_id; |
284 params.nav_entry_id = nav_entry_id; | 294 params.nav_entry_id = nav_entry_id; |
285 params.url = url_copy; | 295 params.url = url_copy; |
286 params.transition = transition; | 296 params.transition = transition; |
287 params.should_update_history = true; | 297 params.should_update_history = true; |
288 params.did_create_new_entry = did_create_new_entry; | 298 params.did_create_new_entry = did_create_new_entry; |
| 299 params.should_replace_current_entry = should_replace_entry; |
289 params.gesture = NavigationGestureUser; | 300 params.gesture = NavigationGestureUser; |
290 params.contents_mime_type = contents_mime_type_; | 301 params.contents_mime_type = contents_mime_type_; |
291 params.is_post = false; | 302 params.is_post = false; |
292 params.http_status_code = response_code; | 303 params.http_status_code = response_code; |
293 params.socket_address.set_host("2001:db8::1"); | 304 params.socket_address.set_host("2001:db8::1"); |
294 params.socket_address.set_port(80); | 305 params.socket_address.set_port(80); |
295 params.history_list_was_cleared = simulate_history_list_was_cleared_; | 306 params.history_list_was_cleared = simulate_history_list_was_cleared_; |
296 params.original_request_url = url_copy; | 307 params.original_request_url = url_copy; |
297 | 308 |
298 // In most cases, the origin will match the URL's origin. Tests that need to | 309 // In most cases, the origin will match the URL's origin. Tests that need to |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // cleared during DidFailProvisionalLoad). | 429 // cleared during DidFailProvisionalLoad). |
419 int page_id = entry ? entry->GetPageID() : -1; | 430 int page_id = entry ? entry->GetPageID() : -1; |
420 if (page_id == -1) { | 431 if (page_id == -1) { |
421 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(delegate()); | 432 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(delegate()); |
422 page_id = web_contents->GetMaxPageIDForSiteInstance(GetSiteInstance()) + 1; | 433 page_id = web_contents->GetMaxPageIDForSiteInstance(GetSiteInstance()) + 1; |
423 } | 434 } |
424 return page_id; | 435 return page_id; |
425 } | 436 } |
426 | 437 |
427 } // namespace content | 438 } // namespace content |
OLD | NEW |