Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: chrome/renderer/webplugin_delegate_pepper.h

Issue 6646025: Deleted WebPluginDelegatePepper. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | chrome/renderer/webplugin_delegate_pepper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_
6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_
7 #pragma once
8
9 #include "build/build_config.h"
10
11 #include <string>
12 #include <vector>
13
14 #include "base/id_map.h"
15 #include "base/ref_counted.h"
16 #include "base/weak_ptr.h"
17 #include "base/task.h"
18 #include "chrome/renderer/pepper_devices.h"
19 #include "third_party/npapi/bindings/npapi.h"
20 #include "third_party/skia/include/core/SkBitmap.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet ion.h"
22 #include "ui/gfx/native_widget_types.h"
23 #include "ui/gfx/rect.h"
24 #include "webkit/plugins/npapi/webplugin_delegate.h"
25
26 class FilePath;
27 class RenderView;
28 class WebCursor;
29 class WebPluginDelegateProxy;
30
31 namespace webkit {
32 namespace npapi {
33 class PluginInstance;
34 }
35 }
36
37 // An implementation of WebPluginDelegate for Pepper in-process plugins.
38 class WebPluginDelegatePepper : public webkit::npapi::WebPluginDelegate,
39 public WebKit::WebFileChooserCompletion {
40 public:
41 static WebPluginDelegatePepper* Create(
42 const FilePath& filename,
43 const std::string& mime_type,
44 const base::WeakPtr<RenderView>& render_view);
45
46 webkit::npapi::PluginInstance* instance() { return instance_.get(); }
47
48 // WebKit::WebFileChooserCompletion implementation.
49 virtual void didChooseFile(
50 const WebKit::WebVector<WebKit::WebString>& file_names);
51
52 // WebPluginDelegate implementation
53 virtual bool Initialize(const GURL& url,
54 const std::vector<std::string>& arg_names,
55 const std::vector<std::string>& arg_values,
56 webkit::npapi::WebPlugin* plugin,
57 bool load_manually);
58 virtual void PluginDestroyed();
59 virtual void UpdateGeometry(const gfx::Rect& window_rect,
60 const gfx::Rect& clip_rect);
61 virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect);
62 virtual void Print(gfx::NativeDrawingContext context);
63 virtual void SetFocus(bool focused);
64 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event,
65 WebKit::WebCursorInfo* cursor);
66 virtual NPObject* GetPluginScriptableObject();
67 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason,
68 int notify_id);
69 virtual int GetProcessId();
70 virtual void SendJavaScriptStream(const GURL& url,
71 const std::string& result,
72 bool success,
73 int notify_id);
74 virtual void DidReceiveManualResponse(const GURL& url,
75 const std::string& mime_type,
76 const std::string& headers,
77 uint32 expected_length,
78 uint32 last_modified);
79 virtual void DidReceiveManualData(const char* buffer, int length);
80 virtual void DidFinishManualLoading();
81 virtual void DidManualLoadFail();
82 virtual void InstallMissingPlugin();
83 virtual webkit::npapi::WebPluginResourceClient* CreateResourceClient(
84 unsigned long resource_id, const GURL& url, int notify_id);
85 virtual webkit::npapi::WebPluginResourceClient* CreateSeekableResourceClient(
86 unsigned long resource_id, int range_request_id);
87 virtual bool StartFind(const string16& search_text,
88 bool case_sensitive,
89 int identifier);
90 virtual void SelectFindResult(bool forward);
91 virtual void StopFind();
92 virtual void NumberOfFindResultsChanged(int total, bool final_result);
93 virtual void SelectedFindResultChanged(int index);
94 virtual bool ChooseFile(const char* mime_types,
95 int mode,
96 NPChooseFileCallback callback,
97 void* user_data);
98 virtual NPWidgetExtensions* GetWidgetExtensions();
99 virtual bool SetCursor(NPCursorType type);
100 virtual NPFontExtensions* GetFontExtensions();
101 virtual void SetZoomFactor(float scale, bool text_only);
102 virtual bool HasSelection() const;
103 virtual string16 GetSelectionAsText() const;
104 virtual string16 GetSelectionAsMarkup() const;
105
106 // WebPlugin2DDeviceDelegate implementation.
107 virtual NPError Device2DQueryCapability(int32 capability, int32* value);
108 virtual NPError Device2DQueryConfig(const NPDeviceContext2DConfig* request,
109 NPDeviceContext2DConfig* obtain);
110 virtual NPError Device2DInitializeContext(
111 const NPDeviceContext2DConfig* config,
112 NPDeviceContext2D* context);
113 virtual NPError Device2DSetStateContext(NPDeviceContext2D* context,
114 int32 state,
115 intptr_t value);
116 virtual NPError Device2DGetStateContext(NPDeviceContext2D* context,
117 int32 state,
118 intptr_t* value);
119 virtual NPError Device2DFlushContext(NPP id,
120 NPDeviceContext2D* context,
121 NPDeviceFlushContextCallbackPtr callback,
122 void* user_data);
123 virtual NPError Device2DDestroyContext(NPDeviceContext2D* context);
124
125 // WebPlugin3DDeviceDelegate implementation.
126 virtual NPError Device3DQueryCapability(int32 capability, int32* value);
127 virtual NPError Device3DQueryConfig(const NPDeviceContext3DConfig* request,
128 NPDeviceContext3DConfig* obtain);
129 virtual NPError Device3DInitializeContext(
130 const NPDeviceContext3DConfig* config,
131 NPDeviceContext3D* context);
132 virtual NPError Device3DSetStateContext(NPDeviceContext3D* context,
133 int32 state,
134 intptr_t value);
135 virtual NPError Device3DGetStateContext(NPDeviceContext3D* context,
136 int32 state,
137 intptr_t* value);
138 virtual NPError Device3DFlushContext(NPP id,
139 NPDeviceContext3D* context,
140 NPDeviceFlushContextCallbackPtr callback,
141 void* user_data);
142 virtual NPError Device3DDestroyContext(NPDeviceContext3D* context);
143 virtual NPError Device3DCreateBuffer(NPDeviceContext3D* context,
144 size_t size,
145 int32* id);
146 virtual NPError Device3DDestroyBuffer(NPDeviceContext3D* context,
147 int32 id);
148 virtual NPError Device3DMapBuffer(NPDeviceContext3D* context,
149 int32 id,
150 NPDeviceBuffer* buffer);
151 virtual NPError Device3DGetNumConfigs(int32* num_configs);
152 virtual NPError Device3DGetConfigAttribs(int32 config,
153 int32* attrib_list);
154 virtual NPError Device3DCreateContext(int32 config,
155 const int32* attrib_list,
156 NPDeviceContext3D** context);
157 virtual NPError Device3DRegisterCallback(
158 NPP id,
159 NPDeviceContext3D* context,
160 int32 callback_type,
161 NPDeviceGenericCallbackPtr callback,
162 void* callback_data);
163 virtual NPError Device3DSynchronizeContext(
164 NPP id,
165 NPDeviceContext3D* context,
166 NPDeviceSynchronizationMode mode,
167 const int32* input_attrib_list,
168 int32* output_attrib_list,
169 NPDeviceSynchronizeContextCallbackPtr callback,
170 void* callback_data);
171
172 // WebPluginAudioDeviceDelegate implementation.
173 virtual NPError DeviceAudioQueryCapability(int32 capability, int32* value);
174 virtual NPError DeviceAudioQueryConfig(
175 const NPDeviceContextAudioConfig* request,
176 NPDeviceContextAudioConfig* obtain);
177 virtual NPError DeviceAudioInitializeContext(
178 const NPDeviceContextAudioConfig* config,
179 NPDeviceContextAudio* context);
180 virtual NPError DeviceAudioSetStateContext(NPDeviceContextAudio* context,
181 int32 state, intptr_t value);
182 virtual NPError DeviceAudioGetStateContext(NPDeviceContextAudio* context,
183 int32 state, intptr_t* value);
184 virtual NPError DeviceAudioFlushContext(
185 NPP id, NPDeviceContextAudio* context,
186 NPDeviceFlushContextCallbackPtr callback, void* user_data);
187 virtual NPError DeviceAudioDestroyContext(NPDeviceContextAudio* context);
188
189 // WebPluginPrintDelegate implementation.
190 virtual bool PrintSupportsPrintExtension();
191 virtual int PrintBegin(const gfx::Rect& printable_area, int printer_dpi);
192 virtual bool PrintPage(int page_number, WebKit::WebCanvas* canvas);
193 virtual void PrintEnd();
194
195 gfx::Rect GetRect() const { return window_rect_; }
196 gfx::Rect GetClipRect() const { return clip_rect_; }
197
198 // Returns the path for the library implementing this plugin.
199 FilePath GetPluginPath();
200
201 // Notifications when the RenderView painted the screen (InitiatedPaint) and
202 // when an ack was received that the browser copied it to the screen
203 // (FlushedPaint).
204 void RenderViewInitiatedPaint();
205 void RenderViewFlushedPaint();
206
207 Graphics2DDeviceContext* GetGraphicsContext(NPDeviceContext2D* context);
208
209 private:
210 WebPluginDelegatePepper(
211 const base::WeakPtr<RenderView>& render_view,
212 webkit::npapi::PluginInstance *instance);
213 ~WebPluginDelegatePepper();
214
215 //-----------------------------------------
216 // used for windowed and windowless plugins
217
218 // Closes down and destroys our plugin instance.
219 void DestroyInstance();
220
221 void ForwardSetWindow();
222
223 // A helper method that invokes the plugin's Print extensions to calculate
224 // the size needed in pixels to render the given page in a raster format.
225 bool CalculatePrintedPageDimensions(int page_number,
226 NPPPrintExtensions* print_extensions,
227 gfx::Size* page_dimensions);
228 bool VectorPrintPage(int page_number, WebKit::WebCanvas* canvas);
229
230 NPPPrintExtensions* GetPrintExtensions();
231
232 NPPFindExtensions* GetFindExtensions();
233
234 #if defined(OS_WIN)
235 // Compresses the given bitmap as JPEG and draws it into the backing platform
236 // DC (Windows-only).
237 bool DrawJPEGToPlatformDC(const SkBitmap& bitmap,
238 const gfx::Rect& printable_area,
239 WebKit::WebCanvas* canvas);
240 #endif // OS_WIN
241 #if defined(OS_MACOSX)
242 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting
243 // at the specified destination rect.
244 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas,
245 const gfx::Rect& dest_rect, int canvas_height);
246 #endif // OS_MACOSX
247
248 // Returns the selection. If nothing is selected, returns an empty string.
249 // If html is true, it will return a string only if html data is available.
250 string16 GetSelectedText(bool html) const;
251
252 base::WeakPtr<RenderView> render_view_;
253
254 webkit::npapi::WebPlugin* plugin_;
255 scoped_refptr<webkit::npapi::PluginInstance> instance_;
256
257 NPWindow window_;
258 gfx::Rect window_rect_;
259 gfx::Rect clip_rect_;
260 std::vector<gfx::Rect> cutout_rects_;
261
262 // Open device contexts
263 typedef IDMap<Graphics2DDeviceContext, IDMapOwnPointer> Graphics2DMap;
264 Graphics2DMap graphic2d_contexts_;
265 IDMap<AudioDeviceContext, IDMapOwnPointer> audio_contexts_;
266
267 // Plugin graphics context implementation
268 SkBitmap committed_bitmap_;
269
270 // The url with which the plugin was instantiated.
271 std::string plugin_url_;
272
273 // The last printable_area passed in to PrintBegin. We remember this because
274 // we need to stretch the printed raster bitmap to these dimensions. It is
275 // cleared in PrintEnd.
276 gfx::Rect current_printable_area_;
277 int current_printer_dpi_;
278 #if defined(OS_MACOSX)
279 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary
280 // to keep the pixels valid until CGContextEndPage is called. We use this
281 // variable to hold on to the pixels.
282 SkBitmap last_printed_page_;
283 #endif // defined(OS_MACOSX)
284 #if defined (OS_LINUX)
285 // On Linux, we always send all pages from the renderer to the browser.
286 // So, if the plugin supports printPagesAsPDF we print the entire output
287 // in one shot in the first call to PrintPage.
288 // (This is a temporary hack until we change the WebFrame and WebPlugin print
289 // interfaces).
290 // Specifies the total number of pages to be printed. It it set in PrintBegin.
291 int32 num_pages_;
292 // Specifies whether we have already output all pages. This is used to ignore
293 // subsequent PrintPage requests.
294 bool pdf_output_done_;
295 #endif // defined(OS_LINUX)
296
297 // The id of the current find operation, or -1 if none is in process.
298 int find_identifier_;
299
300 // When a choose file operation is outstanding, this will contain a
301 // pointer to the callback specified by the plugin. Will be NULL otherwise.
302 NPChooseFileCallback current_choose_file_callback_;
303 void* current_choose_file_user_data_;
304
305 scoped_ptr<WebKit::WebCursorInfo> cursor_;
306
307 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepper);
308 };
309
310 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | chrome/renderer/webplugin_delegate_pepper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698