OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_GUEST_TO_EMBEDDER_CHANNEL_H_ |
| 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_GUEST_TO_EMBEDDER_CHANNEL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 11 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" |
| 12 #include "content/renderer/render_view_impl.h" |
| 13 #include "ipc/ipc_channel_handle.h" |
| 14 #include "ppapi/c/pp_bool.h" |
| 15 #include "ppapi/c/pp_instance.h" |
| 16 #include "ppapi/shared_impl/ppb_view_shared.h" |
| 17 #include "ppapi/proxy/plugin_dispatcher.h" |
| 18 #include "ppapi/proxy/serialized_var.h" |
| 19 #include "ppapi/shared_impl/host_resource.h" |
| 20 #include "ppapi/shared_impl/ppapi_preferences.h" |
| 21 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 24 |
| 25 namespace content { |
| 26 |
| 27 class BrowserPluginChannelManager; |
| 28 |
| 29 class GuestToEmbedderChannel |
| 30 : public ppapi::proxy::Dispatcher, |
| 31 public base::RefCounted<GuestToEmbedderChannel> { |
| 32 public: |
| 33 GuestToEmbedderChannel(const std::string& embedder_channel_manager); |
| 34 |
| 35 virtual ~GuestToEmbedderChannel() { } |
| 36 |
| 37 // This must be called before anything else. Returns true on success. |
| 38 bool InitChannel(const IPC::ChannelHandle& channel_handle); |
| 39 |
| 40 // Creates a new WebGraphicsContext3DCommandBufferImpl and returns it. |
| 41 WebGraphicsContext3DCommandBufferImpl* CreateWebGraphicsContext3D( |
| 42 RenderViewImpl* render_view, |
| 43 const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| 44 bool offscreen); |
| 45 |
| 46 // Inform the host to invalidate its plugin container after a swap buffer. |
| 47 void IssueSwapBuffers(const ppapi::HostResource& resource); |
| 48 |
| 49 // Request the receipt of events from the host renderer. |
| 50 void RequestInputEvents(PP_Instance instance); |
| 51 |
| 52 // Request a graphics context from the host renderer. |
| 53 bool CreateGraphicsContext( |
| 54 WebGraphicsContext3DCommandBufferImpl* context, |
| 55 const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| 56 bool offscreen, |
| 57 RenderViewImpl* render_view); |
| 58 |
| 59 // Register the given RenderView with the given PP_Instance. |
| 60 void AddGuest(PP_Instance instance, RenderViewImpl* render_view); |
| 61 |
| 62 // Removes the guest with the given instance identifier from the |
| 63 // InstanceMap. If the map is empty, GuestToEmbedderChannel deletes itself. |
| 64 void RemoveGuest(PP_Instance instance); |
| 65 |
| 66 // ppapi::proxy::Dispatcher implementation. |
| 67 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 68 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 69 virtual void OnChannelError() OVERRIDE; |
| 70 virtual bool IsPlugin() const; |
| 71 |
| 72 private: |
| 73 typedef std::map<PP_Instance, base::WeakPtr<RenderViewImpl> > InstanceMap; |
| 74 typedef std::map<int, int> RoutingIDToInstanceMap; |
| 75 |
| 76 void OnSupportsInterface(const std::string& interface_name, bool* result); |
| 77 void OnSetPreferences(const ppapi::Preferences& prefs); |
| 78 void OnReserveInstanceId(PP_Instance instance, bool* usable); |
| 79 void OnDidCreate(PP_Instance instance, |
| 80 const std::vector<std::string>& argn, |
| 81 const std::vector<std::string>& argv, |
| 82 PP_Bool* result); |
| 83 void OnDidDestroy(PP_Instance instance); |
| 84 void OnDidChangeView(PP_Instance instance, |
| 85 const ppapi::ViewData& new_data, |
| 86 PP_Bool flash_fullscreen); |
| 87 void OnDidChangeFocus(PP_Instance instance, PP_Bool has_focus); |
| 88 void OnGetInstanceObject(PP_Instance instance, |
| 89 ppapi::proxy::SerializedVarReturnValue result); |
| 90 |
| 91 void OnHandleMessage(PP_Instance instance, |
| 92 ppapi::proxy::SerializedVarReceiveInput data); |
| 93 |
| 94 void OnHandleFilteredInputEvent(PP_Instance instance, |
| 95 const ppapi::InputEventData& data, |
| 96 PP_Bool* result); |
| 97 |
| 98 void OnSwapBuffersACK(const ppapi::HostResource& context, |
| 99 int32_t pp_error); |
| 100 |
| 101 void OnContextLost(PP_Instance instance); |
| 102 |
| 103 base::WeakPtr<RenderViewImpl> render_view_; |
| 104 BrowserPluginChannelManager* channel_manager_; |
| 105 std::string embedder_channel_name_; |
| 106 PepperProxyChannelDelegateImpl delegate_; |
| 107 |
| 108 InstanceMap render_view_instances_; |
| 109 RoutingIDToInstanceMap routing_id_instance_map_; |
| 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(GuestToEmbedderChannel); |
| 112 }; |
| 113 |
| 114 } // namespace content |
| 115 |
| 116 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_GUEST_TO_EMBEDDER_CHANNEL_H_ |
OLD | NEW |