Chromium Code Reviews| Index: content/renderer/render_view_impl.cc |
| diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
| index 5f1411ceaf91025f28c64ab79deb37ce2a4ef7f8..d6da0b487ff7cf41258d4ce782990e9133dcd5f8 100644 |
| --- a/content/renderer/render_view_impl.cc |
| +++ b/content/renderer/render_view_impl.cc |
| @@ -88,6 +88,7 @@ |
| #include "content/renderer/media/rtc_peer_connection_handler.h" |
| #include "content/renderer/mhtml_generator.h" |
| #include "content/renderer/notification_provider.h" |
| +#include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
| #include "content/renderer/plugin_channel_host.h" |
| #include "content/renderer/render_process.h" |
| #include "content/renderer/render_thread_impl.h" |
| @@ -199,7 +200,6 @@ |
| #include "webkit/plugins/npapi/webplugin_delegate.h" |
| #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| #include "webkit/plugins/npapi/webplugin_impl.h" |
| -#include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
| #if defined(OS_ANDROID) |
| #include "content/common/android/device_info.h" |
| @@ -605,7 +605,13 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) |
| pending_frame_tree_update_(false), |
| target_process_id_(0), |
| target_routing_id_(0), |
| - ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
| +#if defined(ENABLE_PPAPI) |
|
brettw
2012/11/30 23:18:12
I think this should just go in the constructor rat
nilesh
2012/12/01 00:41:35
Done.
|
| + ALLOW_THIS_IN_INITIALIZER_LIST( |
| + pepper_delegate_(new PepperPluginDelegateImpl(this))) |
| +#else |
| + pepper_delegate_(new PluginDelegateHelper()) |
| +#endif |
| +{ |
| set_throttle_input_events(params->renderer_prefs.throttle_input_events); |
| routing_id_ = params->routing_id; |
| surface_id_ = params->surface_id; |
| @@ -4362,16 +4368,11 @@ WebKit::WebPlugin* RenderViewImpl::CreatePlugin( |
| WebKit::WebFrame* frame, |
| const webkit::WebPluginInfo& info, |
| const WebKit::WebPluginParams& params) { |
| - bool pepper_plugin_was_registered = false; |
| - scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
| - pepper_delegate_.CreatePepperPluginModule(info, |
| - &pepper_plugin_was_registered)); |
| - if (pepper_plugin_was_registered) { |
| - if (!pepper_module) |
| - return NULL; |
| - return new webkit::ppapi::WebPluginImpl( |
| - pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); |
| - } |
| + WebKit::WebPlugin* pepper_webplugin = |
| + pepper_delegate_->CreatePepperWebPlugin(info, params); |
| + |
| + if (pepper_webplugin) |
| + return pepper_webplugin; |
| #if defined(USE_AURA) && !defined(OS_WIN) |
| return NULL; |
| @@ -4555,8 +4556,8 @@ void RenderViewImpl::SyncSelectionIfRequired() { |
| size_t offset; |
| ui::Range range; |
| - if (pepper_delegate_.IsPluginFocused()) { |
| - pepper_delegate_.GetSurroundingText(&text, &range); |
| + if (pepper_delegate_->IsPluginFocused()) { |
| + pepper_delegate_->GetSurroundingText(&text, &range); |
| offset = 0; // Pepper API does not support offset reporting. |
| // TODO(kinaba): cut as needed. |
| } else { |
| @@ -5525,12 +5526,12 @@ void RenderViewImpl::OnResize(const gfx::Size& new_size, |
| void RenderViewImpl::WillInitiatePaint() { |
| // Notify the pepper plugins that we're about to paint. |
| - pepper_delegate_.ViewWillInitiatePaint(); |
| + pepper_delegate_->ViewWillInitiatePaint(); |
| } |
| void RenderViewImpl::DidInitiatePaint() { |
| // Notify the pepper plugins that we've painted, and are waiting to flush. |
| - pepper_delegate_.ViewInitiatedPaint(); |
| + pepper_delegate_->ViewInitiatedPaint(); |
| } |
| void RenderViewImpl::DidFlushPaint() { |
| @@ -5538,7 +5539,7 @@ void RenderViewImpl::DidFlushPaint() { |
| // and we it may ask to close itself as a result. This will, in turn, modify |
| // our set, possibly invalidating the iterator. So we iterate on a copy that |
| // won't change out from under us. |
| - pepper_delegate_.ViewFlushedPaint(); |
| + pepper_delegate_->ViewFlushedPaint(); |
| // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
| // See crbug.com/112921. |
| @@ -5584,7 +5585,7 @@ webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint( |
| gfx::Rect* location, |
| gfx::Rect* clip, |
| float* scale_factor) { |
| - return pepper_delegate_.GetBitmapForOptimizedPluginPaint( |
| + return pepper_delegate_->GetBitmapForOptimizedPluginPaint( |
| paint_bounds, dib, location, clip, scale_factor); |
| } |
| @@ -5704,7 +5705,7 @@ bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; |
| possible_drag_event_info_.event_location = |
| gfx::Point(event.globalX, event.globalY); |
| - pepper_delegate_.WillHandleMouseEvent(); |
| + pepper_delegate_->WillHandleMouseEvent(); |
| // If the mouse is locked, only the current owner of the mouse lock can |
| // process mouse events. |
| @@ -5747,7 +5748,7 @@ void RenderViewImpl::OnWasHidden() { |
| } |
| // Inform PPAPI plugins that their page is no longer visible. |
| - pepper_delegate_.PageVisibilityChanged(false); |
| + pepper_delegate_->PageVisibilityChanged(false); |
| #if defined(OS_MACOSX) |
| // Inform NPAPI plugins that their container is no longer visible. |
| @@ -5769,7 +5770,7 @@ void RenderViewImpl::OnWasShown(bool needs_repainting) { |
| } |
| // Inform PPAPI plugins that their page is visible. |
| - pepper_delegate_.PageVisibilityChanged(true); |
| + pepper_delegate_->PageVisibilityChanged(true); |
| #if defined(OS_MACOSX) |
| // Inform NPAPI plugins that their container is now visible. |
| @@ -5813,7 +5814,7 @@ void RenderViewImpl::OnSetFocus(bool enable) { |
| } |
| } |
| // Notify all Pepper plugins. |
| - pepper_delegate_.OnSetFocus(enable); |
| + pepper_delegate_->OnSetFocus(enable); |
| // Notify all BrowserPlugins of the RenderView's focus state. |
| if (browser_plugin_manager_) |
| browser_plugin_manager()->SetEmbedderFocus(this, enable); |
| @@ -5835,9 +5836,9 @@ void RenderViewImpl::PpapiPluginCaretPositionChanged() { |
| } |
| bool RenderViewImpl::GetPpapiPluginCaretBounds(gfx::Rect* rect) { |
| - if (!pepper_delegate_.IsPluginFocused()) |
| + if (!pepper_delegate_->IsPluginFocused()) |
| return false; |
| - *rect = pepper_delegate_.GetCaretBounds(); |
| + *rect = pepper_delegate_->GetCaretBounds(); |
| return true; |
| } |
| @@ -5876,9 +5877,9 @@ void RenderViewImpl::OnImeSetComposition( |
| const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| int selection_start, |
| int selection_end) { |
| - if (pepper_delegate_.IsPluginFocused()) { |
| + if (pepper_delegate_->IsPluginFocused()) { |
| // When a PPAPI plugin has focus, we bypass WebKit. |
| - pepper_delegate_.OnImeSetComposition(text, |
| + pepper_delegate_->OnImeSetComposition(text, |
| underlines, |
| selection_start, |
| selection_end); |
| @@ -5918,9 +5919,9 @@ void RenderViewImpl::OnImeSetComposition( |
| void RenderViewImpl::OnImeConfirmComposition( |
| const string16& text, const ui::Range& replacement_range) { |
| - if (pepper_delegate_.IsPluginFocused()) { |
| + if (pepper_delegate_->IsPluginFocused()) { |
| // When a PPAPI plugin has focus, we bypass WebKit. |
| - pepper_delegate_.OnImeConfirmComposition(text); |
| + pepper_delegate_->OnImeConfirmComposition(text); |
| } else { |
| #if defined(OS_WIN) |
| // Same as OnImeSetComposition(), we send the text from IMEs directly to |
| @@ -5957,17 +5958,17 @@ void RenderViewImpl::SetDeviceScaleFactor(float device_scale_factor) { |
| } |
| ui::TextInputType RenderViewImpl::GetTextInputType() { |
| - return pepper_delegate_.IsPluginFocused() ? |
| - pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); |
| + return pepper_delegate_->IsPluginFocused() ? |
| + pepper_delegate_->GetTextInputType() : RenderWidget::GetTextInputType(); |
| } |
| void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { |
| - if (pepper_delegate_.IsPluginFocused()) { |
| + if (pepper_delegate_->IsPluginFocused()) { |
| // TODO(kinaba) http://crbug.com/101101 |
| // Current Pepper IME API does not handle selection bounds. So we simply |
| // use the caret position as an empty range for now. It will be updated |
| // after Pepper API equips features related to surrounding text retrieval. |
| - gfx::Rect caret = pepper_delegate_.GetCaretBounds(); |
| + gfx::Rect caret = pepper_delegate_->GetCaretBounds(); |
| *start = caret; |
| *end = caret; |
| return; |
| @@ -6006,8 +6007,8 @@ void RenderViewImpl::GetCompositionCharacterBounds( |
| } |
| bool RenderViewImpl::CanComposeInline() { |
| - return pepper_delegate_.IsPluginFocused() ? |
| - pepper_delegate_.CanComposeInline() : true; |
| + return pepper_delegate_->IsPluginFocused() ? |
| + pepper_delegate_->CanComposeInline() : true; |
| } |
| #if defined(OS_WIN) |
| @@ -6262,13 +6263,13 @@ void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, |
| if (!intent.is_empty()) |
| Send(new ViewHostMsg_StartContentIntent(routing_id_, intent)); |
| } |
| -#endif |
| +#endif // defined(OS_ANDROID) |
| void RenderViewImpl::OnAsyncFileOpened( |
| base::PlatformFileError error_code, |
| IPC::PlatformFileForTransit file_for_transit, |
| int message_id) { |
| - pepper_delegate_.OnAsyncFileOpened( |
| + pepper_delegate_->OnAsyncFileOpened( |
| error_code, |
| IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
| message_id); |
| @@ -6277,14 +6278,14 @@ void RenderViewImpl::OnAsyncFileOpened( |
| void RenderViewImpl::OnPpapiBrokerChannelCreated( |
| int request_id, |
| const IPC::ChannelHandle& handle) { |
| - pepper_delegate_.OnPpapiBrokerChannelCreated(request_id, |
| + pepper_delegate_->OnPpapiBrokerChannelCreated(request_id, |
| handle); |
| } |
| void RenderViewImpl::OnPpapiBrokerPermissionResult( |
| int request_id, |
| bool result) { |
| - pepper_delegate_.OnPpapiBrokerPermissionResult(request_id, result); |
| + pepper_delegate_->OnPpapiBrokerPermissionResult(request_id, result); |
| } |
| #if defined(OS_MACOSX) |