| 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/browser/tab_contents/test_tab_contents.h" | 5 #include "content/browser/tab_contents/test_tab_contents.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/browser/browser_url_handler.h" | 9 #include "content/browser/browser_url_handler.h" |
| 10 #include "content/browser/renderer_host/mock_render_process_host.h" | 10 #include "content/browser/renderer_host/mock_render_process_host.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 params.was_within_same_page = false; | 73 params.was_within_same_page = false; |
| 74 params.is_post = false; | 74 params.is_post = false; |
| 75 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); | 75 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); |
| 76 | 76 |
| 77 DidNavigate(render_view_host, params); | 77 DidNavigate(render_view_host, params); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool TestTabContents::CreateRenderViewForRenderManager( | 80 bool TestTabContents::CreateRenderViewForRenderManager( |
| 81 RenderViewHost* render_view_host) { | 81 RenderViewHost* render_view_host) { |
| 82 // This will go to a TestRenderViewHost. | 82 // This will go to a TestRenderViewHost. |
| 83 render_view_host->CreateRenderView(string16(), -1); | 83 static_cast<RenderViewHostImpl*>( |
| 84 render_view_host)->CreateRenderView(string16(), -1); |
| 84 return true; | 85 return true; |
| 85 } | 86 } |
| 86 | 87 |
| 87 WebContents* TestTabContents::Clone() { | 88 WebContents* TestTabContents::Clone() { |
| 88 TabContents* tc = new TestTabContents( | 89 TabContents* tc = new TestTabContents( |
| 89 GetBrowserContext(), | 90 GetBrowserContext(), |
| 90 SiteInstance::Create(GetBrowserContext())); | 91 SiteInstance::Create(GetBrowserContext())); |
| 91 tc->GetControllerImpl().CopyStateFrom(controller_); | 92 tc->GetControllerImpl().CopyStateFrom(controller_); |
| 92 return tc; | 93 return tc; |
| 93 } | 94 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 113 RenderViewHost* old_rvh = render_manager_.current_host(); | 114 RenderViewHost* old_rvh = render_manager_.current_host(); |
| 114 TestRenderViewHost* rvh = pending_rvh(); | 115 TestRenderViewHost* rvh = pending_rvh(); |
| 115 if (!rvh) | 116 if (!rvh) |
| 116 rvh = static_cast<TestRenderViewHost*>(old_rvh); | 117 rvh = static_cast<TestRenderViewHost*>(old_rvh); |
| 117 | 118 |
| 118 const NavigationEntry* entry = GetController().GetPendingEntry(); | 119 const NavigationEntry* entry = GetController().GetPendingEntry(); |
| 119 DCHECK(entry); | 120 DCHECK(entry); |
| 120 int page_id = entry->GetPageID(); | 121 int page_id = entry->GetPageID(); |
| 121 if (page_id == -1) { | 122 if (page_id == -1) { |
| 122 // It's a new navigation, assign a never-seen page id to it. | 123 // It's a new navigation, assign a never-seen page id to it. |
| 123 page_id = GetMaxPageIDForSiteInstance(rvh->site_instance()) + 1; | 124 page_id = GetMaxPageIDForSiteInstance(rvh->GetSiteInstance()) + 1; |
| 124 } | 125 } |
| 125 rvh->SendNavigate(page_id, entry->GetURL()); | 126 rvh->SendNavigate(page_id, entry->GetURL()); |
| 126 | 127 |
| 127 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation | 128 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation |
| 128 // without making any network requests. | 129 // without making any network requests. |
| 129 if (old_rvh != rvh) | 130 if (old_rvh != rvh) |
| 130 old_rvh->OnSwapOutACK(); | 131 static_cast<RenderViewHostImpl*>(old_rvh)->OnSwapOutACK(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void TestTabContents::ProceedWithCrossSiteNavigation() { | 134 void TestTabContents::ProceedWithCrossSiteNavigation() { |
| 134 if (!pending_rvh()) | 135 if (!pending_rvh()) |
| 135 return; | 136 return; |
| 136 TestRenderViewHost* rvh = static_cast<TestRenderViewHost*>( | 137 TestRenderViewHost* rvh = static_cast<TestRenderViewHost*>( |
| 137 render_manager_.current_host()); | 138 render_manager_.current_host()); |
| 138 rvh->SendShouldCloseACK(true); | 139 rvh->SendShouldCloseACK(true); |
| 139 } | 140 } |
| 140 | 141 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 158 void TestTabContents::SetHistoryLengthAndPrune( | 159 void TestTabContents::SetHistoryLengthAndPrune( |
| 159 const SiteInstance* site_instance, int history_length, | 160 const SiteInstance* site_instance, int history_length, |
| 160 int32 min_page_id) { | 161 int32 min_page_id) { |
| 161 EXPECT_TRUE(expect_set_history_length_and_prune_); | 162 EXPECT_TRUE(expect_set_history_length_and_prune_); |
| 162 expect_set_history_length_and_prune_ = false; | 163 expect_set_history_length_and_prune_ = false; |
| 163 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); | 164 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); |
| 164 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, | 165 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, |
| 165 history_length); | 166 history_length); |
| 166 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); | 167 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); |
| 167 } | 168 } |
| OLD | NEW |