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