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