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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | 683 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) |
681 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 684 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
682 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) | 685 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) |
683 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) | 686 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) |
684 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, | 687 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, |
685 OnSetSelectedColorInColorChooser) | 688 OnSetSelectedColorInColorChooser) |
686 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) | 689 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) |
687 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 690 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
688 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 691 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
689 OnRequestPpapiBrokerPermission) | 692 OnRequestPpapiBrokerPermission) |
| 693 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, |
| 694 OnBrowserPluginNavigateGuest) |
690 IPC_MESSAGE_UNHANDLED(handled = false) | 695 IPC_MESSAGE_UNHANDLED(handled = false) |
691 IPC_END_MESSAGE_MAP_EX() | 696 IPC_END_MESSAGE_MAP_EX() |
692 message_source_ = NULL; | 697 message_source_ = NULL; |
693 | 698 |
694 if (!message_is_ok) { | 699 if (!message_is_ok) { |
695 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 700 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
696 GetRenderProcessHost()->ReceivedBadMessage(); | 701 GetRenderProcessHost()->ReceivedBadMessage(); |
697 } | 702 } |
698 | 703 |
699 return handled; | 704 return handled; |
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 } | 2272 } |
2268 | 2273 |
2269 void WebContentsImpl::OnPpapiBrokerPermissionResult(int request_id, | 2274 void WebContentsImpl::OnPpapiBrokerPermissionResult(int request_id, |
2270 bool result) { | 2275 bool result) { |
2271 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); | 2276 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); |
2272 rvh->Send(new ViewMsg_PpapiBrokerPermissionResult(rvh->GetRoutingID(), | 2277 rvh->Send(new ViewMsg_PpapiBrokerPermissionResult(rvh->GetRoutingID(), |
2273 request_id, | 2278 request_id, |
2274 result)); | 2279 result)); |
2275 } | 2280 } |
2276 | 2281 |
| 2282 void WebContentsImpl::OnBrowserPluginNavigateGuest(int instance_id, |
| 2283 int64 frame_id, |
| 2284 const std::string& src, |
| 2285 const gfx::Size& size) { |
| 2286 // This is the first 'navigate' to a browser plugin, before WebContents has/is |
| 2287 // an 'Embedder'; subsequent navigate messages for this WebContents will |
| 2288 // be handled by the BrowserPluginEmbedderHelper of the embedder itself (this |
| 2289 // also means any message from browser plugin renderer prior to NavigateGuest |
| 2290 // which is not NavigateGuest will be ignored). Therefore |
| 2291 // |browser_plugin_embedder_| should not be set. |
| 2292 // For more info, see comment above classes BrowserPluginEmbedder and |
| 2293 // BrowserPluginGuest. |
| 2294 CHECK(!browser_plugin_embedder_.get()); |
| 2295 |
| 2296 browser_plugin_embedder_.reset( |
| 2297 content::BrowserPluginEmbedder::Create(this, GetRenderViewHost())); |
| 2298 browser_plugin_embedder_->NavigateGuest(GetRenderViewHost(), |
| 2299 instance_id, |
| 2300 frame_id, |
| 2301 src, |
| 2302 size); |
| 2303 } |
| 2304 |
2277 // Notifies the RenderWidgetHost instance about the fact that the page is | 2305 // Notifies the RenderWidgetHost instance about the fact that the page is |
2278 // loading, or done loading and calls the base implementation. | 2306 // loading, or done loading and calls the base implementation. |
2279 void WebContentsImpl::SetIsLoading(bool is_loading, | 2307 void WebContentsImpl::SetIsLoading(bool is_loading, |
2280 LoadNotificationDetails* details) { | 2308 LoadNotificationDetails* details) { |
2281 if (is_loading == is_loading_) | 2309 if (is_loading == is_loading_) |
2282 return; | 2310 return; |
2283 | 2311 |
2284 if (!is_loading) { | 2312 if (!is_loading) { |
2285 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 2313 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
2286 load_state_host_.clear(); | 2314 load_state_host_.clear(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2423 | 2451 |
2424 void WebContentsImpl::NotifySwapped() { | 2452 void WebContentsImpl::NotifySwapped() { |
2425 // After sending out a swap notification, we need to send a disconnect | 2453 // After sending out a swap notification, we need to send a disconnect |
2426 // notification so that clients that pick up a pointer to |this| can NULL the | 2454 // notification so that clients that pick up a pointer to |this| can NULL the |
2427 // pointer. See Bug 1230284. | 2455 // pointer. See Bug 1230284. |
2428 notify_disconnection_ = true; | 2456 notify_disconnection_ = true; |
2429 content::NotificationService::current()->Notify( | 2457 content::NotificationService::current()->Notify( |
2430 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 2458 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, |
2431 content::Source<WebContents>(this), | 2459 content::Source<WebContents>(this), |
2432 content::NotificationService::NoDetails()); | 2460 content::NotificationService::NoDetails()); |
| 2461 |
| 2462 // Ensure that the associated embedder gets cleared after a RenderViewHost |
| 2463 // gets swapped, so we don't reuse the same embedder next time a |
| 2464 // RenderViewHost is attached to this WebContents (for security concerns). |
| 2465 RemoveSwappedOutBrowserPluginEmbedder(); |
2433 } | 2466 } |
2434 | 2467 |
2435 void WebContentsImpl::NotifyConnected() { | 2468 void WebContentsImpl::NotifyConnected() { |
2436 notify_disconnection_ = true; | 2469 notify_disconnection_ = true; |
2437 content::NotificationService::current()->Notify( | 2470 content::NotificationService::current()->Notify( |
2438 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 2471 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
2439 content::Source<WebContents>(this), | 2472 content::Source<WebContents>(this), |
2440 content::NotificationService::NoDetails()); | 2473 content::NotificationService::NoDetails()); |
2441 } | 2474 } |
2442 | 2475 |
(...skipping 25 matching lines...) Expand all Loading... |
2468 WebContents* WebContentsImpl::GetAsWebContents() { | 2501 WebContents* WebContentsImpl::GetAsWebContents() { |
2469 return this; | 2502 return this; |
2470 } | 2503 } |
2471 | 2504 |
2472 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { | 2505 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { |
2473 if (delegate_) | 2506 if (delegate_) |
2474 return delegate_->GetRootWindowResizerRect(); | 2507 return delegate_->GetRootWindowResizerRect(); |
2475 return gfx::Rect(); | 2508 return gfx::Rect(); |
2476 } | 2509 } |
2477 | 2510 |
| 2511 void WebContentsImpl::RemoveSwappedOutBrowserPluginEmbedder() { |
| 2512 if (browser_plugin_embedder_.get()) |
| 2513 browser_plugin_embedder_.reset(); |
| 2514 } |
| 2515 |
2478 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 2516 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
2479 // Don't send notifications if we are just creating a swapped-out RVH for | 2517 // Don't send notifications if we are just creating a swapped-out RVH for |
2480 // the opener chain. These won't be used for view-source or WebUI, so it's | 2518 // the opener chain. These won't be used for view-source or WebUI, so it's |
2481 // ok to return early. | 2519 // ok to return early. |
2482 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) | 2520 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) |
2483 return; | 2521 return; |
2484 | 2522 |
2485 content::NotificationService::current()->Notify( | 2523 content::NotificationService::current()->Notify( |
2486 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2524 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
2487 content::Source<WebContents>(this), | 2525 content::Source<WebContents>(this), |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3256 old_browser_plugin_host()->embedder_render_process_host(); | 3294 old_browser_plugin_host()->embedder_render_process_host(); |
3257 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3295 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
3258 int embedder_process_id = | 3296 int embedder_process_id = |
3259 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3297 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3260 if (embedder_process_id != -1) { | 3298 if (embedder_process_id != -1) { |
3261 *embedder_channel_name = | 3299 *embedder_channel_name = |
3262 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3300 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3263 embedder_process_id); | 3301 embedder_process_id); |
3264 } | 3302 } |
3265 } | 3303 } |
| 3304 |
| 3305 content::BrowserPluginGuest* WebContentsImpl::AssignBrowserPluginGuest( |
| 3306 int instance_id) { |
| 3307 // This makes this WebContents to have a guest role. |
| 3308 // For more info, see comment above class BrowserPluginGuest. |
| 3309 browser_plugin_guest_.reset(content::BrowserPluginGuest::Create( |
| 3310 instance_id, this, GetRenderViewHost())); |
| 3311 return browser_plugin_guest_.get(); |
| 3312 } |
| 3313 |
| 3314 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3315 return browser_plugin_guest_.get(); |
| 3316 } |
| 3317 |
| 3318 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3319 return browser_plugin_embedder_.get(); |
| 3320 } |
OLD | NEW |