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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return ViewMsg_Navigate_Type::RESTORE; | 191 return ViewMsg_Navigate_Type::RESTORE; |
192 } | 192 } |
193 | 193 |
194 return ViewMsg_Navigate_Type::NORMAL; | 194 return ViewMsg_Navigate_Type::NORMAL; |
195 } | 195 } |
196 | 196 |
197 void MakeNavigateParams(const NavigationEntryImpl& entry, | 197 void MakeNavigateParams(const NavigationEntryImpl& entry, |
198 const NavigationControllerImpl& controller, | 198 const NavigationControllerImpl& controller, |
199 content::WebContentsDelegate* delegate, | 199 content::WebContentsDelegate* delegate, |
200 NavigationController::ReloadType reload_type, | 200 NavigationController::ReloadType reload_type, |
| 201 const std::string& embedder_channel_name, |
| 202 int embedder_container_id, |
201 ViewMsg_Navigate_Params* params) { | 203 ViewMsg_Navigate_Params* params) { |
202 params->page_id = entry.GetPageID(); | 204 params->page_id = entry.GetPageID(); |
203 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | 205 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); |
204 params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); | 206 params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); |
205 params->current_history_list_length = controller.GetEntryCount(); | 207 params->current_history_list_length = controller.GetEntryCount(); |
206 params->url = entry.GetURL(); | 208 params->url = entry.GetURL(); |
207 params->referrer = entry.GetReferrer(); | 209 params->referrer = entry.GetReferrer(); |
208 params->transition = entry.GetTransitionType(); | 210 params->transition = entry.GetTransitionType(); |
209 params->state = entry.GetContentState(); | 211 params->state = entry.GetContentState(); |
210 params->navigation_type = | 212 params->navigation_type = |
211 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); | 213 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); |
212 params->request_time = base::Time::Now(); | 214 params->request_time = base::Time::Now(); |
213 params->extra_headers = entry.extra_headers(); | 215 params->extra_headers = entry.extra_headers(); |
214 params->transferred_request_child_id = | 216 params->transferred_request_child_id = |
215 entry.transferred_global_request_id().child_id; | 217 entry.transferred_global_request_id().child_id; |
216 params->transferred_request_request_id = | 218 params->transferred_request_request_id = |
217 entry.transferred_global_request_id().request_id; | 219 entry.transferred_global_request_id().request_id; |
218 // Avoid downloading when in view-source mode. | 220 // Avoid downloading when in view-source mode. |
219 params->allow_download = !entry.IsViewSourceMode(); | 221 params->allow_download = !entry.IsViewSourceMode(); |
| 222 params->embedder_channel_name = embedder_channel_name; |
| 223 params->embedder_container_id = embedder_container_id; |
220 | 224 |
221 if (delegate) | 225 if (delegate) |
222 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); | 226 delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); |
223 } | 227 } |
224 | 228 |
225 int GetSwitchValueAsInt( | 229 int GetSwitchValueAsInt( |
226 const CommandLine& command_line, | 230 const CommandLine& command_line, |
227 const std::string& switch_string, | 231 const std::string& switch_string, |
228 int min_value) { | 232 int min_value) { |
229 std::string string_value = command_line.GetSwitchValueASCII(switch_string); | 233 std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 content::GetContentClient()->SetActiveURL(entry.GetURL()); | 1148 content::GetContentClient()->SetActiveURL(entry.GetURL()); |
1145 CHECK(0); | 1149 CHECK(0); |
1146 } | 1150 } |
1147 | 1151 |
1148 // Tell DevTools agent that it is attached prior to the navigation. | 1152 // Tell DevTools agent that it is attached prior to the navigation. |
1149 DevToolsManagerImpl::GetInstance()->OnNavigatingToPendingEntry( | 1153 DevToolsManagerImpl::GetInstance()->OnNavigatingToPendingEntry( |
1150 GetRenderViewHost(), | 1154 GetRenderViewHost(), |
1151 dest_render_view_host, | 1155 dest_render_view_host, |
1152 entry.GetURL()); | 1156 entry.GetURL()); |
1153 | 1157 |
1154 // Tell BrowserPluginHost about the pending cross-process navigation. | |
1155 // TODO(fsamuel): Remove this once this issue is addressed: | |
1156 // https://code.google.com/p/chromium/issues/detail?id=128976 | |
1157 browser_plugin_host()->OnPendingNavigation(dest_render_view_host); | |
1158 | |
1159 // Used for page load time metrics. | 1158 // Used for page load time metrics. |
1160 current_load_start_ = base::TimeTicks::Now(); | 1159 current_load_start_ = base::TimeTicks::Now(); |
1161 | 1160 |
1162 // Navigate in the desired RenderViewHost. | 1161 // Navigate in the desired RenderViewHost. |
| 1162 std::string embedder_channel_name; |
| 1163 int embedder_container_id; |
| 1164 GetBrowserPluginEmbedderInfo(dest_render_view_host, |
| 1165 &embedder_channel_name, |
| 1166 &embedder_container_id); |
1163 ViewMsg_Navigate_Params navigate_params; | 1167 ViewMsg_Navigate_Params navigate_params; |
1164 MakeNavigateParams(entry, controller_, delegate_, reload_type, | 1168 MakeNavigateParams(entry, controller_, delegate_, reload_type, |
| 1169 embedder_channel_name, |
| 1170 embedder_container_id, |
1165 &navigate_params); | 1171 &navigate_params); |
1166 dest_render_view_host->Navigate(navigate_params); | 1172 dest_render_view_host->Navigate(navigate_params); |
1167 | 1173 |
1168 if (entry.GetPageID() == -1) { | 1174 if (entry.GetPageID() == -1) { |
1169 // HACK!! This code suppresses javascript: URLs from being added to | 1175 // HACK!! This code suppresses javascript: URLs from being added to |
1170 // session history, which is what we want to do for javascript: URLs that | 1176 // session history, which is what we want to do for javascript: URLs that |
1171 // do not generate content. What we really need is a message from the | 1177 // do not generate content. What we really need is a message from the |
1172 // renderer telling us that a new page was not created. The same message | 1178 // renderer telling us that a new page was not created. The same message |
1173 // could be used for mailto: URLs and the like. | 1179 // could be used for mailto: URLs and the like. |
1174 if (entry.GetURL().SchemeIs(chrome::kJavaScriptScheme)) | 1180 if (entry.GetURL().SchemeIs(chrome::kJavaScriptScheme)) |
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2729 | 2735 |
2730 // Now that the RenderView has been created, we need to tell it its size. | 2736 // Now that the RenderView has been created, we need to tell it its size. |
2731 if (rwh_view) | 2737 if (rwh_view) |
2732 rwh_view->SetSize(view_->GetContainerSize()); | 2738 rwh_view->SetSize(view_->GetContainerSize()); |
2733 | 2739 |
2734 // Make sure we use the correct starting page_id in the new RenderView. | 2740 // Make sure we use the correct starting page_id in the new RenderView. |
2735 UpdateMaxPageIDIfNecessary(render_view_host); | 2741 UpdateMaxPageIDIfNecessary(render_view_host); |
2736 int32 max_page_id = | 2742 int32 max_page_id = |
2737 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); | 2743 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); |
2738 | 2744 |
2739 content::RenderProcessHost* embedder_render_process_host = | 2745 std::string embedder_channel_name; |
2740 browser_plugin_host()->embedder_render_process_host(); | 2746 int embedder_container_id; |
2741 int embedder_process_id = | 2747 GetBrowserPluginEmbedderInfo(render_view_host, |
2742 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 2748 &embedder_channel_name, |
| 2749 &embedder_container_id); |
2743 if (!static_cast<RenderViewHostImpl*>( | 2750 if (!static_cast<RenderViewHostImpl*>( |
2744 render_view_host)->CreateRenderView(string16(), | 2751 render_view_host)->CreateRenderView(string16(), |
2745 opener_route_id, | 2752 opener_route_id, |
2746 max_page_id, | 2753 max_page_id, |
2747 embedder_process_id)) { | 2754 embedder_channel_name, |
| 2755 embedder_container_id)) { |
2748 return false; | 2756 return false; |
2749 } | 2757 } |
2750 | 2758 |
2751 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 2759 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
2752 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on | 2760 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on |
2753 // linux. See crbug.com/83941. | 2761 // linux. See crbug.com/83941. |
2754 if (rwh_view) { | 2762 if (rwh_view) { |
2755 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 2763 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) |
2756 render_widget_host->WasResized(); | 2764 render_widget_host->WasResized(); |
2757 } | 2765 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2809 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2817 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2810 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2818 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2811 // Can be NULL during tests. | 2819 // Can be NULL during tests. |
2812 if (rwh_view) | 2820 if (rwh_view) |
2813 rwh_view->SetSize(GetView()->GetContainerSize()); | 2821 rwh_view->SetSize(GetView()->GetContainerSize()); |
2814 } | 2822 } |
2815 | 2823 |
2816 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 2824 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
2817 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2825 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2818 } | 2826 } |
| 2827 |
| 2828 void WebContentsImpl::GetBrowserPluginEmbedderInfo( |
| 2829 content::RenderViewHost* render_view_host, |
| 2830 std::string* embedder_channel_name, |
| 2831 int* embedder_container_id) { |
| 2832 content::RenderProcessHost* embedder_render_process_host = |
| 2833 browser_plugin_host()->embedder_render_process_host(); |
| 2834 *embedder_container_id = browser_plugin_host()->instance_id(); |
| 2835 int embedder_process_id = |
| 2836 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
| 2837 if (embedder_process_id != -1) { |
| 2838 *embedder_channel_name = |
| 2839 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
| 2840 embedder_process_id); |
| 2841 } |
| 2842 } |
OLD | NEW |