| 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/common/frame_messages.h" | 8 #include "content/common/frame_messages.h" |
| 9 #include "content/test/test_render_view_host.h" | 9 #include "content/test/test_render_view_host.h" |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 | 51 |
| 52 void TestRenderFrameHost::SendNavigateWithTransitionAndResponseCode( | 52 void TestRenderFrameHost::SendNavigateWithTransitionAndResponseCode( |
| 53 int page_id, | 53 int page_id, |
| 54 const GURL& url, PageTransition transition, | 54 const GURL& url, PageTransition transition, |
| 55 int response_code) { | 55 int response_code) { |
| 56 // DidStartProvisionalLoad may delete the pending entry that holds |url|, | 56 // DidStartProvisionalLoad may delete the pending entry that holds |url|, |
| 57 // so we keep a copy of it to use in SendNavigateWithParameters. | 57 // so we keep a copy of it to use in SendNavigateWithParameters. |
| 58 GURL url_copy(url); | 58 GURL url_copy(url); |
| 59 OnDidStartProvisionalLoadForFrame(-1, url_copy); | 59 OnDidStartProvisionalLoadForFrame(-1, url_copy); |
| 60 SendNavigateWithParameters( | 60 SendNavigateWithParameters(page_id, url_copy, transition, url_copy, |
| 61 page_id, url_copy, transition, url_copy, response_code, 0); | 61 response_code, 0, std::vector<GURL>()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void TestRenderFrameHost::SendNavigateWithOriginalRequestURL( | 64 void TestRenderFrameHost::SendNavigateWithOriginalRequestURL( |
| 65 int page_id, | 65 int page_id, |
| 66 const GURL& url, | 66 const GURL& url, |
| 67 const GURL& original_request_url) { | 67 const GURL& original_request_url) { |
| 68 OnDidStartProvisionalLoadForFrame(-1, url); | 68 OnDidStartProvisionalLoadForFrame(-1, url); |
| 69 SendNavigateWithParameters( | 69 SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK, |
| 70 page_id, url, PAGE_TRANSITION_LINK, original_request_url, 200, 0); | 70 original_request_url, 200, 0, std::vector<GURL>()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void TestRenderFrameHost::SendNavigateWithFile( | 73 void TestRenderFrameHost::SendNavigateWithFile( |
| 74 int page_id, | 74 int page_id, |
| 75 const GURL& url, | 75 const GURL& url, |
| 76 const base::FilePath& file_path) { | 76 const base::FilePath& file_path) { |
| 77 SendNavigateWithParameters( | 77 SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK, url, 200, |
| 78 page_id, url, PAGE_TRANSITION_LINK, url, 200, &file_path); | 78 &file_path, std::vector<GURL>()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void TestRenderFrameHost::SendNavigateWithParams( | 81 void TestRenderFrameHost::SendNavigateWithParams( |
| 82 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { | 82 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { |
| 83 FrameHostMsg_DidCommitProvisionalLoad msg(1, *params); | 83 FrameHostMsg_DidCommitProvisionalLoad msg(1, *params); |
| 84 OnNavigate(msg); | 84 OnNavigate(msg); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void TestRenderFrameHost::SendNavigateWithRedirects( |
| 88 int page_id, |
| 89 const GURL& url, |
| 90 const std::vector<GURL>& redirects) { |
| 91 SendNavigateWithParameters( |
| 92 page_id, url, PAGE_TRANSITION_LINK, url, 200, 0, redirects); |
| 93 } |
| 94 |
| 87 void TestRenderFrameHost::SendNavigateWithParameters( | 95 void TestRenderFrameHost::SendNavigateWithParameters( |
| 88 int page_id, | 96 int page_id, |
| 89 const GURL& url, | 97 const GURL& url, |
| 90 PageTransition transition, | 98 PageTransition transition, |
| 91 const GURL& original_request_url, | 99 const GURL& original_request_url, |
| 92 int response_code, | 100 int response_code, |
| 93 const base::FilePath* file_path_for_history_item) { | 101 const base::FilePath* file_path_for_history_item, |
| 102 const std::vector<GURL>& redirects) { |
| 94 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 103 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 95 params.page_id = page_id; | 104 params.page_id = page_id; |
| 96 params.url = url; | 105 params.url = url; |
| 97 params.referrer = Referrer(); | 106 params.referrer = Referrer(); |
| 98 params.transition = transition; | 107 params.transition = transition; |
| 99 params.redirects = std::vector<GURL>(); | 108 params.redirects = redirects; |
| 100 params.should_update_history = true; | 109 params.should_update_history = true; |
| 101 params.searchable_form_url = GURL(); | 110 params.searchable_form_url = GURL(); |
| 102 params.searchable_form_encoding = std::string(); | 111 params.searchable_form_encoding = std::string(); |
| 103 params.security_info = std::string(); | 112 params.security_info = std::string(); |
| 104 params.gesture = NavigationGestureUser; | 113 params.gesture = NavigationGestureUser; |
| 105 params.contents_mime_type = contents_mime_type_; | 114 params.contents_mime_type = contents_mime_type_; |
| 106 params.is_post = false; | 115 params.is_post = false; |
| 107 params.was_within_same_page = false; | 116 params.was_within_same_page = false; |
| 108 params.http_status_code = response_code; | 117 params.http_status_code = response_code; |
| 109 params.socket_address.set_host("2001:db8::1"); | 118 params.socket_address.set_host("2001:db8::1"); |
| 110 params.socket_address.set_port(80); | 119 params.socket_address.set_port(80); |
| 111 params.history_list_was_cleared = simulate_history_list_was_cleared_; | 120 params.history_list_was_cleared = simulate_history_list_was_cleared_; |
| 112 params.original_request_url = original_request_url; | 121 params.original_request_url = original_request_url; |
| 113 | 122 |
| 114 params.page_state = PageState::CreateForTesting( | 123 params.page_state = PageState::CreateForTesting( |
| 115 url, | 124 url, |
| 116 false, | 125 false, |
| 117 file_path_for_history_item ? "data" : NULL, | 126 file_path_for_history_item ? "data" : NULL, |
| 118 file_path_for_history_item); | 127 file_path_for_history_item); |
| 119 | 128 |
| 120 FrameHostMsg_DidCommitProvisionalLoad msg(1, params); | 129 FrameHostMsg_DidCommitProvisionalLoad msg(1, params); |
| 121 OnNavigate(msg); | 130 OnNavigate(msg); |
| 122 } | 131 } |
| 123 | 132 |
| 124 } // namespace content | 133 } // namespace content |
| OLD | NEW |