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_
11 #include "base/memory/ref_counted.h"
12 #include "content/child/npapi/npobject_stub.h"
13 #include "ipc/ipc_listener.h"
14 #include "ipc/ipc_sender.h"
15 #include "third_party/npapi/bindings/npapi.h"
16 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/rect.h"
20 struct PluginMsg_Init_Params
;
21 struct PluginMsg_DidReceiveResponseParams
;
22 struct PluginMsg_UpdateGeometry_Param
;
31 class WebPluginDelegateImpl
;
34 // Converts the IPC messages from WebPluginDelegateProxy into calls to the
35 // actual WebPluginDelegateImpl object.
36 class WebPluginDelegateStub
: public IPC::Listener
,
38 public base::RefCounted
<WebPluginDelegateStub
> {
40 WebPluginDelegateStub(const std::string
& mime_type
, int instance_id
,
41 PluginChannel
* channel
);
43 // IPC::Listener implementation:
44 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
46 // IPC::Sender implementation:
47 virtual bool Send(IPC::Message
* msg
) OVERRIDE
;
49 int instance_id() { return instance_id_
; }
50 WebPluginProxy
* webplugin() { return webplugin_
; }
53 friend class base::RefCounted
<WebPluginDelegateStub
>;
55 virtual ~WebPluginDelegateStub();
57 // Message handlers for the WebPluginDelegate calls that are proxied from the
58 // renderer over the IPC channel.
59 void OnInit(const PluginMsg_Init_Params
& params
,
62 void OnWillSendRequest(int id
, const GURL
& url
, int http_status_code
);
63 void OnDidReceiveResponse(const PluginMsg_DidReceiveResponseParams
& params
);
64 void OnDidReceiveData(int id
, const std::vector
<char>& buffer
,
66 void OnDidFinishLoading(int id
);
67 void OnDidFail(int id
);
68 void OnDidFinishLoadWithReason(const GURL
& url
, int reason
, int notify_id
);
69 void OnSetFocus(bool focused
);
70 void OnHandleInputEvent(const WebKit::WebInputEvent
* event
,
71 bool* handled
, WebCursor
* cursor
);
72 void OnPaint(const gfx::Rect
& damaged_rect
);
74 void OnUpdateGeometry(const PluginMsg_UpdateGeometry_Param
& param
);
75 void OnGetPluginScriptableObject(int* route_id
);
76 void OnSendJavaScriptStream(const GURL
& url
,
77 const std::string
& result
,
80 void OnGetFormValue(string16
* value
, bool* success
);
82 void OnSetContentAreaFocus(bool has_focus
);
83 #if defined(OS_WIN) && !defined(USE_AURA)
84 void OnImeCompositionUpdated(const string16
& text
,
85 const std::vector
<int>& clauses
,
86 const std::vector
<int>& target
,
88 void OnImeCompositionCompleted(const string16
& text
);
90 #if defined(OS_MACOSX)
91 void OnSetWindowFocus(bool has_focus
);
92 void OnContainerHidden();
93 void OnContainerShown(gfx::Rect window_frame
, gfx::Rect view_frame
,
95 void OnWindowFrameChanged(const gfx::Rect
& window_frame
,
96 const gfx::Rect
& view_frame
);
97 void OnImeCompositionCompleted(const string16
& text
);
100 void OnDidReceiveManualResponse(
102 const PluginMsg_DidReceiveResponseParams
& params
);
103 void OnDidReceiveManualData(const std::vector
<char>& buffer
);
104 void OnDidFinishManualLoading();
105 void OnDidManualLoadFail();
106 void OnHandleURLRequestReply(unsigned long resource_id
,
109 void OnHTTPRangeRequestReply(unsigned long resource_id
, int range_request_id
);
111 std::string mime_type_
;
114 scoped_refptr
<PluginChannel
> channel_
;
116 base::WeakPtr
<NPObjectStub
> plugin_scriptable_object_
;
117 WebPluginDelegateImpl
* delegate_
;
118 WebPluginProxy
* webplugin_
;
121 // The url of the main frame hosting the plugin.
124 DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub
);
127 } // namespace content
129 #endif // CONTENT_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_