[content shell] hook up testRunner.dumpEditingCallbacks
[chromium-blink-merge.git] / content / plugin / webplugin_delegate_stub.h
blob5764c38efcbdf5e6dcb8835782430e9798fc0bfe
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.
5 #ifndef CONTENT_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_
6 #define CONTENT_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/ref_counted.h"
12 #include "content/common/npobject_stub.h"
13 #include "googleurl/src/gurl.h"
14 #include "ipc/ipc_listener.h"
15 #include "ipc/ipc_sender.h"
16 #include "third_party/npapi/bindings/npapi.h"
17 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gfx/rect.h"
20 struct PluginMsg_Init_Params;
21 struct PluginMsg_DidReceiveResponseParams;
22 struct PluginMsg_UpdateGeometry_Param;
23 class WebCursor;
25 namespace WebKit {
26 class WebInputEvent;
29 namespace webkit {
30 namespace npapi {
31 class WebPluginDelegateImpl;
35 namespace content {
36 class PluginChannel;
37 class WebPluginProxy;
39 // Converts the IPC messages from WebPluginDelegateProxy into calls to the
40 // actual WebPluginDelegateImpl object.
41 class WebPluginDelegateStub : public IPC::Listener,
42 public IPC::Sender,
43 public base::RefCounted<WebPluginDelegateStub> {
44 public:
45 WebPluginDelegateStub(const std::string& mime_type, int instance_id,
46 PluginChannel* channel);
48 // IPC::Listener implementation:
49 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
51 // IPC::Sender implementation:
52 virtual bool Send(IPC::Message* msg) OVERRIDE;
54 int instance_id() { return instance_id_; }
55 WebPluginProxy* webplugin() { return webplugin_; }
57 private:
58 friend class base::RefCounted<WebPluginDelegateStub>;
60 virtual ~WebPluginDelegateStub();
62 // Message handlers for the WebPluginDelegate calls that are proxied from the
63 // renderer over the IPC channel.
64 void OnInit(const PluginMsg_Init_Params& params, bool* result);
65 void OnWillSendRequest(int id, const GURL& url, int http_status_code);
66 void OnDidReceiveResponse(const PluginMsg_DidReceiveResponseParams& params);
67 void OnDidReceiveData(int id, const std::vector<char>& buffer,
68 int data_offset);
69 void OnDidFinishLoading(int id);
70 void OnDidFail(int id);
71 void OnDidFinishLoadWithReason(const GURL& url, int reason, int notify_id);
72 void OnSetFocus(bool focused);
73 void OnHandleInputEvent(const WebKit::WebInputEvent* event,
74 bool* handled, WebCursor* cursor);
75 void OnPaint(const gfx::Rect& damaged_rect);
76 void OnDidPaint();
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 void OnGetFormValue(string16* value, bool* success);
85 void OnSetContentAreaFocus(bool has_focus);
86 #if defined(OS_WIN) && !defined(USE_AURA)
87 void OnImeCompositionUpdated(const string16& text,
88 const std::vector<int>& clauses,
89 const std::vector<int>& target,
90 int cursor_position);
91 void OnImeCompositionCompleted(const string16& text);
92 #endif
93 #if defined(OS_MACOSX)
94 void OnSetWindowFocus(bool has_focus);
95 void OnContainerHidden();
96 void OnContainerShown(gfx::Rect window_frame, gfx::Rect view_frame,
97 bool has_focus);
98 void OnWindowFrameChanged(const gfx::Rect& window_frame,
99 const gfx::Rect& view_frame);
100 void OnImeCompositionCompleted(const string16& text);
101 #endif
103 void OnDidReceiveManualResponse(
104 const GURL& url,
105 const PluginMsg_DidReceiveResponseParams& params);
106 void OnDidReceiveManualData(const std::vector<char>& buffer);
107 void OnDidFinishManualLoading();
108 void OnDidManualLoadFail();
109 void OnHandleURLRequestReply(unsigned long resource_id,
110 const GURL& url,
111 int notify_id);
112 void OnHTTPRangeRequestReply(unsigned long resource_id, int range_request_id);
114 std::string mime_type_;
115 int instance_id_;
117 scoped_refptr<PluginChannel> channel_;
119 base::WeakPtr<NPObjectStub> plugin_scriptable_object_;
120 webkit::npapi::WebPluginDelegateImpl* delegate_;
121 WebPluginProxy* webplugin_;
122 bool in_destructor_;
124 // The url of the main frame hosting the plugin.
125 GURL page_url_;
127 #if defined(ENABLE_GPU)
128 #if defined(OS_MACOSX)
129 // If this is a GPU-accelerated plug-in, we need to be able to receive a fake
130 // window handle which is used for subsequent communication back to the
131 // browser.
132 void OnSetFakeAcceleratedSurfaceWindowHandle(gfx::PluginWindowHandle window);
133 #endif
134 #endif
136 DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub);
139 } // namespace content
141 #endif // CONTENT_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_