OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_DELEGATE_H_ | |
6 #define WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_DELEGATE_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/strings/string16.h" | |
12 #include "build/build_config.h" | |
13 #include "third_party/WebKit/public/platform/WebCanvas.h" | |
14 #include "third_party/npapi/bindings/npapi.h" | |
15 #include "ui/gfx/native_widget_types.h" | |
16 #include "webkit/common/cursors/webcursor.h" | |
17 #include "webkit/plugins/webkit_plugins_export.h" | |
18 | |
19 class GURL; | |
20 struct NPObject; | |
21 | |
22 namespace WebKit { | |
23 class WebInputEvent; | |
24 } | |
25 | |
26 namespace gfx { | |
27 class Rect; | |
28 } | |
29 | |
30 namespace webkit { | |
31 namespace npapi { | |
32 | |
33 class WebPlugin; | |
34 class WebPluginResourceClient; | |
35 | |
36 // This is the interface that a plugin implementation needs to provide. | |
37 class WEBKIT_PLUGINS_EXPORT WebPluginDelegate { | |
38 public: | |
39 virtual ~WebPluginDelegate() {} | |
40 | |
41 // Initializes the plugin implementation with the given (UTF8) arguments. | |
42 // Note that the lifetime of WebPlugin must be longer than this delegate. | |
43 // If this function returns false the plugin isn't started and shouldn't be | |
44 // called again. If this method succeeds, then the WebPlugin is valid until | |
45 // PluginDestroyed is called. | |
46 // The load_manually parameter if true indicates that the plugin data would | |
47 // be passed from webkit. if false indicates that the plugin should download | |
48 // the data. This also controls whether the plugin is instantiated as a full | |
49 // page plugin (NP_FULL) or embedded (NP_EMBED). | |
50 virtual bool Initialize(const GURL& url, | |
51 const std::vector<std::string>& arg_names, | |
52 const std::vector<std::string>& arg_values, | |
53 WebPlugin* plugin, | |
54 bool load_manually) = 0; | |
55 | |
56 // Called when the WebPlugin is being destroyed. This is a signal to the | |
57 // delegate that it should tear-down the plugin implementation and not call | |
58 // methods on the WebPlugin again. | |
59 virtual void PluginDestroyed() = 0; | |
60 | |
61 // Update the geometry of the plugin. This is a request to move the | |
62 // plugin, relative to its containing window, to the coords given by | |
63 // window_rect. Its contents should be clipped to the coords given | |
64 // by clip_rect, which are relative to the origin of the plugin | |
65 // window. The clip_rect is in plugin-relative coordinates. | |
66 virtual void UpdateGeometry(const gfx::Rect& window_rect, | |
67 const gfx::Rect& clip_rect) = 0; | |
68 | |
69 // Tells the plugin to paint the damaged rect. |canvas| is only used for | |
70 // windowless plugins. | |
71 virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect) = 0; | |
72 | |
73 // Informs the plugin that it has gained or lost focus. This is only called in | |
74 // windowless mode. | |
75 virtual void SetFocus(bool focused) = 0; | |
76 | |
77 // For windowless plugins, gives them a user event like mouse/keyboard. | |
78 // Returns whether the event was handled. This is only called in windowsless | |
79 // mode. See NPAPI NPP_HandleEvent for more information. | |
80 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, | |
81 WebCursor::CursorInfo* cursor) = 0; | |
82 | |
83 // Gets the NPObject associated with the plugin for scripting. | |
84 virtual NPObject* GetPluginScriptableObject() = 0; | |
85 | |
86 // Gets the NPP instance uniquely identifying the plugin for its lifetime. | |
87 virtual struct _NPP* GetPluginNPP() = 0; | |
88 | |
89 // Gets the form value associated with the plugin instance. | |
90 // Returns false if the value is not available. | |
91 virtual bool GetFormValue(base::string16* value) = 0; | |
92 | |
93 // Receives notification about a resource load that the plugin initiated | |
94 // for a frame. | |
95 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, | |
96 int notify_id) = 0; | |
97 | |
98 // Returns the process id of the process that is running the plugin. | |
99 virtual int GetProcessId() = 0; | |
100 | |
101 // The result, UTF-8 encoded, of the script execution is returned via this | |
102 // function. | |
103 virtual void SendJavaScriptStream(const GURL& url, | |
104 const std::string& result, | |
105 bool success, | |
106 int notify_id) = 0; | |
107 | |
108 // Receives notification about data being available. | |
109 virtual void DidReceiveManualResponse(const GURL& url, | |
110 const std::string& mime_type, | |
111 const std::string& headers, | |
112 uint32 expected_length, | |
113 uint32 last_modified) = 0; | |
114 | |
115 // Receives the data. | |
116 virtual void DidReceiveManualData(const char* buffer, int length) = 0; | |
117 | |
118 // Indicates end of data load. | |
119 virtual void DidFinishManualLoading() = 0; | |
120 | |
121 // Indicates a failure in data receipt. | |
122 virtual void DidManualLoadFail() = 0; | |
123 | |
124 // Creates a WebPluginResourceClient instance and returns the same. | |
125 virtual WebPluginResourceClient* CreateResourceClient( | |
126 unsigned long resource_id, | |
127 const GURL& url, | |
128 int notify_id) = 0; | |
129 | |
130 // Creates a WebPluginResourceClient instance for an existing stream that is | |
131 // has become seekable. | |
132 virtual WebPluginResourceClient* CreateSeekableResourceClient( | |
133 unsigned long resource_id, int range_request_id) = 0; | |
134 }; | |
135 | |
136 } // namespace npapi | |
137 } // namespace webkit | |
138 | |
139 #endif // WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_DELEGATE_H_ | |
OLD | NEW |