Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 10868012: Browser Plugin: New Implementation (Browser Side) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-trial-obrowser
Patch Set: Address CL comments. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 // TODO(lazyboy, rjkroege): This might trigger a race condition if we receive
2199 // NavigateGuest message in WebContents via IO thread (by capturing it via
2200 // MesssageFilter) for the following case: if first two 'NavigateGuest'
2201 // messages are around the same time (i.e. both gets routed to WebContents
2202 // before BrowserPluginEmbedderHelper has a chance to intercept the second
2203 // 'NavigateGuest' message).
2204 browser_plugin_embedder_.reset(
2205 new content::BrowserPluginEmbedder(this, GetRenderViewHost()));
2206 browser_plugin_embedder_->NavigateGuest(GetRenderViewHost(),
2207 instance_id,
2208 frame_id,
2209 src,
2210 size);
2211 }
2212
2181 // Notifies the RenderWidgetHost instance about the fact that the page is 2213 // Notifies the RenderWidgetHost instance about the fact that the page is
2182 // loading, or done loading and calls the base implementation. 2214 // loading, or done loading and calls the base implementation.
2183 void WebContentsImpl::SetIsLoading(bool is_loading, 2215 void WebContentsImpl::SetIsLoading(bool is_loading,
2184 LoadNotificationDetails* details) { 2216 LoadNotificationDetails* details) {
2185 if (is_loading == is_loading_) 2217 if (is_loading == is_loading_)
2186 return; 2218 return;
2187 2219
2188 if (!is_loading) { 2220 if (!is_loading) {
2189 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); 2221 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16());
2190 load_state_host_.clear(); 2222 load_state_host_.clear();
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 old_browser_plugin_host()->embedder_render_process_host(); 3173 old_browser_plugin_host()->embedder_render_process_host();
3142 *embedder_container_id = old_browser_plugin_host()->instance_id(); 3174 *embedder_container_id = old_browser_plugin_host()->instance_id();
3143 int embedder_process_id = 3175 int embedder_process_id =
3144 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; 3176 embedder_render_process_host ? embedder_render_process_host->GetID() : -1;
3145 if (embedder_process_id != -1) { 3177 if (embedder_process_id != -1) {
3146 *embedder_channel_name = 3178 *embedder_channel_name =
3147 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), 3179 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(),
3148 embedder_process_id); 3180 embedder_process_id);
3149 } 3181 }
3150 } 3182 }
3183
3184 content::BrowserPluginGuest* WebContentsImpl::SetBrowserPluginGuest(
3185 int instance_id) {
3186 browser_plugin_guest_.reset(new content::BrowserPluginGuest(
3187 instance_id, this, GetRenderViewHost()));
3188 return browser_plugin_guest_.get();
3189 }
3190
3191 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
3192 return browser_plugin_guest_.get();
3193 }
3194
3195 content::BrowserPluginEmbedder* WebContentsImpl::
Charlie Reis 2012/08/29 00:11:04 nit: Please move the WebContentsImpl:: part to the
lazyboy 2012/08/29 21:37:25 This actually fits now in one line after renaming
3196 GetBrowserPluginEmbedder() {
3197 return browser_plugin_embedder_.get();
3198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698