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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 9609008: Implemented Browser Plugin (NOT FOR REVIEW) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merged with Tip-of-Tree Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | example.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "content/public/renderer/content_renderer_client.h" 48 #include "content/public/renderer/content_renderer_client.h"
49 #include "content/public/renderer/document_state.h" 49 #include "content/public/renderer/document_state.h"
50 #include "content/public/renderer/navigation_state.h" 50 #include "content/public/renderer/navigation_state.h"
51 #include "content/public/renderer/render_view_observer.h" 51 #include "content/public/renderer/render_view_observer.h"
52 #include "content/public/renderer/render_view_visitor.h" 52 #include "content/public/renderer/render_view_visitor.h"
53 #include "content/renderer/device_orientation_dispatcher.h" 53 #include "content/renderer/device_orientation_dispatcher.h"
54 #include "content/renderer/devtools_agent.h" 54 #include "content/renderer/devtools_agent.h"
55 #include "content/renderer/dom_automation_controller.h" 55 #include "content/renderer/dom_automation_controller.h"
56 #include "content/renderer/external_popup_menu.h" 56 #include "content/renderer/external_popup_menu.h"
57 #include "content/renderer/geolocation_dispatcher.h" 57 #include "content/renderer/geolocation_dispatcher.h"
58 #include "content/renderer/guest_render_view_observer.h"
58 #include "content/renderer/idle_user_detector.h" 59 #include "content/renderer/idle_user_detector.h"
59 #include "content/renderer/input_tag_speech_dispatcher.h" 60 #include "content/renderer/input_tag_speech_dispatcher.h"
60 #include "content/renderer/web_intents_host.h" 61 #include "content/renderer/web_intents_host.h"
61 #include "content/renderer/java/java_bridge_dispatcher.h" 62 #include "content/renderer/java/java_bridge_dispatcher.h"
62 #include "content/renderer/load_progress_tracker.h" 63 #include "content/renderer/load_progress_tracker.h"
63 #include "content/renderer/media/audio_message_filter.h" 64 #include "content/renderer/media/audio_message_filter.h"
64 #include "content/renderer/media/audio_renderer_impl.h" 65 #include "content/renderer/media/audio_renderer_impl.h"
65 #include "content/renderer/media/media_stream_dependency_factory.h" 66 #include "content/renderer/media/media_stream_dependency_factory.h"
66 #include "content/renderer/media/media_stream_dispatcher.h" 67 #include "content/renderer/media/media_stream_dispatcher.h"
67 #include "content/renderer/media/media_stream_impl.h" 68 #include "content/renderer/media/media_stream_impl.h"
68 #include "content/renderer/media/render_audiosourceprovider.h" 69 #include "content/renderer/media/render_audiosourceprovider.h"
69 #include "content/renderer/media/render_media_log.h" 70 #include "content/renderer/media/render_media_log.h"
70 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h" 71 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h"
71 #include "content/renderer/mhtml_generator.h" 72 #include "content/renderer/mhtml_generator.h"
72 #include "content/renderer/mouse_lock_dispatcher.h" 73 #include "content/renderer/mouse_lock_dispatcher.h"
73 #include "content/renderer/notification_provider.h" 74 #include "content/renderer/notification_provider.h"
74 #include "content/renderer/p2p/socket_dispatcher.h" 75 #include "content/renderer/p2p/socket_dispatcher.h"
75 #include "content/renderer/plugin_channel_host.h" 76 #include "content/renderer/plugin_channel_host.h"
77 #include "content/renderer/plugins/browser_plugin_placeholder.h"
76 #include "content/renderer/render_process.h" 78 #include "content/renderer/render_process.h"
77 #include "content/renderer/render_thread_impl.h" 79 #include "content/renderer/render_thread_impl.h"
78 #include "content/renderer/render_widget_fullscreen_pepper.h" 80 #include "content/renderer/render_widget_fullscreen_pepper.h"
79 #include "content/renderer/renderer_accessibility.h" 81 #include "content/renderer/renderer_accessibility.h"
80 #include "content/renderer/renderer_webapplicationcachehost_impl.h" 82 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
81 #include "content/renderer/renderer_webstoragenamespace_impl.h" 83 #include "content/renderer/renderer_webstoragenamespace_impl.h"
82 #include "content/renderer/text_input_client_observer.h" 84 #include "content/renderer/text_input_client_observer.h"
83 #include "content/renderer/v8_value_converter_impl.h" 85 #include "content/renderer/v8_value_converter_impl.h"
84 #include "content/renderer/web_ui_bindings.h" 86 #include "content/renderer/web_ui_bindings.h"
85 #include "content/renderer/webplugin_delegate_proxy.h" 87 #include "content/renderer/webplugin_delegate_proxy.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 #include "webkit/glue/webdropdata.h" 160 #include "webkit/glue/webdropdata.h"
159 #include "webkit/glue/webkit_constants.h" 161 #include "webkit/glue/webkit_constants.h"
160 #include "webkit/glue/webkit_glue.h" 162 #include "webkit/glue/webkit_glue.h"
161 #include "webkit/glue/weburlloader_impl.h" 163 #include "webkit/glue/weburlloader_impl.h"
162 #include "webkit/glue/weburlresponse_extradata_impl.h" 164 #include "webkit/glue/weburlresponse_extradata_impl.h"
163 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 165 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
164 #include "webkit/media/webmediaplayer_impl.h" 166 #include "webkit/media/webmediaplayer_impl.h"
165 #include "webkit/plugins/npapi/plugin_list.h" 167 #include "webkit/plugins/npapi/plugin_list.h"
166 #include "webkit/plugins/npapi/webplugin_delegate.h" 168 #include "webkit/plugins/npapi/webplugin_delegate.h"
167 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" 169 #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
170 #include "webkit/plugins/plugin_constants.h"
168 #include "webkit/plugins/npapi/webplugin_impl.h" 171 #include "webkit/plugins/npapi/webplugin_impl.h"
169 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 172 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
170 173
171 #if defined(OS_WIN) 174 #if defined(OS_WIN)
172 // TODO(port): these files are currently Windows only because they concern: 175 // TODO(port): these files are currently Windows only because they concern:
173 // * theming 176 // * theming
174 #include "ui/gfx/native_theme_win.h" 177 #include "ui/gfx/native_theme_win.h"
175 #elif defined(USE_X11) 178 #elif defined(USE_X11)
176 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme. h" 179 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme. h"
177 #include "ui/gfx/native_theme.h" 180 #include "ui/gfx/native_theme.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 target_url_status_(TARGET_NONE), 440 target_url_status_(TARGET_NONE),
438 selection_text_offset_(0), 441 selection_text_offset_(0),
439 cached_is_main_frame_pinned_to_left_(false), 442 cached_is_main_frame_pinned_to_left_(false),
440 cached_is_main_frame_pinned_to_right_(false), 443 cached_is_main_frame_pinned_to_right_(false),
441 cached_has_main_frame_horizontal_scrollbar_(false), 444 cached_has_main_frame_horizontal_scrollbar_(false),
442 cached_has_main_frame_vertical_scrollbar_(false), 445 cached_has_main_frame_vertical_scrollbar_(false),
443 context_has_swapbuffers_complete_callback_(false), 446 context_has_swapbuffers_complete_callback_(false),
444 queried_for_swapbuffers_complete_callback_(false), 447 queried_for_swapbuffers_complete_callback_(false),
445 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 448 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
446 geolocation_dispatcher_(NULL), 449 geolocation_dispatcher_(NULL),
450 guest_observer_(NULL),
447 input_tag_speech_dispatcher_(NULL), 451 input_tag_speech_dispatcher_(NULL),
448 device_orientation_dispatcher_(NULL), 452 device_orientation_dispatcher_(NULL),
449 media_stream_dispatcher_(NULL), 453 media_stream_dispatcher_(NULL),
450 p2p_socket_dispatcher_(NULL), 454 p2p_socket_dispatcher_(NULL),
451 devtools_agent_(NULL), 455 devtools_agent_(NULL),
452 renderer_accessibility_(NULL), 456 renderer_accessibility_(NULL),
453 mouse_lock_dispatcher_(NULL), 457 mouse_lock_dispatcher_(NULL),
454 session_storage_namespace_id_(session_storage_namespace_id), 458 session_storage_namespace_id_(session_storage_namespace_id),
455 handling_select_range_(false), 459 handling_select_range_(false),
456 #if defined(OS_WIN) 460 #if defined(OS_WIN)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 494
491 // If this is a popup, we must wait for the CreatingNew_ACK message before 495 // If this is a popup, we must wait for the CreatingNew_ACK message before
492 // completing initialization. Otherwise, we can finish it now. 496 // completing initialization. Otherwise, we can finish it now.
493 if (opener_id == MSG_ROUTING_NONE) { 497 if (opener_id == MSG_ROUTING_NONE) {
494 did_show_ = true; 498 did_show_ = true;
495 CompleteInit(parent_hwnd); 499 CompleteInit(parent_hwnd);
496 } 500 }
497 501
498 g_view_map.Get().insert(std::make_pair(webview(), this)); 502 g_view_map.Get().insert(std::make_pair(webview(), this));
499 webkit_preferences_.Apply(webview()); 503 webkit_preferences_.Apply(webview());
504
505 // This needs to be before initializeMainFrame it seems.
506 // PpapiMsg_CreateChannel messages can get lost if the guest
507 // observer has not been constructed before a sync message.
508 if (!guest_observer_)
509 guest_observer_ = new GuestRenderViewObserver(this);
510
500 webview()->initializeMainFrame(this); 511 webview()->initializeMainFrame(this);
501 if (!frame_name.empty()) 512 if (!frame_name.empty())
502 webview()->mainFrame()->setName(frame_name); 513 webview()->mainFrame()->setName(frame_name);
503 webview()->settings()->setMinimumTimerInterval( 514 webview()->settings()->setMinimumTimerInterval(
504 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : 515 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval :
505 webkit_glue::kForegroundTabTimerInterval); 516 webkit_glue::kForegroundTabTimerInterval);
506 517
507 OnSetRendererPrefs(renderer_prefs); 518 OnSetRendererPrefs(renderer_prefs);
508 519
509 host_window_ = parent_hwnd; 520 host_window_ = parent_hwnd;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) 830 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize)
820 #endif 831 #endif
821 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, 832 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune,
822 OnSetHistoryLengthAndPrune) 833 OnSetHistoryLengthAndPrune)
823 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 834 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
824 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) 835 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit)
825 836
826 // Have the super handle all other messages. 837 // Have the super handle all other messages.
827 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) 838 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
828 IPC_END_MESSAGE_MAP() 839 IPC_END_MESSAGE_MAP()
829
830 if (!msg_is_ok) { 840 if (!msg_is_ok) {
831 // The message had a handler, but its deserialization failed. 841 // The message had a handler, but its deserialization failed.
832 // Kill the renderer to avoid potential spoofing attacks. 842 // Kill the renderer to avoid potential spoofing attacks.
833 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; 843 CHECK(false) << "Unable to deserialize message in RenderViewImpl.";
834 } 844 }
835
836 return handled; 845 return handled;
837 } 846 }
838 847
839 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { 848 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) {
840 MaybeHandleDebugURL(params.url); 849 MaybeHandleDebugURL(params.url);
841 if (!webview()) 850 if (!webview())
842 return; 851 return;
843 852
844 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); 853 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url));
845 854
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( 1551 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D(
1543 const WebGraphicsContext3D::Attributes& attributes) { 1552 const WebGraphicsContext3D::Attributes& attributes) {
1544 return createGraphicsContext3D(attributes, true); 1553 return createGraphicsContext3D(attributes, true);
1545 } 1554 }
1546 1555
1547 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( 1556 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D(
1548 const WebGraphicsContext3D::Attributes& attributes, 1557 const WebGraphicsContext3D::Attributes& attributes,
1549 bool direct) { 1558 bool direct) {
1550 if (!webview()) 1559 if (!webview())
1551 return NULL; 1560 return NULL;
1561
1562 if (guest_observer_ && guest_observer_->GetWebGraphicsContext3D())
1563 return guest_observer_->GetWebGraphicsContext3D();
1552 // The WebGraphicsContext3DInProcessImpl code path is used for 1564 // The WebGraphicsContext3DInProcessImpl code path is used for
1553 // layout tests (though not through this code) as well as for 1565 // layout tests (though not through this code) as well as for
1554 // debugging and bringing up new ports. 1566 // debugging and bringing up new ports.
1555 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { 1567 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
1556 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( 1568 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
1557 attributes, direct); 1569 attributes, direct);
1558 } else { 1570 } else {
1559 int surface = direct ? surface_id() : 0; 1571 int surface = direct ? surface_id() : 0;
1560 1572
1561 GURL url; 1573 GURL url;
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after
3425 if (node.isContentEditable()) { 3437 if (node.isContentEditable()) {
3426 is_editable_node = true; 3438 is_editable_node = true;
3427 } else if (node.isElementNode()) { 3439 } else if (node.isElementNode()) {
3428 is_editable_node = 3440 is_editable_node =
3429 node.toConst<WebElement>().isTextFormControlElement(); 3441 node.toConst<WebElement>().isTextFormControlElement();
3430 } 3442 }
3431 } 3443 }
3432 return is_editable_node; 3444 return is_editable_node;
3433 } 3445 }
3434 3446
3447 WebKit::WebPlugin* RenderViewImpl::CreateBrowserPlugin(
3448 base::ProcessHandle process_handle,
3449 const IPC::ChannelHandle& channel_handle,
3450 const WebKit::WebPluginParams& params) {
3451 scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
3452 pepper_delegate_.CreateBrowserPluginModule(process_handle,
3453 channel_handle));
3454 return new webkit::ppapi::WebPluginImpl(
3455 pepper_module.get(), params, pepper_delegate_.AsWeakPtr());
3456 }
3457
3435 WebKit::WebPlugin* RenderViewImpl::CreatePlugin( 3458 WebKit::WebPlugin* RenderViewImpl::CreatePlugin(
3436 WebKit::WebFrame* frame, 3459 WebKit::WebFrame* frame,
3437 const webkit::WebPluginInfo& info, 3460 const webkit::WebPluginInfo& info,
3438 const WebKit::WebPluginParams& params) { 3461 const WebKit::WebPluginParams& params) {
3462
3463 // The browser plugin is a special kind of pepper plugin
3464 // that loads asynchronously. We first create a placeholder here.
3465 // When a guest is ready to be displayed, we swap out the placeholder
3466 // with the guest.
3467 if (UTF16ToASCII(info.name) == kBrowserPluginName)
3468 return BrowserPluginPlaceholder::Create(this, frame, params);
3469
3439 bool pepper_plugin_was_registered = false; 3470 bool pepper_plugin_was_registered = false;
3440 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( 3471 scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
3441 pepper_delegate_.CreatePepperPluginModule(info, 3472 pepper_delegate_.CreatePepperPluginModule(info,
3442 &pepper_plugin_was_registered)); 3473 &pepper_plugin_was_registered));
3443 if (pepper_plugin_was_registered) { 3474 if (pepper_plugin_was_registered) {
3444 if (!pepper_module) 3475 if (!pepper_module)
3445 return NULL; 3476 return NULL;
3446 return new webkit::ppapi::WebPluginImpl( 3477 return new webkit::ppapi::WebPluginImpl(
3447 pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); 3478 pepper_module.get(), params, pepper_delegate_.AsWeakPtr());
3448 } 3479 }
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
5117 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5148 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5118 return !!RenderThreadImpl::current()->compositor_thread(); 5149 return !!RenderThreadImpl::current()->compositor_thread();
5119 } 5150 }
5120 5151
5121 void RenderViewImpl::OnJavaBridgeInit() { 5152 void RenderViewImpl::OnJavaBridgeInit() {
5122 DCHECK(!java_bridge_dispatcher_.get()); 5153 DCHECK(!java_bridge_dispatcher_.get());
5123 #if defined(ENABLE_JAVA_BRIDGE) 5154 #if defined(ENABLE_JAVA_BRIDGE)
5124 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5155 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5125 #endif 5156 #endif
5126 } 5157 }
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | example.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698