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/dom_storage_context_impl.h" | 23 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
22 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 24 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
23 #include "content/browser/download/download_stats.h" | 25 #include "content/browser/download/download_stats.h" |
24 #include "content/browser/download/mhtml_generation_manager.h" | 26 #include "content/browser/download/mhtml_generation_manager.h" |
25 #include "content/browser/download/save_package.h" | 27 #include "content/browser/download/save_package.h" |
26 #include "content/browser/gpu/gpu_data_manager_impl.h" | 28 #include "content/browser/gpu/gpu_data_manager_impl.h" |
27 #include "content/browser/gpu/gpu_process_host.h" | 29 #include "content/browser/gpu/gpu_process_host.h" |
28 #include "content/browser/host_zoom_map_impl.h" | 30 #include "content/browser/host_zoom_map_impl.h" |
29 #include "content/browser/intents/web_intents_dispatcher_impl.h" | 31 #include "content/browser/intents/web_intents_dispatcher_impl.h" |
30 #include "content/browser/renderer_host/render_process_host_impl.h" | 32 #include "content/browser/renderer_host/render_process_host_impl.h" |
31 #include "content/browser/renderer_host/render_view_host_impl.h" | 33 #include "content/browser/renderer_host/render_view_host_impl.h" |
32 #include "content/browser/renderer_host/render_widget_host_impl.h" | 34 #include "content/browser/renderer_host/render_widget_host_impl.h" |
33 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 35 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
34 #include "content/browser/site_instance_impl.h" | 36 #include "content/browser/site_instance_impl.h" |
35 #include "content/browser/web_contents/interstitial_page_impl.h" | 37 #include "content/browser/web_contents/interstitial_page_impl.h" |
36 #include "content/browser/web_contents/navigation_entry_impl.h" | 38 #include "content/browser/web_contents/navigation_entry_impl.h" |
37 #include "content/browser/webui/web_ui_impl.h" | 39 #include "content/browser/webui/web_ui_impl.h" |
40 #include "content/common/browser_plugin_messages.h" | |
38 #include "content/common/intents_messages.h" | 41 #include "content/common/intents_messages.h" |
39 #include "content/common/ssl_status_serialization.h" | 42 #include "content/common/ssl_status_serialization.h" |
40 #include "content/common/view_messages.h" | 43 #include "content/common/view_messages.h" |
41 #include "content/port/browser/render_view_host_delegate_view.h" | 44 #include "content/port/browser/render_view_host_delegate_view.h" |
42 #include "content/port/browser/render_widget_host_view_port.h" | 45 #include "content/port/browser/render_widget_host_view_port.h" |
43 #include "content/public/browser/browser_context.h" | 46 #include "content/public/browser/browser_context.h" |
44 #include "content/public/browser/color_chooser.h" | 47 #include "content/public/browser/color_chooser.h" |
45 #include "content/public/browser/content_browser_client.h" | 48 #include "content/public/browser/content_browser_client.h" |
46 #include "content/public/browser/devtools_agent_host_registry.h" | 49 #include "content/public/browser/devtools_agent_host_registry.h" |
47 #include "content/public/browser/download_manager.h" | 50 #include "content/public/browser/download_manager.h" |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | 680 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) |
678 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 681 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
679 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) | 682 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) |
680 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) | 683 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) |
681 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, | 684 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, |
682 OnSetSelectedColorInColorChooser) | 685 OnSetSelectedColorInColorChooser) |
683 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) | 686 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) |
684 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 687 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
685 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 688 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
686 OnRequestPpapiBrokerPermission) | 689 OnRequestPpapiBrokerPermission) |
690 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, | |
691 OnBrowserPluginNavigateGuest) | |
687 IPC_MESSAGE_UNHANDLED(handled = false) | 692 IPC_MESSAGE_UNHANDLED(handled = false) |
688 IPC_END_MESSAGE_MAP_EX() | 693 IPC_END_MESSAGE_MAP_EX() |
689 message_source_ = NULL; | 694 message_source_ = NULL; |
690 | 695 |
691 if (!message_is_ok) { | 696 if (!message_is_ok) { |
692 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 697 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
693 GetRenderProcessHost()->ReceivedBadMessage(); | 698 GetRenderProcessHost()->ReceivedBadMessage(); |
694 } | 699 } |
695 | 700 |
696 return handled; | 701 return handled; |
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2264 } | 2269 } |
2265 | 2270 |
2266 void WebContentsImpl::OnPpapiBrokerPermissionResult(int request_id, | 2271 void WebContentsImpl::OnPpapiBrokerPermissionResult(int request_id, |
2267 bool result) { | 2272 bool result) { |
2268 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); | 2273 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); |
2269 rvh->Send(new ViewMsg_PpapiBrokerPermissionResult(rvh->GetRoutingID(), | 2274 rvh->Send(new ViewMsg_PpapiBrokerPermissionResult(rvh->GetRoutingID(), |
2270 request_id, | 2275 request_id, |
2271 result)); | 2276 result)); |
2272 } | 2277 } |
2273 | 2278 |
2279 void WebContentsImpl::OnBrowserPluginNavigateGuest(int instance_id, | |
2280 int64 frame_id, | |
2281 std::string src, | |
2282 gfx::Size size) { | |
2283 // This is the first 'navigate' to a browser plugin, before WebContents has/is | |
2284 // an 'Embedder'; subsequent navigate messages for this WebContents will | |
2285 // be handled by the BrowserPluginEmbedderHelper of the embedder itself (this | |
2286 // also means any message from browser plugin renderer prior to NavigateGuest | |
2287 // which is not NavigateGuest will be ignored). Therefore | |
2288 // browser_plugin_embedder_ should not be set. | |
awong
2012/09/06 00:23:27
browser_plugin_embedder_ -> |browser_plugin_embedd
lazyboy
2012/09/06 04:33:53
Done.
| |
2289 DCHECK(!browser_plugin_embedder_.get()); | |
awong
2012/09/06 00:23:27
How "impossible" is it for a bug to creep in that
lazyboy
2012/09/06 04:33:53
Changed to CHECK.
| |
2290 | |
2291 browser_plugin_embedder_.reset( | |
2292 content::BrowserPluginEmbedder::Create(this, GetRenderViewHost())); | |
2293 browser_plugin_embedder_->NavigateGuest(GetRenderViewHost(), | |
2294 instance_id, | |
2295 frame_id, | |
2296 src, | |
2297 size); | |
2298 } | |
2299 | |
2274 // Notifies the RenderWidgetHost instance about the fact that the page is | 2300 // Notifies the RenderWidgetHost instance about the fact that the page is |
2275 // loading, or done loading and calls the base implementation. | 2301 // loading, or done loading and calls the base implementation. |
2276 void WebContentsImpl::SetIsLoading(bool is_loading, | 2302 void WebContentsImpl::SetIsLoading(bool is_loading, |
2277 LoadNotificationDetails* details) { | 2303 LoadNotificationDetails* details) { |
2278 if (is_loading == is_loading_) | 2304 if (is_loading == is_loading_) |
2279 return; | 2305 return; |
2280 | 2306 |
2281 if (!is_loading) { | 2307 if (!is_loading) { |
2282 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 2308 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
2283 load_state_host_.clear(); | 2309 load_state_host_.clear(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2420 | 2446 |
2421 void WebContentsImpl::NotifySwapped() { | 2447 void WebContentsImpl::NotifySwapped() { |
2422 // After sending out a swap notification, we need to send a disconnect | 2448 // After sending out a swap notification, we need to send a disconnect |
2423 // notification so that clients that pick up a pointer to |this| can NULL the | 2449 // notification so that clients that pick up a pointer to |this| can NULL the |
2424 // pointer. See Bug 1230284. | 2450 // pointer. See Bug 1230284. |
2425 notify_disconnection_ = true; | 2451 notify_disconnection_ = true; |
2426 content::NotificationService::current()->Notify( | 2452 content::NotificationService::current()->Notify( |
2427 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 2453 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, |
2428 content::Source<WebContents>(this), | 2454 content::Source<WebContents>(this), |
2429 content::NotificationService::NoDetails()); | 2455 content::NotificationService::NoDetails()); |
2456 | |
2457 // Once we swap RenderViewHosts, we remove browser plugin embedder if its | |
2458 // associated RenderViewHost has been swapped out. | |
awong
2012/09/06 00:23:27
This comment just describes the code directly. Ins
lazyboy
2012/09/06 04:33:53
Done.
| |
2459 RemoveSwappedOutBrowserPluginEmbedder(); | |
2430 } | 2460 } |
2431 | 2461 |
2432 void WebContentsImpl::NotifyConnected() { | 2462 void WebContentsImpl::NotifyConnected() { |
2433 notify_disconnection_ = true; | 2463 notify_disconnection_ = true; |
2434 content::NotificationService::current()->Notify( | 2464 content::NotificationService::current()->Notify( |
2435 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 2465 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
2436 content::Source<WebContents>(this), | 2466 content::Source<WebContents>(this), |
2437 content::NotificationService::NoDetails()); | 2467 content::NotificationService::NoDetails()); |
2438 } | 2468 } |
2439 | 2469 |
(...skipping 25 matching lines...) Expand all Loading... | |
2465 WebContents* WebContentsImpl::GetAsWebContents() { | 2495 WebContents* WebContentsImpl::GetAsWebContents() { |
2466 return this; | 2496 return this; |
2467 } | 2497 } |
2468 | 2498 |
2469 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { | 2499 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { |
2470 if (delegate_) | 2500 if (delegate_) |
2471 return delegate_->GetRootWindowResizerRect(); | 2501 return delegate_->GetRootWindowResizerRect(); |
2472 return gfx::Rect(); | 2502 return gfx::Rect(); |
2473 } | 2503 } |
2474 | 2504 |
2505 void WebContentsImpl::RemoveSwappedOutBrowserPluginEmbedder() { | |
2506 if (browser_plugin_embedder_.get() && | |
2507 !browser_plugin_embedder_->IsForRenderViewHost(GetRenderViewHost())) { | |
2508 browser_plugin_embedder_.reset(); | |
2509 } | |
2510 } | |
2511 | |
2475 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 2512 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
2476 // Don't send notifications if we are just creating a swapped-out RVH for | 2513 // Don't send notifications if we are just creating a swapped-out RVH for |
2477 // the opener chain. These won't be used for view-source or WebUI, so it's | 2514 // the opener chain. These won't be used for view-source or WebUI, so it's |
2478 // ok to return early. | 2515 // ok to return early. |
2479 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) | 2516 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) |
2480 return; | 2517 return; |
2481 | 2518 |
2482 content::NotificationService::current()->Notify( | 2519 content::NotificationService::current()->Notify( |
2483 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2520 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
2484 content::Source<WebContents>(this), | 2521 content::Source<WebContents>(this), |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3253 old_browser_plugin_host()->embedder_render_process_host(); | 3290 old_browser_plugin_host()->embedder_render_process_host(); |
3254 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3291 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
3255 int embedder_process_id = | 3292 int embedder_process_id = |
3256 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3293 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3257 if (embedder_process_id != -1) { | 3294 if (embedder_process_id != -1) { |
3258 *embedder_channel_name = | 3295 *embedder_channel_name = |
3259 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3296 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3260 embedder_process_id); | 3297 embedder_process_id); |
3261 } | 3298 } |
3262 } | 3299 } |
3300 | |
3301 content::BrowserPluginGuest* WebContentsImpl::SetBrowserPluginGuest( | |
3302 int instance_id) { | |
3303 browser_plugin_guest_.reset(content::BrowserPluginGuest::Create( | |
3304 instance_id, this, GetRenderViewHost())); | |
3305 return browser_plugin_guest_.get(); | |
3306 } | |
3307 | |
3308 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | |
3309 return browser_plugin_guest_.get(); | |
3310 } | |
3311 | |
3312 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | |
3313 return browser_plugin_embedder_.get(); | |
3314 } | |
OLD | NEW |