| 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" |
| 11 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
| 12 #include "content/browser/renderer_host/test_render_view_host.h" | 12 #include "content/browser/renderer_host/test_render_view_host.h" |
| 13 #include "content/browser/site_instance.h" | 13 #include "content/browser/site_instance_impl.h" |
| 14 #include "content/browser/tab_contents/navigation_entry_impl.h" | 14 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 15 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
| 16 #include "content/public/common/page_transition_types.h" | 16 #include "content/public/common/page_transition_types.h" |
| 17 #include "webkit/glue/webkit_glue.h" | 17 #include "webkit/glue/webkit_glue.h" |
| 18 #include "webkit/forms/password_form.h" | 18 #include "webkit/forms/password_form.h" |
| 19 | 19 |
| 20 using content::NavigationEntry; | 20 using content::NavigationEntry; |
| 21 using content::SiteInstance; |
| 21 using content::WebContents; | 22 using content::WebContents; |
| 22 | 23 |
| 23 TestTabContents::TestTabContents(content::BrowserContext* browser_context, | 24 TestTabContents::TestTabContents(content::BrowserContext* browser_context, |
| 24 SiteInstance* instance) | 25 SiteInstance* instance) |
| 25 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), | 26 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), |
| 26 transition_cross_site(false), | 27 transition_cross_site(false), |
| 27 delegate_view_override_(NULL), | 28 delegate_view_override_(NULL), |
| 28 expect_set_history_length_and_prune_(false), | 29 expect_set_history_length_and_prune_(false), |
| 29 expect_set_history_length_and_prune_site_instance_(NULL), | 30 expect_set_history_length_and_prune_site_instance_(NULL), |
| 30 expect_set_history_length_and_prune_history_length_(0), | 31 expect_set_history_length_and_prune_history_length_(0), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 bool TestTabContents::CreateRenderViewForRenderManager( | 80 bool TestTabContents::CreateRenderViewForRenderManager( |
| 80 RenderViewHost* render_view_host) { | 81 RenderViewHost* render_view_host) { |
| 81 // This will go to a TestRenderViewHost. | 82 // This will go to a TestRenderViewHost. |
| 82 render_view_host->CreateRenderView(string16(), -1); | 83 render_view_host->CreateRenderView(string16(), -1); |
| 83 return true; | 84 return true; |
| 84 } | 85 } |
| 85 | 86 |
| 86 WebContents* TestTabContents::Clone() { | 87 WebContents* TestTabContents::Clone() { |
| 87 TabContents* tc = new TestTabContents( | 88 TabContents* tc = new TestTabContents( |
| 88 GetBrowserContext(), | 89 GetBrowserContext(), |
| 89 SiteInstance::CreateSiteInstance(GetBrowserContext())); | 90 SiteInstance::Create(GetBrowserContext())); |
| 90 tc->GetControllerImpl().CopyStateFrom(controller_); | 91 tc->GetControllerImpl().CopyStateFrom(controller_); |
| 91 return tc; | 92 return tc; |
| 92 } | 93 } |
| 93 | 94 |
| 94 void TestTabContents::NavigateAndCommit(const GURL& url) { | 95 void TestTabContents::NavigateAndCommit(const GURL& url) { |
| 95 GetController().LoadURL( | 96 GetController().LoadURL( |
| 96 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 97 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
| 97 GURL loaded_url(url); | 98 GURL loaded_url(url); |
| 98 bool reverse_on_redirect = false; | 99 bool reverse_on_redirect = false; |
| 99 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 100 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 if (delegate_view_override_) | 142 if (delegate_view_override_) |
| 142 return delegate_view_override_; | 143 return delegate_view_override_; |
| 143 return TabContents::GetViewDelegate(); | 144 return TabContents::GetViewDelegate(); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void TestTabContents::ExpectSetHistoryLengthAndPrune( | 147 void TestTabContents::ExpectSetHistoryLengthAndPrune( |
| 147 const SiteInstance* site_instance, | 148 const SiteInstance* site_instance, |
| 148 int history_length, | 149 int history_length, |
| 149 int32 min_page_id) { | 150 int32 min_page_id) { |
| 150 expect_set_history_length_and_prune_ = true; | 151 expect_set_history_length_and_prune_ = true; |
| 151 expect_set_history_length_and_prune_site_instance_ = site_instance; | 152 expect_set_history_length_and_prune_site_instance_ = |
| 153 static_cast<const SiteInstanceImpl*>(site_instance); |
| 152 expect_set_history_length_and_prune_history_length_ = history_length; | 154 expect_set_history_length_and_prune_history_length_ = history_length; |
| 153 expect_set_history_length_and_prune_min_page_id_ = min_page_id; | 155 expect_set_history_length_and_prune_min_page_id_ = min_page_id; |
| 154 } | 156 } |
| 155 | 157 |
| 156 void TestTabContents::SetHistoryLengthAndPrune( | 158 void TestTabContents::SetHistoryLengthAndPrune( |
| 157 const SiteInstance* site_instance, int history_length, int32 min_page_id) { | 159 const SiteInstance* site_instance, int history_length, |
| 160 int32 min_page_id) { |
| 158 EXPECT_TRUE(expect_set_history_length_and_prune_); | 161 EXPECT_TRUE(expect_set_history_length_and_prune_); |
| 159 expect_set_history_length_and_prune_ = false; | 162 expect_set_history_length_and_prune_ = false; |
| 160 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); | 163 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); |
| 161 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, | 164 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, |
| 162 history_length); | 165 history_length); |
| 163 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); | 166 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); |
| 164 } | 167 } |
| OLD | NEW |