| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 CHROME_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_ | |
| 6 #define CHROME_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/ref_counted.h" | |
| 13 #include "base/shared_memory.h" | |
| 14 #include "base/task.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 #include "ipc/ipc_channel.h" | |
| 17 #include "third_party/npapi/bindings/npapi.h" | |
| 18 #include "ui/gfx/native_widget_types.h" | |
| 19 #include "ui/gfx/rect.h" | |
| 20 | |
| 21 class PluginChannel; | |
| 22 class WebPluginProxy; | |
| 23 struct PluginMsg_Init_Params; | |
| 24 struct PluginMsg_DidReceiveResponseParams; | |
| 25 struct PluginMsg_UpdateGeometry_Param; | |
| 26 class WebCursor; | |
| 27 | |
| 28 namespace WebKit { | |
| 29 class WebInputEvent; | |
| 30 } | |
| 31 | |
| 32 namespace webkit { | |
| 33 namespace npapi { | |
| 34 class WebPluginDelegateImpl; | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 // Converts the IPC messages from WebPluginDelegateProxy into calls to the | |
| 39 // actual WebPluginDelegateImpl object. | |
| 40 class WebPluginDelegateStub : public IPC::Channel::Listener, | |
| 41 public IPC::Message::Sender, | |
| 42 public base::RefCounted<WebPluginDelegateStub> { | |
| 43 public: | |
| 44 WebPluginDelegateStub(const std::string& mime_type, int instance_id, | |
| 45 PluginChannel* channel); | |
| 46 | |
| 47 // IPC::Channel::Listener implementation: | |
| 48 virtual bool OnMessageReceived(const IPC::Message& msg); | |
| 49 | |
| 50 // IPC::Message::Sender implementation: | |
| 51 virtual bool Send(IPC::Message* msg); | |
| 52 | |
| 53 int instance_id() { return instance_id_; } | |
| 54 WebPluginProxy* webplugin() { return webplugin_; } | |
| 55 | |
| 56 private: | |
| 57 friend class base::RefCounted<WebPluginDelegateStub>; | |
| 58 | |
| 59 ~WebPluginDelegateStub(); | |
| 60 | |
| 61 // Message handlers for the WebPluginDelegate calls that are proxied from the | |
| 62 // renderer over the IPC channel. | |
| 63 void OnInit(const PluginMsg_Init_Params& params, bool* result); | |
| 64 void OnWillSendRequest(int id, const GURL& url, int http_status_code); | |
| 65 void OnDidReceiveResponse(const PluginMsg_DidReceiveResponseParams& params); | |
| 66 void OnDidReceiveData(int id, const std::vector<char>& buffer, | |
| 67 int data_offset); | |
| 68 void OnDidFinishLoading(int id); | |
| 69 void OnDidFail(int id); | |
| 70 void OnDidFinishLoadWithReason(const GURL& url, int reason, int notify_id); | |
| 71 void OnSetFocus(bool focused); | |
| 72 void OnHandleInputEvent(const WebKit::WebInputEvent* event, | |
| 73 bool* handled, WebCursor* cursor); | |
| 74 void OnPaint(const gfx::Rect& damaged_rect); | |
| 75 void OnDidPaint(); | |
| 76 void OnPrint(base::SharedMemoryHandle* shared_memory, uint32* size); | |
| 77 void OnUpdateGeometry(const PluginMsg_UpdateGeometry_Param& param); | |
| 78 void OnGetPluginScriptableObject(int* route_id); | |
| 79 void OnSendJavaScriptStream(const GURL& url, | |
| 80 const std::string& result, | |
| 81 bool success, | |
| 82 int notify_id); | |
| 83 | |
| 84 void OnSetContentAreaFocus(bool has_focus); | |
| 85 #if defined(OS_MACOSX) | |
| 86 void OnSetWindowFocus(bool has_focus); | |
| 87 void OnContainerHidden(); | |
| 88 void OnContainerShown(gfx::Rect window_frame, gfx::Rect view_frame, | |
| 89 bool has_focus); | |
| 90 void OnWindowFrameChanged(const gfx::Rect& window_frame, | |
| 91 const gfx::Rect& view_frame); | |
| 92 void OnImeCompositionCompleted(const string16& text); | |
| 93 #endif | |
| 94 | |
| 95 void OnDidReceiveManualResponse( | |
| 96 const GURL& url, | |
| 97 const PluginMsg_DidReceiveResponseParams& params); | |
| 98 void OnDidReceiveManualData(const std::vector<char>& buffer); | |
| 99 void OnDidFinishManualLoading(); | |
| 100 void OnDidManualLoadFail(); | |
| 101 void OnInstallMissingPlugin(); | |
| 102 void OnHandleURLRequestReply(unsigned long resource_id, | |
| 103 const GURL& url, | |
| 104 int notify_id); | |
| 105 void OnHTTPRangeRequestReply(unsigned long resource_id, int range_request_id); | |
| 106 | |
| 107 void CreateSharedBuffer(uint32 size, | |
| 108 base::SharedMemory* shared_buf, | |
| 109 base::SharedMemoryHandle* remote_handle); | |
| 110 | |
| 111 std::string mime_type_; | |
| 112 int instance_id_; | |
| 113 | |
| 114 scoped_refptr<PluginChannel> channel_; | |
| 115 | |
| 116 webkit::npapi::WebPluginDelegateImpl* delegate_; | |
| 117 WebPluginProxy* webplugin_; | |
| 118 bool in_destructor_; | |
| 119 | |
| 120 // The url of the main frame hosting the plugin. | |
| 121 GURL page_url_; | |
| 122 | |
| 123 #if defined(ENABLE_GPU) | |
| 124 #if defined(OS_MACOSX) | |
| 125 // If this is a GPU-accelerated plug-in, we need to be able to receive a fake | |
| 126 // window handle which is used for subsequent communication back to the | |
| 127 // browser. | |
| 128 void OnSetFakeAcceleratedSurfaceWindowHandle(gfx::PluginWindowHandle window); | |
| 129 #endif | |
| 130 #endif | |
| 131 | |
| 132 DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub); | |
| 133 }; | |
| 134 | |
| 135 #endif // CHROME_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_ | |
| OLD | NEW |