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 "content/browser/browser_url_handler_impl.h" | 9 #include "content/browser/browser_url_handler_impl.h" |
| 10 #include "content/browser/frame_host/cross_process_frame_connector.h" | 10 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "content/public/test/mock_render_process_host.h" | 23 #include "content/public/test/mock_render_process_host.h" |
| 24 #include "content/test/test_render_view_host.h" | 24 #include "content/test/test_render_view_host.h" |
| 25 #include "ui/base/page_transition_types.h" | 25 #include "ui/base/page_transition_types.h" |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 TestWebContents::TestWebContents(BrowserContext* browser_context) | 29 TestWebContents::TestWebContents(BrowserContext* browser_context) |
| 30 : WebContentsImpl(browser_context), | 30 : WebContentsImpl(browser_context), |
| 31 delegate_view_override_(NULL), | 31 delegate_view_override_(NULL), |
| 32 expect_set_history_offset_and_length_(false), | 32 expect_set_history_offset_and_length_(false), |
| 33 expect_set_history_offset_and_length_history_length_(0) { | 33 expect_set_history_offset_and_length_history_length_(0), |
| 34 } | 34 simulate_used_data_reduction_proxy_(false) {} |
| 35 | 35 |
| 36 TestWebContents* TestWebContents::Create(BrowserContext* browser_context, | 36 TestWebContents* TestWebContents::Create(BrowserContext* browser_context, |
| 37 SiteInstance* instance) { | 37 SiteInstance* instance) { |
| 38 TestWebContents* test_web_contents = new TestWebContents(browser_context); | 38 TestWebContents* test_web_contents = new TestWebContents(browser_context); |
| 39 test_web_contents->Init(WebContents::CreateParams(browser_context, instance)); | 39 test_web_contents->Init(WebContents::CreateParams(browser_context, instance)); |
| 40 return test_web_contents; | 40 return test_web_contents; |
| 41 } | 41 } |
| 42 | 42 |
| 43 TestWebContents::~TestWebContents() { | 43 TestWebContents::~TestWebContents() { |
| 44 EXPECT_FALSE(expect_set_history_offset_and_length_); | 44 EXPECT_FALSE(expect_set_history_offset_and_length_); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 params.should_update_history = false; | 131 params.should_update_history = false; |
| 132 params.searchable_form_url = GURL(); | 132 params.searchable_form_url = GURL(); |
| 133 params.searchable_form_encoding = std::string(); | 133 params.searchable_form_encoding = std::string(); |
| 134 params.did_create_new_entry = did_create_new_entry; | 134 params.did_create_new_entry = did_create_new_entry; |
| 135 params.security_info = std::string(); | 135 params.security_info = std::string(); |
| 136 params.gesture = NavigationGestureUser; | 136 params.gesture = NavigationGestureUser; |
| 137 params.was_within_same_page = false; | 137 params.was_within_same_page = false; |
| 138 params.is_post = false; | 138 params.is_post = false; |
| 139 params.page_state = PageState::CreateFromURL(url); | 139 params.page_state = PageState::CreateFromURL(url); |
| 140 params.contents_mime_type = std::string("text/html"); | 140 params.contents_mime_type = std::string("text/html"); |
| 141 params.used_data_reduction_proxy = simulate_used_data_reduction_proxy_; | |
|
tbansal1
2016/03/08 22:14:44
Is this really needed?
RyanSturm
2016/03/10 00:37:58
Done.
| |
| 141 | 142 |
| 142 rfh->SendNavigateWithParams(¶ms); | 143 rfh->SendNavigateWithParams(¶ms); |
| 143 } | 144 } |
| 144 | 145 |
| 145 const std::string& TestWebContents::GetSaveFrameHeaders() { | 146 const std::string& TestWebContents::GetSaveFrameHeaders() { |
| 146 return save_frame_headers_; | 147 return save_frame_headers_; |
| 147 } | 148 } |
| 148 | 149 |
| 149 bool TestWebContents::CrossProcessNavigationPending() { | 150 bool TestWebContents::CrossProcessNavigationPending() { |
| 150 if (IsBrowserSideNavigationEnabled()) { | 151 if (IsBrowserSideNavigationEnabled()) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 CHECK(!browser_side_navigation || rfh->is_loading()); | 246 CHECK(!browser_side_navigation || rfh->is_loading()); |
| 246 CHECK(!browser_side_navigation || | 247 CHECK(!browser_side_navigation || |
| 247 !rfh->frame_tree_node()->navigation_request()); | 248 !rfh->frame_tree_node()->navigation_request()); |
| 248 | 249 |
| 249 int page_id = entry->GetPageID(); | 250 int page_id = entry->GetPageID(); |
| 250 if (page_id == -1) { | 251 if (page_id == -1) { |
| 251 // It's a new navigation, assign a never-seen page id to it. | 252 // It's a new navigation, assign a never-seen page id to it. |
| 252 page_id = GetMaxPageIDForSiteInstance(rfh->GetSiteInstance()) + 1; | 253 page_id = GetMaxPageIDForSiteInstance(rfh->GetSiteInstance()) + 1; |
| 253 } | 254 } |
| 254 | 255 |
| 256 rfh->set_simulate_used_data_reduction_proxy( | |
| 257 simulate_used_data_reduction_proxy_); | |
| 255 rfh->SendNavigate(page_id, entry->GetUniqueID(), | 258 rfh->SendNavigate(page_id, entry->GetUniqueID(), |
| 256 GetController().GetPendingEntryIndex() == -1, | 259 GetController().GetPendingEntryIndex() == -1, |
| 257 entry->GetURL()); | 260 entry->GetURL()); |
| 261 rfh->set_simulate_used_data_reduction_proxy(false); | |
|
tbansal1
2016/03/08 22:14:44
Why is this set to false?
RyanSturm
2016/03/10 00:37:58
Done.
| |
| 258 // Simulate the SwapOut_ACK. This is needed when cross-site navigation | 262 // Simulate the SwapOut_ACK. This is needed when cross-site navigation |
| 259 // happens. | 263 // happens. |
| 260 if (old_rfh != rfh) | 264 if (old_rfh != rfh) |
| 261 old_rfh->OnSwappedOut(); | 265 old_rfh->OnSwappedOut(); |
| 262 } | 266 } |
| 263 | 267 |
| 264 void TestWebContents::ProceedWithCrossSiteNavigation() { | 268 void TestWebContents::ProceedWithCrossSiteNavigation() { |
| 265 if (!GetPendingMainFrame()) | 269 if (!GetPendingMainFrame()) |
| 266 return; | 270 return; |
| 267 GetMainFrame()->SendBeforeUnloadACK(true); | 271 GetMainFrame()->SendBeforeUnloadACK(true); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { | 347 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { |
| 344 } | 348 } |
| 345 | 349 |
| 346 void TestWebContents::SaveFrameWithHeaders(const GURL& url, | 350 void TestWebContents::SaveFrameWithHeaders(const GURL& url, |
| 347 const Referrer& referrer, | 351 const Referrer& referrer, |
| 348 const std::string& headers) { | 352 const std::string& headers) { |
| 349 save_frame_headers_ = headers; | 353 save_frame_headers_ = headers; |
| 350 } | 354 } |
| 351 | 355 |
| 352 } // namespace content | 356 } // namespace content |
| OLD | NEW |