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/sys_info.h" | 15 #include "base/sys_info.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| 19 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
18 #include "content/browser/browser_plugin/old/old_browser_plugin_host.h" | 20 #include "content/browser/browser_plugin/old/old_browser_plugin_host.h" |
19 #include "content/browser/child_process_security_policy_impl.h" | 21 #include "content/browser/child_process_security_policy_impl.h" |
20 #include "content/browser/debugger/devtools_manager_impl.h" | 22 #include "content/browser/debugger/devtools_manager_impl.h" |
21 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 23 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
22 #include "content/browser/download/download_stats.h" | 24 #include "content/browser/download/download_stats.h" |
23 #include "content/browser/download/mhtml_generation_manager.h" | 25 #include "content/browser/download/mhtml_generation_manager.h" |
24 #include "content/browser/download/save_package.h" | 26 #include "content/browser/download/save_package.h" |
25 #include "content/browser/gpu/gpu_data_manager_impl.h" | 27 #include "content/browser/gpu/gpu_data_manager_impl.h" |
26 #include "content/browser/gpu/gpu_process_host.h" | 28 #include "content/browser/gpu/gpu_process_host.h" |
27 #include "content/browser/host_zoom_map_impl.h" | 29 #include "content/browser/host_zoom_map_impl.h" |
28 #include "content/browser/intents/web_intents_dispatcher_impl.h" | 30 #include "content/browser/intents/web_intents_dispatcher_impl.h" |
29 #include "content/browser/renderer_host/render_process_host_impl.h" | 31 #include "content/browser/renderer_host/render_process_host_impl.h" |
30 #include "content/browser/renderer_host/render_view_host_impl.h" | 32 #include "content/browser/renderer_host/render_view_host_impl.h" |
31 #include "content/browser/renderer_host/render_widget_host_impl.h" | 33 #include "content/browser/renderer_host/render_widget_host_impl.h" |
32 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 34 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
33 #include "content/browser/site_instance_impl.h" | 35 #include "content/browser/site_instance_impl.h" |
34 #include "content/browser/web_contents/interstitial_page_impl.h" | 36 #include "content/browser/web_contents/interstitial_page_impl.h" |
35 #include "content/browser/web_contents/navigation_entry_impl.h" | 37 #include "content/browser/web_contents/navigation_entry_impl.h" |
36 #include "content/browser/webui/web_ui_impl.h" | 38 #include "content/browser/webui/web_ui_impl.h" |
| 39 #include "content/common/browser_plugin_messages.h" |
37 #include "content/common/intents_messages.h" | 40 #include "content/common/intents_messages.h" |
38 #include "content/common/ssl_status_serialization.h" | 41 #include "content/common/ssl_status_serialization.h" |
39 #include "content/common/view_messages.h" | 42 #include "content/common/view_messages.h" |
40 #include "content/port/browser/render_view_host_delegate_view.h" | 43 #include "content/port/browser/render_view_host_delegate_view.h" |
41 #include "content/port/browser/render_widget_host_view_port.h" | 44 #include "content/port/browser/render_widget_host_view_port.h" |
42 #include "content/public/browser/browser_context.h" | 45 #include "content/public/browser/browser_context.h" |
43 #include "content/public/browser/color_chooser.h" | 46 #include "content/public/browser/color_chooser.h" |
44 #include "content/public/browser/content_browser_client.h" | 47 #include "content/public/browser/content_browser_client.h" |
45 #include "content/public/browser/devtools_agent_host_registry.h" | 48 #include "content/public/browser/devtools_agent_host_registry.h" |
46 #include "content/public/browser/download_manager.h" | 49 #include "content/public/browser/download_manager.h" |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 OnRegisterProtocolHandler) | 682 OnRegisterProtocolHandler) |
680 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) | 683 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) |
681 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | 684 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) |
682 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 685 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
683 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) | 686 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) |
684 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) | 687 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) |
685 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, | 688 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, |
686 OnSetSelectedColorInColorChooser) | 689 OnSetSelectedColorInColorChooser) |
687 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) | 690 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) |
688 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 691 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
| 692 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, |
| 693 OnBrowserPluginNavigateGuest) |
689 IPC_MESSAGE_UNHANDLED(handled = false) | 694 IPC_MESSAGE_UNHANDLED(handled = false) |
690 IPC_END_MESSAGE_MAP_EX() | 695 IPC_END_MESSAGE_MAP_EX() |
691 message_source_ = NULL; | 696 message_source_ = NULL; |
692 | 697 |
693 if (!message_is_ok) { | 698 if (!message_is_ok) { |
694 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 699 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
695 GetRenderProcessHost()->ReceivedBadMessage(); | 700 GetRenderProcessHost()->ReceivedBadMessage(); |
696 } | 701 } |
697 | 702 |
698 return handled; | 703 return handled; |
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 | 2176 |
2172 // This exists for render views that don't have a WebUI, but do have WebUI | 2177 // This exists for render views that don't have a WebUI, but do have WebUI |
2173 // bindings enabled. | 2178 // bindings enabled. |
2174 void WebContentsImpl::OnWebUISend(const GURL& source_url, | 2179 void WebContentsImpl::OnWebUISend(const GURL& source_url, |
2175 const std::string& name, | 2180 const std::string& name, |
2176 const base::ListValue& args) { | 2181 const base::ListValue& args) { |
2177 if (delegate_) | 2182 if (delegate_) |
2178 delegate_->WebUISend(this, source_url, name, args); | 2183 delegate_->WebUISend(this, source_url, name, args); |
2179 } | 2184 } |
2180 | 2185 |
| 2186 void WebContentsImpl::OnBrowserPluginNavigateGuest(int instance_id, |
| 2187 int64 frame_id, |
| 2188 std::string src, |
| 2189 gfx::Size size) { |
| 2190 // This is the first 'navigate' to a browser plugin, before WebContents has/is |
| 2191 // an 'Embedder'; subsequent navigate messages for this WebContents will |
| 2192 // be handled by the BrowserPluginEmbedderHelper of the embedder itself (this |
| 2193 // also means any message from browser plugin renderer prior to NavigateGuest |
| 2194 // which is not NavigateGuest will be ignored). Therefore |
| 2195 // browser_plugin_embedder_ should not be set. |
| 2196 DCHECK(!browser_plugin_embedder_.get()); |
| 2197 |
| 2198 browser_plugin_embedder_.reset( |
| 2199 content::BrowserPluginEmbedder::Create(this, GetRenderViewHost())); |
| 2200 browser_plugin_embedder_->NavigateGuest(GetRenderViewHost(), |
| 2201 instance_id, |
| 2202 frame_id, |
| 2203 src, |
| 2204 size); |
| 2205 } |
| 2206 |
2181 // Notifies the RenderWidgetHost instance about the fact that the page is | 2207 // Notifies the RenderWidgetHost instance about the fact that the page is |
2182 // loading, or done loading and calls the base implementation. | 2208 // loading, or done loading and calls the base implementation. |
2183 void WebContentsImpl::SetIsLoading(bool is_loading, | 2209 void WebContentsImpl::SetIsLoading(bool is_loading, |
2184 LoadNotificationDetails* details) { | 2210 LoadNotificationDetails* details) { |
2185 if (is_loading == is_loading_) | 2211 if (is_loading == is_loading_) |
2186 return; | 2212 return; |
2187 | 2213 |
2188 if (!is_loading) { | 2214 if (!is_loading) { |
2189 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 2215 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
2190 load_state_host_.clear(); | 2216 load_state_host_.clear(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 | 2353 |
2328 void WebContentsImpl::NotifySwapped() { | 2354 void WebContentsImpl::NotifySwapped() { |
2329 // After sending out a swap notification, we need to send a disconnect | 2355 // After sending out a swap notification, we need to send a disconnect |
2330 // notification so that clients that pick up a pointer to |this| can NULL the | 2356 // notification so that clients that pick up a pointer to |this| can NULL the |
2331 // pointer. See Bug 1230284. | 2357 // pointer. See Bug 1230284. |
2332 notify_disconnection_ = true; | 2358 notify_disconnection_ = true; |
2333 content::NotificationService::current()->Notify( | 2359 content::NotificationService::current()->Notify( |
2334 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 2360 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, |
2335 content::Source<WebContents>(this), | 2361 content::Source<WebContents>(this), |
2336 content::NotificationService::NoDetails()); | 2362 content::NotificationService::NoDetails()); |
| 2363 |
| 2364 // Once we swap RenderViewHosts, we remove browser plugin embedder if its |
| 2365 // associated RenderViewHost has been swapped out. |
| 2366 RemoveSwappedOutBrowserPluginEmbedder(); |
2337 } | 2367 } |
2338 | 2368 |
2339 void WebContentsImpl::NotifyConnected() { | 2369 void WebContentsImpl::NotifyConnected() { |
2340 notify_disconnection_ = true; | 2370 notify_disconnection_ = true; |
2341 content::NotificationService::current()->Notify( | 2371 content::NotificationService::current()->Notify( |
2342 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 2372 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
2343 content::Source<WebContents>(this), | 2373 content::Source<WebContents>(this), |
2344 content::NotificationService::NoDetails()); | 2374 content::NotificationService::NoDetails()); |
2345 } | 2375 } |
2346 | 2376 |
(...skipping 25 matching lines...) Expand all Loading... |
2372 WebContents* WebContentsImpl::GetAsWebContents() { | 2402 WebContents* WebContentsImpl::GetAsWebContents() { |
2373 return this; | 2403 return this; |
2374 } | 2404 } |
2375 | 2405 |
2376 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { | 2406 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { |
2377 if (delegate_) | 2407 if (delegate_) |
2378 return delegate_->GetRootWindowResizerRect(); | 2408 return delegate_->GetRootWindowResizerRect(); |
2379 return gfx::Rect(); | 2409 return gfx::Rect(); |
2380 } | 2410 } |
2381 | 2411 |
| 2412 void WebContentsImpl::RemoveSwappedOutBrowserPluginEmbedder() { |
| 2413 if (browser_plugin_embedder_.get() && |
| 2414 !browser_plugin_embedder_->IsForRenderViewHost(GetRenderViewHost())) { |
| 2415 browser_plugin_embedder_.reset(); |
| 2416 } |
| 2417 } |
| 2418 |
2382 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 2419 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
2383 // Don't send notifications if we are just creating a swapped-out RVH for | 2420 // Don't send notifications if we are just creating a swapped-out RVH for |
2384 // the opener chain. These won't be used for view-source or WebUI, so it's | 2421 // the opener chain. These won't be used for view-source or WebUI, so it's |
2385 // ok to return early. | 2422 // ok to return early. |
2386 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) | 2423 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) |
2387 return; | 2424 return; |
2388 | 2425 |
2389 content::NotificationService::current()->Notify( | 2426 content::NotificationService::current()->Notify( |
2390 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2427 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
2391 content::Source<WebContents>(this), | 2428 content::Source<WebContents>(this), |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3141 old_browser_plugin_host()->embedder_render_process_host(); | 3178 old_browser_plugin_host()->embedder_render_process_host(); |
3142 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3179 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
3143 int embedder_process_id = | 3180 int embedder_process_id = |
3144 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3181 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3145 if (embedder_process_id != -1) { | 3182 if (embedder_process_id != -1) { |
3146 *embedder_channel_name = | 3183 *embedder_channel_name = |
3147 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3184 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3148 embedder_process_id); | 3185 embedder_process_id); |
3149 } | 3186 } |
3150 } | 3187 } |
| 3188 |
| 3189 content::BrowserPluginGuest* WebContentsImpl::SetBrowserPluginGuest( |
| 3190 int instance_id) { |
| 3191 browser_plugin_guest_.reset(content::BrowserPluginGuest::Create( |
| 3192 instance_id, this, GetRenderViewHost())); |
| 3193 return browser_plugin_guest_.get(); |
| 3194 } |
| 3195 |
| 3196 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3197 return browser_plugin_guest_.get(); |
| 3198 } |
| 3199 |
| 3200 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3201 return browser_plugin_embedder_.get(); |
| 3202 } |
OLD | NEW |