OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_GLUE_WEBPLUGIN_H__ | 5 #ifndef WEBKIT_GLUE_WEBPLUGININFO_H_ |
6 #define WEBKIT_GLUE_WEBPLUGIN_H__ | 6 #define WEBKIT_GLUE_WEBPLUGININFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/gfx/rect.h" | |
14 #include "base/gfx/native_widget_types.h" | |
15 | |
16 // TODO(port): this typedef is obviously incorrect on non-Windows | |
17 // platforms, but now a lot of code now accidentally depends on them | |
18 // existing. #ifdef out these declarations and fix all the users. | |
19 typedef void* HANDLE; | |
20 | |
21 class GURL; | |
22 class WebFrame; | |
23 class WebPluginResourceClient; | |
24 | |
25 struct NPObject; | |
26 | 13 |
27 // Describes a mime type entry for a plugin. | 14 // Describes a mime type entry for a plugin. |
28 struct WebPluginMimeType { | 15 struct WebPluginMimeType { |
29 // The actual mime type. | 16 // The name of the mime type (e.g., "application/x-shockwave-flash"). |
30 std::string mime_type; | 17 std::string mime_type; |
31 | 18 |
32 // A list of all the file extensions for this mime type. | 19 // A list of all the file extensions for this mime type. |
33 std::vector<std::string> file_extensions; | 20 std::vector<std::string> file_extensions; |
34 | 21 |
35 // Description of the mime type. | 22 // Description of the mime type. |
36 std::wstring description; | 23 std::wstring description; |
37 }; | 24 }; |
38 | 25 |
39 | |
40 // Describes an available NPAPI plugin. | 26 // Describes an available NPAPI plugin. |
41 struct WebPluginInfo { | 27 struct WebPluginInfo { |
42 // The name of the plugin (i.e. Flash). | 28 // The name of the plugin (i.e. Flash). |
43 std::wstring name; | 29 std::wstring name; |
44 | 30 |
45 // The path to the plugin file (DLL/bundle/library). | 31 // The path to the plugin file (DLL/bundle/library). |
46 FilePath path; | 32 FilePath path; |
47 | 33 |
48 // The version number of the plugin file (may be OS-specific) | 34 // The version number of the plugin file (may be OS-specific) |
49 std::wstring version; | 35 std::wstring version; |
50 | 36 |
51 // A description of the plugin that we get from its version info. | 37 // A description of the plugin that we get from its version info. |
52 std::wstring desc; | 38 std::wstring desc; |
53 | 39 |
54 // A list of all the mime types that this plugin supports. | 40 // A list of all the mime types that this plugin supports. |
55 std::vector<WebPluginMimeType> mime_types; | 41 std::vector<WebPluginMimeType> mime_types; |
56 }; | 42 }; |
57 | 43 |
58 | 44 #endif // WEBKIT_GLUE_WEBPLUGININFO_H_ |
59 // Describes the new location for a plugin window. | |
60 struct WebPluginGeometry { | |
61 gfx::NativeView window; | |
62 gfx::Rect window_rect; | |
63 // Clip rect (include) and cutouts (excludes), relative to | |
64 // window_rect origin. | |
65 gfx::Rect clip_rect; | |
66 std::vector<gfx::Rect> cutout_rects; | |
67 bool visible; | |
68 }; | |
69 | |
70 | |
71 enum RoutingStatus { | |
72 ROUTED, | |
73 NOT_ROUTED, | |
74 INVALID_URL, | |
75 GENERAL_FAILURE | |
76 }; | |
77 | |
78 // The WebKit side of a plugin implementation. It provides wrappers around | |
79 // operations that need to interact with the frame and other WebCore objects. | |
80 class WebPlugin { | |
81 public: | |
82 WebPlugin() { } | |
83 virtual ~WebPlugin() { } | |
84 | |
85 // Called by the plugin delegate to let the WebPlugin know if the plugin is | |
86 // windowed (i.e. handle is not NULL) or windowless (handle is NULL). This | |
87 // tells the WebPlugin to send mouse/keyboard events to the plugin delegate, | |
88 // as well as the information about the HDC for paint operations. | |
89 virtual void SetWindow(gfx::NativeView window) = 0; | |
90 | |
91 // Called by the plugin delegate to let it know that the window is being | |
92 // destroyed. | |
93 virtual void WillDestroyWindow(gfx::NativeView window) = 0; | |
94 #if defined(OS_WIN) | |
95 // The pump_messages_event is a event handle which is valid only for | |
96 // windowless plugins and is used in NPP_HandleEvent calls to pump messages | |
97 // if the plugin enters a modal loop. | |
98 // Cancels a pending request. | |
99 virtual void SetWindowlessPumpEvent(HANDLE pump_messages_event) = 0; | |
100 #endif | |
101 virtual void CancelResource(int id) = 0; | |
102 virtual void Invalidate() = 0; | |
103 virtual void InvalidateRect(const gfx::Rect& rect) = 0; | |
104 | |
105 // Returns the NPObject for the browser's window object. | |
106 virtual NPObject* GetWindowScriptNPObject() = 0; | |
107 | |
108 // Returns the DOM element that loaded the plugin. | |
109 virtual NPObject* GetPluginElement() = 0; | |
110 | |
111 // Cookies | |
112 virtual void SetCookie(const GURL& url, | |
113 const GURL& policy_url, | |
114 const std::string& cookie) = 0; | |
115 virtual std::string GetCookies(const GURL& url, | |
116 const GURL& policy_url) = 0; | |
117 | |
118 // Shows a modal HTML dialog containing the given URL. json_arguments are | |
119 // passed to the dialog via the DOM 'window.chrome.dialogArguments', and the | |
120 // retval is the string returned by 'window.chrome.send("DialogClose", | |
121 // retval)'. | |
122 virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, | |
123 const std::string& json_arguments, | |
124 std::string* json_retval) = 0; | |
125 | |
126 // When a default plugin has downloaded the plugin list and finds it is | |
127 // available, it calls this method to notify the renderer. Also it will update | |
128 // the status when user clicks on the plugin to install. | |
129 virtual void OnMissingPluginStatus(int status) = 0; | |
130 | |
131 // Handles GetURL/GetURLNotify/PostURL/PostURLNotify requests initiated | |
132 // by plugins. | |
133 virtual void HandleURLRequest(const char *method, | |
134 bool is_javascript_url, | |
135 const char* target, unsigned int len, | |
136 const char* buf, bool is_file_data, | |
137 bool notify, const char* url, | |
138 intptr_t notify_data, bool popups_allowed) = 0; | |
139 | |
140 // Cancels document load. | |
141 virtual void CancelDocumentLoad() = 0; | |
142 | |
143 // Initiates a HTTP range request. | |
144 virtual void InitiateHTTPRangeRequest(const char* url, | |
145 const char* range_info, | |
146 intptr_t existing_stream, | |
147 bool notify_needed, | |
148 intptr_t notify_data) = 0; | |
149 | |
150 // Returns true iff in off the record (Incognito) mode. | |
151 virtual bool IsOffTheRecord() = 0; | |
152 | |
153 private: | |
154 DISALLOW_EVIL_CONSTRUCTORS(WebPlugin); | |
155 }; | |
156 | |
157 // Simpler version of ResourceHandleClient that lends itself to proxying. | |
158 class WebPluginResourceClient { | |
159 public: | |
160 virtual ~WebPluginResourceClient() {} | |
161 virtual void WillSendRequest(const GURL& url) = 0; | |
162 // The request_is_seekable parameter indicates whether byte range requests | |
163 // can be issued for the underlying stream. | |
164 virtual void DidReceiveResponse(const std::string& mime_type, | |
165 const std::string& headers, | |
166 uint32 expected_length, | |
167 uint32 last_modified, | |
168 bool request_is_seekable, | |
169 bool* cancel) = 0; | |
170 virtual void DidReceiveData(const char* buffer, int length, | |
171 int data_offset) = 0; | |
172 virtual void DidFinishLoading() = 0; | |
173 virtual void DidFail() = 0; | |
174 virtual bool IsMultiByteResponseExpected() = 0; | |
175 }; | |
176 | |
177 | |
178 #endif // #ifndef WEBKIT_GLUE_WEBPLUGIN_H__ | |
OLD | NEW |