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