Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 | 134 |
| 135 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && | 135 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && |
| 136 browser_context->DidLastSessionExitCleanly()) | 136 browser_context->DidLastSessionExitCleanly()) |
| 137 return ViewMsg_Navigate_Type::RESTORE; | 137 return ViewMsg_Navigate_Type::RESTORE; |
| 138 | 138 |
| 139 return ViewMsg_Navigate_Type::NORMAL; | 139 return ViewMsg_Navigate_Type::NORMAL; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void MakeNavigateParams(const NavigationEntry& entry, | 142 void MakeNavigateParams(const NavigationEntry& entry, |
| 143 const NavigationController& controller, | 143 const NavigationController& controller, |
| 144 TabContentsDelegate* delegate, | |
| 144 NavigationController::ReloadType reload_type, | 145 NavigationController::ReloadType reload_type, |
| 145 ViewMsg_Navigate_Params* params) { | 146 ViewMsg_Navigate_Params* params) { |
| 146 params->page_id = entry.page_id(); | 147 params->page_id = entry.page_id(); |
| 147 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | 148 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); |
| 148 params->current_history_list_offset = controller.last_committed_entry_index(); | 149 params->current_history_list_offset = controller.last_committed_entry_index(); |
| 149 params->current_history_list_length = controller.entry_count(); | 150 params->current_history_list_length = controller.entry_count(); |
| 150 params->url = entry.url(); | 151 params->url = entry.url(); |
| 151 params->referrer = entry.referrer(); | 152 params->referrer = entry.referrer(); |
| 152 params->transition = entry.transition_type(); | 153 params->transition = entry.transition_type(); |
| 153 params->state = entry.content_state(); | 154 params->state = entry.content_state(); |
| 154 params->navigation_type = | 155 params->navigation_type = |
| 155 GetNavigationType(controller.browser_context(), entry, reload_type); | 156 GetNavigationType(controller.browser_context(), entry, reload_type); |
| 156 params->request_time = base::Time::Now(); | 157 params->request_time = base::Time::Now(); |
| 158 params->extra_headers = entry.extra_headers(); | |
| 159 | |
| 160 if (delegate) | |
| 161 params->extra_headers += delegate->GetNavigationHeaders(params->url); | |
|
sky
2011/08/30 17:05:25
Is concatanating the strings going to do the right
Roger Tawa OOO till Jul 10th
2011/08/30 18:58:32
Good catch. Done.
| |
| 157 } | 162 } |
| 158 | 163 |
| 159 } // namespace | 164 } // namespace |
| 160 | 165 |
| 161 | 166 |
| 162 // TabContents ---------------------------------------------------------------- | 167 // TabContents ---------------------------------------------------------------- |
| 163 | 168 |
| 164 TabContents::TabContents(content::BrowserContext* browser_context, | 169 TabContents::TabContents(content::BrowserContext* browser_context, |
| 165 SiteInstance* site_instance, | 170 SiteInstance* site_instance, |
| 166 int routing_id, | 171 int routing_id, |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), | 585 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), |
| 581 dest_render_view_host, | 586 dest_render_view_host, |
| 582 entry.url()); | 587 entry.url()); |
| 583 } | 588 } |
| 584 | 589 |
| 585 // Used for page load time metrics. | 590 // Used for page load time metrics. |
| 586 current_load_start_ = base::TimeTicks::Now(); | 591 current_load_start_ = base::TimeTicks::Now(); |
| 587 | 592 |
| 588 // Navigate in the desired RenderViewHost. | 593 // Navigate in the desired RenderViewHost. |
| 589 ViewMsg_Navigate_Params navigate_params; | 594 ViewMsg_Navigate_Params navigate_params; |
| 590 MakeNavigateParams(entry, controller_, reload_type, &navigate_params); | 595 MakeNavigateParams(entry, controller_, delegate_, reload_type, |
| 591 if (delegate_) { | 596 &navigate_params); |
| 592 navigate_params.extra_headers = | |
| 593 delegate_->GetNavigationHeaders(navigate_params.url); | |
| 594 } | |
| 595 dest_render_view_host->Navigate(navigate_params); | 597 dest_render_view_host->Navigate(navigate_params); |
| 596 | 598 |
| 597 if (entry.page_id() == -1) { | 599 if (entry.page_id() == -1) { |
| 598 // HACK!! This code suppresses javascript: URLs from being added to | 600 // HACK!! This code suppresses javascript: URLs from being added to |
| 599 // session history, which is what we want to do for javascript: URLs that | 601 // session history, which is what we want to do for javascript: URLs that |
| 600 // do not generate content. What we really need is a message from the | 602 // do not generate content. What we really need is a message from the |
| 601 // renderer telling us that a new page was not created. The same message | 603 // renderer telling us that a new page was not created. The same message |
| 602 // could be used for mailto: URLs and the like. | 604 // could be used for mailto: URLs and the like. |
| 603 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) | 605 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) |
| 604 return false; | 606 return false; |
| (...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1983 } | 1985 } |
| 1984 | 1986 |
| 1985 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 1987 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 1986 render_manager_.SwapInRenderViewHost(rvh); | 1988 render_manager_.SwapInRenderViewHost(rvh); |
| 1987 } | 1989 } |
| 1988 | 1990 |
| 1989 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 1991 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 1990 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 1992 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 1991 rwh_view->SetSize(view()->GetContainerSize()); | 1993 rwh_view->SetSize(view()->GetContainerSize()); |
| 1992 } | 1994 } |
| OLD | NEW |