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" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "content/browser/browser_plugin/browser_plugin_host.h" |
17 #include "content/browser/child_process_security_policy_impl.h" | 18 #include "content/browser/child_process_security_policy_impl.h" |
18 #include "content/browser/debugger/devtools_manager_impl.h" | 19 #include "content/browser/debugger/devtools_manager_impl.h" |
19 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 20 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
20 #include "content/browser/download/download_stats.h" | 21 #include "content/browser/download/download_stats.h" |
21 #include "content/browser/download/mhtml_generation_manager.h" | 22 #include "content/browser/download/mhtml_generation_manager.h" |
22 #include "content/browser/download/save_package.h" | 23 #include "content/browser/download/save_package.h" |
23 #include "content/browser/gpu/gpu_data_manager_impl.h" | 24 #include "content/browser/gpu/gpu_data_manager_impl.h" |
24 #include "content/browser/gpu/gpu_process_host.h" | 25 #include "content/browser/gpu/gpu_process_host.h" |
25 #include "content/browser/host_zoom_map_impl.h" | 26 #include "content/browser/host_zoom_map_impl.h" |
26 #include "content/browser/intents/web_intents_dispatcher_impl.h" | 27 #include "content/browser/intents/web_intents_dispatcher_impl.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // Listen for whether our opener gets destroyed. | 320 // Listen for whether our opener gets destroyed. |
320 if (opener_) { | 321 if (opener_) { |
321 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 322 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
322 content::Source<WebContents>(opener_)); | 323 content::Source<WebContents>(opener_)); |
323 } | 324 } |
324 | 325 |
325 #if defined(ENABLE_JAVA_BRIDGE) | 326 #if defined(ENABLE_JAVA_BRIDGE) |
326 java_bridge_dispatcher_host_manager_.reset( | 327 java_bridge_dispatcher_host_manager_.reset( |
327 new JavaBridgeDispatcherHostManager(this)); | 328 new JavaBridgeDispatcherHostManager(this)); |
328 #endif | 329 #endif |
| 330 |
| 331 browser_plugin_host_.reset(new content::BrowserPluginHost(this)); |
329 } | 332 } |
330 | 333 |
331 WebContentsImpl::~WebContentsImpl() { | 334 WebContentsImpl::~WebContentsImpl() { |
332 is_being_destroyed_ = true; | 335 is_being_destroyed_ = true; |
333 | 336 |
334 // Clear out any JavaScript state. | 337 // Clear out any JavaScript state. |
335 if (dialog_creator_) | 338 if (dialog_creator_) |
336 dialog_creator_->ResetJavaScriptState(this); | 339 dialog_creator_->ResetJavaScriptState(this); |
337 | 340 |
338 if (color_chooser_) | 341 if (color_chooser_) |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 } else { | 1059 } else { |
1057 GotResponseToLockMouseRequest(false); | 1060 GotResponseToLockMouseRequest(false); |
1058 } | 1061 } |
1059 } | 1062 } |
1060 | 1063 |
1061 void WebContentsImpl::LostMouseLock() { | 1064 void WebContentsImpl::LostMouseLock() { |
1062 if (delegate_) | 1065 if (delegate_) |
1063 delegate_->LostMouseLock(); | 1066 delegate_->LostMouseLock(); |
1064 } | 1067 } |
1065 | 1068 |
| 1069 void WebContentsImpl::NavigateGuestFromEmbedder( |
| 1070 content::RenderViewHost* render_view_host, |
| 1071 int container_instance_id, |
| 1072 long long frame_id, |
| 1073 const std::string& src, |
| 1074 const gfx::Size& size) { |
| 1075 browser_plugin_host()->NavigateGuestFromEmbedder(render_view_host, |
| 1076 container_instance_id, |
| 1077 frame_id, |
| 1078 src, |
| 1079 size); |
| 1080 } |
| 1081 |
1066 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { | 1082 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { |
1067 preferred_size_ = pref_size; | 1083 preferred_size_ = pref_size; |
1068 if (delegate_) | 1084 if (delegate_) |
1069 delegate_->UpdatePreferredSize(this, pref_size); | 1085 delegate_->UpdatePreferredSize(this, pref_size); |
1070 } | 1086 } |
1071 | 1087 |
1072 void WebContentsImpl::ResizeDueToAutoResize(const gfx::Size& new_size) { | 1088 void WebContentsImpl::ResizeDueToAutoResize(const gfx::Size& new_size) { |
1073 if (delegate_) | 1089 if (delegate_) |
1074 delegate_->ResizeDueToAutoResize(this, new_size); | 1090 delegate_->ResizeDueToAutoResize(this, new_size); |
1075 } | 1091 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 content::GetContentClient()->SetActiveURL(entry.GetURL()); | 1138 content::GetContentClient()->SetActiveURL(entry.GetURL()); |
1123 CHECK(0); | 1139 CHECK(0); |
1124 } | 1140 } |
1125 | 1141 |
1126 // Tell DevTools agent that it is attached prior to the navigation. | 1142 // Tell DevTools agent that it is attached prior to the navigation. |
1127 DevToolsManagerImpl::GetInstance()->OnNavigatingToPendingEntry( | 1143 DevToolsManagerImpl::GetInstance()->OnNavigatingToPendingEntry( |
1128 GetRenderViewHost(), | 1144 GetRenderViewHost(), |
1129 dest_render_view_host, | 1145 dest_render_view_host, |
1130 entry.GetURL()); | 1146 entry.GetURL()); |
1131 | 1147 |
| 1148 // Tell BrowserPluginHost about the pending cross-process navigation. |
| 1149 browser_plugin_host()->OnCrossProcessNavigation(dest_render_view_host); |
| 1150 |
1132 // Used for page load time metrics. | 1151 // Used for page load time metrics. |
1133 current_load_start_ = base::TimeTicks::Now(); | 1152 current_load_start_ = base::TimeTicks::Now(); |
1134 | 1153 |
1135 // Navigate in the desired RenderViewHost. | 1154 // Navigate in the desired RenderViewHost. |
1136 ViewMsg_Navigate_Params navigate_params; | 1155 ViewMsg_Navigate_Params navigate_params; |
1137 MakeNavigateParams(entry, controller_, delegate_, reload_type, | 1156 MakeNavigateParams(entry, controller_, delegate_, reload_type, |
1138 &navigate_params); | 1157 &navigate_params); |
1139 dest_render_view_host->Navigate(navigate_params); | 1158 dest_render_view_host->Navigate(navigate_params); |
1140 | 1159 |
1141 if (entry.GetPageID() == -1) { | 1160 if (entry.GetPageID() == -1) { |
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2706 | 2725 |
2707 // Now that the RenderView has been created, we need to tell it its size. | 2726 // Now that the RenderView has been created, we need to tell it its size. |
2708 if (rwh_view) | 2727 if (rwh_view) |
2709 rwh_view->SetSize(view_->GetContainerSize()); | 2728 rwh_view->SetSize(view_->GetContainerSize()); |
2710 | 2729 |
2711 // Make sure we use the correct starting page_id in the new RenderView. | 2730 // Make sure we use the correct starting page_id in the new RenderView. |
2712 UpdateMaxPageIDIfNecessary(render_view_host); | 2731 UpdateMaxPageIDIfNecessary(render_view_host); |
2713 int32 max_page_id = | 2732 int32 max_page_id = |
2714 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); | 2733 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); |
2715 | 2734 |
| 2735 WebContentsImpl* embedder = browser_plugin_host()->embedder(); |
| 2736 int embedder_process_id = |
| 2737 embedder ? embedder->GetRenderProcessHost()->GetID() : -1; |
2716 if (!static_cast<RenderViewHostImpl*>( | 2738 if (!static_cast<RenderViewHostImpl*>( |
2717 render_view_host)->CreateRenderView(string16(), | 2739 render_view_host)->CreateRenderView(string16(), |
2718 opener_route_id, | 2740 opener_route_id, |
2719 max_page_id, | 2741 max_page_id, |
2720 -1)) { | 2742 embedder_process_id)) { |
2721 return false; | 2743 return false; |
2722 } | 2744 } |
2723 | 2745 |
2724 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 2746 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
2725 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on | 2747 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on |
2726 // linux. See crbug.com/83941. | 2748 // linux. See crbug.com/83941. |
2727 if (rwh_view) { | 2749 if (rwh_view) { |
2728 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 2750 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) |
2729 render_widget_host->WasResized(); | 2751 render_widget_host->WasResized(); |
2730 } | 2752 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2804 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2783 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2805 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2784 // Can be NULL during tests. | 2806 // Can be NULL during tests. |
2785 if (rwh_view) | 2807 if (rwh_view) |
2786 rwh_view->SetSize(GetView()->GetContainerSize()); | 2808 rwh_view->SetSize(GetView()->GetContainerSize()); |
2787 } | 2809 } |
2788 | 2810 |
2789 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 2811 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
2790 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2812 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2791 } | 2813 } |
OLD | NEW |