OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ | 5 #ifndef CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ |
6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ | 6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/id_map.h" | 14 #include "base/id_map.h" |
15 #include "base/ref_counted.h" | 15 #include "base/ref_counted.h" |
16 #include "base/weak_ptr.h" | 16 #include "base/weak_ptr.h" |
17 #include "base/task.h" | 17 #include "base/task.h" |
18 #include "chrome/renderer/pepper_devices.h" | 18 #include "chrome/renderer/pepper_devices.h" |
19 #include "chrome/renderer/command_buffer_proxy.h" | |
20 #include "third_party/npapi/bindings/npapi.h" | 19 #include "third_party/npapi/bindings/npapi.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" |
23 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
24 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
25 #include "webkit/plugins/npapi/webplugin_delegate.h" | 24 #include "webkit/plugins/npapi/webplugin_delegate.h" |
26 | 25 |
27 class FilePath; | 26 class FilePath; |
28 class RenderView; | 27 class RenderView; |
29 class WebCursor; | 28 class WebCursor; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 void RenderViewFlushedPaint(); | 205 void RenderViewFlushedPaint(); |
207 | 206 |
208 Graphics2DDeviceContext* GetGraphicsContext(NPDeviceContext2D* context); | 207 Graphics2DDeviceContext* GetGraphicsContext(NPDeviceContext2D* context); |
209 | 208 |
210 private: | 209 private: |
211 WebPluginDelegatePepper( | 210 WebPluginDelegatePepper( |
212 const base::WeakPtr<RenderView>& render_view, | 211 const base::WeakPtr<RenderView>& render_view, |
213 webkit::npapi::PluginInstance *instance); | 212 webkit::npapi::PluginInstance *instance); |
214 ~WebPluginDelegatePepper(); | 213 ~WebPluginDelegatePepper(); |
215 | 214 |
216 // Set a task that calls the repaint callback the next time the window | |
217 // is invalid and needs to be repainted. | |
218 void ScheduleHandleRepaint(NPP npp, NPDeviceContext3D* context); | |
219 | |
220 //----------------------------------------- | 215 //----------------------------------------- |
221 // used for windowed and windowless plugins | 216 // used for windowed and windowless plugins |
222 | 217 |
223 // Closes down and destroys our plugin instance. | 218 // Closes down and destroys our plugin instance. |
224 void DestroyInstance(); | 219 void DestroyInstance(); |
225 | 220 |
226 void ForwardSetWindow(); | 221 void ForwardSetWindow(); |
227 | 222 |
228 // A helper method that invokes the plugin's Print extensions to calculate | 223 // A helper method that invokes the plugin's Print extensions to calculate |
229 // the size needed in pixels to render the given page in a raster format. | 224 // the size needed in pixels to render the given page in a raster format. |
(...skipping 13 matching lines...) Expand all Loading... |
243 const gfx::Rect& printable_area, | 238 const gfx::Rect& printable_area, |
244 WebKit::WebCanvas* canvas); | 239 WebKit::WebCanvas* canvas); |
245 #endif // OS_WIN | 240 #endif // OS_WIN |
246 #if defined(OS_MACOSX) | 241 #if defined(OS_MACOSX) |
247 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting | 242 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting |
248 // at the specified destination rect. | 243 // at the specified destination rect. |
249 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas, | 244 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas, |
250 const gfx::Rect& dest_rect, int canvas_height); | 245 const gfx::Rect& dest_rect, int canvas_height); |
251 #endif // OS_MACOSX | 246 #endif // OS_MACOSX |
252 | 247 |
253 #if defined(ENABLE_GPU) | |
254 | |
255 void ForwardHandleRepaint(NPP npp, NPDeviceContext3D* context); | |
256 | |
257 // Synchronize a 3D context state with the service. | |
258 void Synchronize3DContext(NPDeviceContext3D* context, | |
259 const gpu::CommandBuffer::State& state); | |
260 | |
261 // Synchronize the 3D context state with the proxy and invoke the async | |
262 // flush callback. | |
263 void Device3DUpdateState(NPP npp, | |
264 NPDeviceContext3D* context, | |
265 NPDeviceFlushContextCallbackPtr callback, | |
266 void* user_data); | |
267 #endif | |
268 | |
269 // Tells the browser out-of-band where the nested delegate lives on | |
270 // the page. | |
271 void SendNestedDelegateGeometryToBrowser(const gfx::Rect& window_rect, | |
272 const gfx::Rect& clip_rect); | |
273 | |
274 // Returns the selection. If nothing is selected, returns an empty string. | 248 // Returns the selection. If nothing is selected, returns an empty string. |
275 // If html is true, it will return a string only if html data is available. | 249 // If html is true, it will return a string only if html data is available. |
276 string16 GetSelectedText(bool html) const; | 250 string16 GetSelectedText(bool html) const; |
277 | 251 |
278 base::WeakPtr<RenderView> render_view_; | 252 base::WeakPtr<RenderView> render_view_; |
279 | 253 |
280 webkit::npapi::WebPlugin* plugin_; | 254 webkit::npapi::WebPlugin* plugin_; |
281 scoped_refptr<webkit::npapi::PluginInstance> instance_; | 255 scoped_refptr<webkit::npapi::PluginInstance> instance_; |
282 | 256 |
283 NPWindow window_; | 257 NPWindow window_; |
284 gfx::Rect window_rect_; | 258 gfx::Rect window_rect_; |
285 gfx::Rect clip_rect_; | 259 gfx::Rect clip_rect_; |
286 std::vector<gfx::Rect> cutout_rects_; | 260 std::vector<gfx::Rect> cutout_rects_; |
287 | 261 |
288 // Open device contexts | 262 // Open device contexts |
289 typedef IDMap<Graphics2DDeviceContext, IDMapOwnPointer> Graphics2DMap; | 263 typedef IDMap<Graphics2DDeviceContext, IDMapOwnPointer> Graphics2DMap; |
290 Graphics2DMap graphic2d_contexts_; | 264 Graphics2DMap graphic2d_contexts_; |
291 IDMap<AudioDeviceContext, IDMapOwnPointer> audio_contexts_; | 265 IDMap<AudioDeviceContext, IDMapOwnPointer> audio_contexts_; |
292 | 266 |
293 // Plugin graphics context implementation | 267 // Plugin graphics context implementation |
294 SkBitmap committed_bitmap_; | 268 SkBitmap committed_bitmap_; |
295 | 269 |
296 // The url with which the plugin was instantiated. | 270 // The url with which the plugin was instantiated. |
297 std::string plugin_url_; | 271 std::string plugin_url_; |
298 | 272 |
299 // The nested GPU plugin. | |
300 WebPluginDelegateProxy* nested_delegate_; | |
301 | |
302 // The last printable_area passed in to PrintBegin. We remember this because | 273 // The last printable_area passed in to PrintBegin. We remember this because |
303 // we need to stretch the printed raster bitmap to these dimensions. It is | 274 // we need to stretch the printed raster bitmap to these dimensions. It is |
304 // cleared in PrintEnd. | 275 // cleared in PrintEnd. |
305 gfx::Rect current_printable_area_; | 276 gfx::Rect current_printable_area_; |
306 int current_printer_dpi_; | 277 int current_printer_dpi_; |
307 #if defined(OS_MACOSX) | 278 #if defined(OS_MACOSX) |
308 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary | 279 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary |
309 // to keep the pixels valid until CGContextEndPage is called. We use this | 280 // to keep the pixels valid until CGContextEndPage is called. We use this |
310 // variable to hold on to the pixels. | 281 // variable to hold on to the pixels. |
311 SkBitmap last_printed_page_; | 282 SkBitmap last_printed_page_; |
312 #endif // defined(OS_MACOSX) | 283 #endif // defined(OS_MACOSX) |
313 #if defined (OS_LINUX) | 284 #if defined (OS_LINUX) |
314 // On Linux, we always send all pages from the renderer to the browser. | 285 // On Linux, we always send all pages from the renderer to the browser. |
315 // So, if the plugin supports printPagesAsPDF we print the entire output | 286 // So, if the plugin supports printPagesAsPDF we print the entire output |
316 // in one shot in the first call to PrintPage. | 287 // in one shot in the first call to PrintPage. |
317 // (This is a temporary hack until we change the WebFrame and WebPlugin print | 288 // (This is a temporary hack until we change the WebFrame and WebPlugin print |
318 // interfaces). | 289 // interfaces). |
319 // Specifies the total number of pages to be printed. It it set in PrintBegin. | 290 // Specifies the total number of pages to be printed. It it set in PrintBegin. |
320 int32 num_pages_; | 291 int32 num_pages_; |
321 // Specifies whether we have already output all pages. This is used to ignore | 292 // Specifies whether we have already output all pages. This is used to ignore |
322 // subsequent PrintPage requests. | 293 // subsequent PrintPage requests. |
323 bool pdf_output_done_; | 294 bool pdf_output_done_; |
324 #endif // defined(OS_LINUX) | 295 #endif // defined(OS_LINUX) |
325 | 296 |
326 #if defined(ENABLE_GPU) | |
327 // The command buffer used to issue commands to the nested GPU plugin. | |
328 CommandBufferProxy* command_buffer_; | |
329 | |
330 // Runnable methods that must be cancelled when the 3D context is destroyed. | |
331 ScopedRunnableMethodFactory<WebPluginDelegatePepper> method_factory3d_; | |
332 #endif | |
333 | |
334 // The id of the current find operation, or -1 if none is in process. | 297 // The id of the current find operation, or -1 if none is in process. |
335 int find_identifier_; | 298 int find_identifier_; |
336 | 299 |
337 // When a choose file operation is outstanding, this will contain a | 300 // When a choose file operation is outstanding, this will contain a |
338 // pointer to the callback specified by the plugin. Will be NULL otherwise. | 301 // pointer to the callback specified by the plugin. Will be NULL otherwise. |
339 NPChooseFileCallback current_choose_file_callback_; | 302 NPChooseFileCallback current_choose_file_callback_; |
340 void* current_choose_file_user_data_; | 303 void* current_choose_file_user_data_; |
341 | 304 |
342 scoped_ptr<WebKit::WebCursorInfo> cursor_; | 305 scoped_ptr<WebKit::WebCursorInfo> cursor_; |
343 | 306 |
344 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepper); | 307 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepper); |
345 }; | 308 }; |
346 | 309 |
347 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ | 310 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ |
OLD | NEW |