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_host_embedder_role.h" |
| 19 #include "content/browser/browser_plugin/browser_plugin_host_guest_role.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 plays |
| 2191 // an 'Embedder' role, subsequent navigate messages for this WebContents will |
| 2192 // be handled by the BrowserPluginHostEmbedderRole itself (this also means any |
| 2193 // message from browser plugin renderer prior to NavigateGuest which is not |
| 2194 // NavigateGuest will be ignored). Therefore embedder_role_ should not be set. |
| 2195 DCHECK(!embedder_role_.get()); |
| 2196 |
| 2197 // TODO(lazyboy, rjkroege): This might trigger a race condition if we receive |
| 2198 // NavigateGuest message in WebContents via IO thread (by capturing it via |
| 2199 // MesssageFilter) for the following case: if first two 'NavigateGuest' |
| 2200 // messages are around the same time (i.e. both gets routed to WebContents |
| 2201 // before BrowserPluginHostEmbedderRole has a chance to intercept the second |
| 2202 // 'NavigateGuest' message). |
| 2203 embedder_role_.reset( |
| 2204 new content::BrowserPluginHostEmbedderRole(this, GetRenderViewHost())); |
| 2205 embedder_role_->NavigateGuest(instance_id, frame_id, src, size); |
| 2206 } |
| 2207 |
2181 // Notifies the RenderWidgetHost instance about the fact that the page is | 2208 // Notifies the RenderWidgetHost instance about the fact that the page is |
2182 // loading, or done loading and calls the base implementation. | 2209 // loading, or done loading and calls the base implementation. |
2183 void WebContentsImpl::SetIsLoading(bool is_loading, | 2210 void WebContentsImpl::SetIsLoading(bool is_loading, |
2184 LoadNotificationDetails* details) { | 2211 LoadNotificationDetails* details) { |
2185 if (is_loading == is_loading_) | 2212 if (is_loading == is_loading_) |
2186 return; | 2213 return; |
2187 | 2214 |
2188 if (!is_loading) { | 2215 if (!is_loading) { |
2189 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 2216 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
2190 load_state_host_.clear(); | 2217 load_state_host_.clear(); |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3141 old_browser_plugin_host()->embedder_render_process_host(); | 3168 old_browser_plugin_host()->embedder_render_process_host(); |
3142 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3169 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
3143 int embedder_process_id = | 3170 int embedder_process_id = |
3144 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3171 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3145 if (embedder_process_id != -1) { | 3172 if (embedder_process_id != -1) { |
3146 *embedder_channel_name = | 3173 *embedder_channel_name = |
3147 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3174 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3148 embedder_process_id); | 3175 embedder_process_id); |
3149 } | 3176 } |
3150 } | 3177 } |
| 3178 |
| 3179 content::BrowserPluginHostGuestRole* WebContentsImpl::AddGuestRole( |
| 3180 int instance_id, |
| 3181 content::RenderProcessHost* render_process_host) { |
| 3182 guest_role_.reset(new content::BrowserPluginHostGuestRole( |
| 3183 instance_id, this, GetRenderViewHost())); |
| 3184 return guest_role_.get(); |
| 3185 } |
| 3186 |
| 3187 content::BrowserPluginHostGuestRole* WebContentsImpl::GetGuestRole() { |
| 3188 return guest_role_.get(); |
| 3189 } |
| 3190 |
| 3191 content::BrowserPluginHostEmbedderRole* WebContentsImpl::GetEmbedderRole() { |
| 3192 return embedder_role_.get(); |
| 3193 } |
OLD | NEW |