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/geometry/rect.h"
17 #include "ui/gfx/native_widget_types.h"
20 struct PluginMsg_Init_Params
;
21 struct PluginMsg_DidReceiveResponseParams
;
22 struct PluginMsg_FetchURL_Params
;
23 struct PluginMsg_UpdateGeometry_Param
;
32 class WebPluginDelegateImpl
;
35 // Converts the IPC messages from WebPluginDelegateProxy into calls to the
36 // actual WebPluginDelegateImpl object.
37 class WebPluginDelegateStub
: public IPC::Listener
,
39 public base::RefCounted
<WebPluginDelegateStub
> {
41 WebPluginDelegateStub(const std::string
& mime_type
, int instance_id
,
42 PluginChannel
* channel
);
44 // IPC::Listener implementation:
45 bool OnMessageReceived(const IPC::Message
& msg
) override
;
47 // IPC::Sender implementation:
48 bool Send(IPC::Message
* msg
) override
;
50 int instance_id() { return instance_id_
; }
51 WebPluginDelegateImpl
* delegate() { return delegate_
; }
52 WebPluginProxy
* webplugin() { return webplugin_
; }
55 friend class base::RefCounted
<WebPluginDelegateStub
>;
57 ~WebPluginDelegateStub() override
;
59 // Message handlers for the WebPluginDelegate calls that are proxied from the
60 // renderer over the IPC channel.
61 void OnInit(const PluginMsg_Init_Params
& params
,
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
,
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 blink::WebInputEvent
* event
,
73 bool* handled
, WebCursor
* cursor
);
74 void OnPaint(const gfx::Rect
& damaged_rect
);
76 void OnUpdateGeometry(const PluginMsg_UpdateGeometry_Param
& param
);
77 void OnGetPluginScriptableObject(int* route_id
);
78 void OnSendJavaScriptStream(const GURL
& url
,
79 const std::string
& result
,
82 void OnGetFormValue(base::string16
* value
, bool* success
);
84 void OnSetContentAreaFocus(bool has_focus
);
85 #if defined(OS_WIN) && !defined(USE_AURA)
86 void OnImeCompositionUpdated(const base::string16
& text
,
87 const std::vector
<int>& clauses
,
88 const std::vector
<int>& target
,
90 void OnImeCompositionCompleted(const base::string16
& text
);
92 #if defined(OS_MACOSX)
93 void OnSetWindowFocus(bool has_focus
);
94 void OnContainerHidden();
95 void OnContainerShown(gfx::Rect window_frame
, gfx::Rect view_frame
,
97 void OnWindowFrameChanged(const gfx::Rect
& window_frame
,
98 const gfx::Rect
& view_frame
);
99 void OnImeCompositionCompleted(const base::string16
& text
);
102 void OnDidReceiveManualResponse(
104 const PluginMsg_DidReceiveResponseParams
& params
);
105 void OnDidReceiveManualData(const std::vector
<char>& buffer
);
106 void OnDidFinishManualLoading();
107 void OnDidManualLoadFail();
108 void OnHandleURLRequestReply(unsigned long resource_id
,
111 void OnHTTPRangeRequestReply(unsigned long resource_id
, int range_request_id
);
112 void OnFetchURL(const PluginMsg_FetchURL_Params
& params
);
114 std::string mime_type_
;
117 scoped_refptr
<PluginChannel
> channel_
;
119 base::WeakPtr
<NPObjectStub
> plugin_scriptable_object_
;
120 WebPluginDelegateImpl
* delegate_
;
121 WebPluginProxy
* webplugin_
;
124 // The url of the main frame hosting the plugin.
127 DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub
);
130 } // namespace content
132 #endif // CONTENT_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_