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/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
;
31 class WebPluginDelegateImpl
;
39 // Converts the IPC messages from WebPluginDelegateProxy into calls to the
40 // actual WebPluginDelegateImpl object.
41 class WebPluginDelegateStub
: public IPC::Listener
,
43 public base::RefCounted
<WebPluginDelegateStub
> {
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_
; }
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
,
67 void OnWillSendRequest(int id
, const GURL
& url
, int http_status_code
);
68 void OnDidReceiveResponse(const PluginMsg_DidReceiveResponseParams
& params
);
69 void OnDidReceiveData(int id
, const std::vector
<char>& buffer
,
71 void OnDidFinishLoading(int id
);
72 void OnDidFail(int id
);
73 void OnDidFinishLoadWithReason(const GURL
& url
, int reason
, int notify_id
);
74 void OnSetFocus(bool focused
);
75 void OnHandleInputEvent(const WebKit::WebInputEvent
* event
,
76 bool* handled
, WebCursor
* cursor
);
77 void OnPaint(const gfx::Rect
& damaged_rect
);
79 void OnUpdateGeometry(const PluginMsg_UpdateGeometry_Param
& param
);
80 void OnGetPluginScriptableObject(int* route_id
);
81 void OnSendJavaScriptStream(const GURL
& url
,
82 const std::string
& result
,
85 void OnGetFormValue(string16
* value
, bool* success
);
87 void OnSetContentAreaFocus(bool has_focus
);
88 #if defined(OS_WIN) && !defined(USE_AURA)
89 void OnImeCompositionUpdated(const string16
& text
,
90 const std::vector
<int>& clauses
,
91 const std::vector
<int>& target
,
93 void OnImeCompositionCompleted(const string16
& text
);
95 #if defined(OS_MACOSX)
96 void OnSetWindowFocus(bool has_focus
);
97 void OnContainerHidden();
98 void OnContainerShown(gfx::Rect window_frame
, gfx::Rect view_frame
,
100 void OnWindowFrameChanged(const gfx::Rect
& window_frame
,
101 const gfx::Rect
& view_frame
);
102 void OnImeCompositionCompleted(const string16
& text
);
105 void OnDidReceiveManualResponse(
107 const PluginMsg_DidReceiveResponseParams
& params
);
108 void OnDidReceiveManualData(const std::vector
<char>& buffer
);
109 void OnDidFinishManualLoading();
110 void OnDidManualLoadFail();
111 void OnHandleURLRequestReply(unsigned long resource_id
,
114 void OnHTTPRangeRequestReply(unsigned long resource_id
, int range_request_id
);
116 std::string mime_type_
;
119 scoped_refptr
<PluginChannel
> channel_
;
121 base::WeakPtr
<NPObjectStub
> plugin_scriptable_object_
;
122 webkit::npapi::WebPluginDelegateImpl
* delegate_
;
123 WebPluginProxy
* webplugin_
;
126 // The url of the main frame hosting the plugin.
129 DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub
);
132 } // namespace content
134 #endif // CONTENT_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_