OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 18 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
19 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" | 19 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" |
20 // TODO(dmichael): Remove the 0.3 printing interface and remove the following | 20 // TODO(dmichael): Remove the 0.3 printing interface and remove the following |
21 // #define. | 21 // #define. |
22 #define PPP_PRINTING_DEV_USE_0_4 1 | 22 #define PPP_PRINTING_DEV_USE_0_4 1 |
23 #include "ppapi/c/dev/ppp_printing_dev.h" | 23 #include "ppapi/c/dev/ppp_printing_dev.h" |
24 #include "ppapi/c/pp_instance.h" | 24 #include "ppapi/c/pp_instance.h" |
25 #include "ppapi/c/pp_resource.h" | 25 #include "ppapi/c/pp_resource.h" |
26 #include "third_party/skia/include/core/SkBitmap.h" | 26 #include "third_party/skia/include/core/SkBitmap.h" |
27 #include "third_party/skia/include/core/SkRefCnt.h" | |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" |
28 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
29 #include "webkit/plugins/ppapi/plugin_delegate.h" | 30 #include "webkit/plugins/ppapi/plugin_delegate.h" |
30 | 31 |
31 typedef struct NPObject NPObject; | 32 typedef struct NPObject NPObject; |
32 struct PP_Var; | 33 struct PP_Var; |
33 struct PPB_Instance; | 34 struct PPB_Instance; |
34 struct PPB_Instance_Private; | 35 struct PPB_Instance_Private; |
35 struct PPB_Find_Dev; | 36 struct PPB_Find_Dev; |
36 struct PPB_Fullscreen_Dev; | 37 struct PPB_Fullscreen_Dev; |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 bool checked_for_plugin_messaging_interface_; | 369 bool checked_for_plugin_messaging_interface_; |
369 | 370 |
370 // This is only valid between a successful PrintBegin call and a PrintEnd | 371 // This is only valid between a successful PrintBegin call and a PrintEnd |
371 // call. | 372 // call. |
372 PP_PrintSettings_Dev current_print_settings_; | 373 PP_PrintSettings_Dev current_print_settings_; |
373 #if defined(OS_MACOSX) | 374 #if defined(OS_MACOSX) |
374 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary | 375 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary |
375 // to keep the pixels valid until CGContextEndPage is called. We use this | 376 // to keep the pixels valid until CGContextEndPage is called. We use this |
376 // variable to hold on to the pixels. | 377 // variable to hold on to the pixels. |
377 scoped_refptr<PPB_ImageData_Impl> last_printed_page_; | 378 scoped_refptr<PPB_ImageData_Impl> last_printed_page_; |
378 #elif defined(OS_LINUX) | 379 #endif // defined(OS_MACOSX) |
379 // On Linux, all pages need to be written to a PDF file in one shot. However, | 380 #if WEBKIT_USING_SKIA |
380 // when users print only a subset of all the pages, it is impossible to know | 381 // When printing to print preview (PDF output), all pages need to be written |
Lei Zhang
2011/05/24 00:24:16
This comment isn't 100% correct. Regular printing
vandebo (ex-Chrome)
2011/05/24 05:48:38
Done.
| |
381 // if a call to PrintPage() is the last call. Thus in PrintPage(), just store | 382 // to a file in one shot. However, when users print only a subset of all the |
382 // the page number in |ranges_|. | 383 // pages, it is impossible to know if a call to PrintPage() is the last call. |
384 // Thus in PrintPage(), just store the page number in |ranges_|. | |
383 // The hack is in PrintEnd(), where a valid |canvas_| is preserved in | 385 // The hack is in PrintEnd(), where a valid |canvas_| is preserved in |
384 // PrintWebViewHelper::PrintPages. This makes it possible to generate the | 386 // PrintWebViewHelper::PrintPages. This makes it possible to generate the |
385 // entire PDF given the variables below: | 387 // entire PDF given the variables below: |
386 // | 388 // |
387 // The most recently used WebCanvas, guaranteed to be valid. | 389 // The most recently used WebCanvas, guaranteed to be valid. |
388 WebKit::WebCanvas* canvas_; | 390 SkRefPtr<WebKit::WebCanvas> canvas_; |
389 // An array of page ranges. | 391 // An array of page ranges. |
390 std::vector<PP_PrintPageNumberRange_Dev> ranges_; | 392 std::vector<PP_PrintPageNumberRange_Dev> ranges_; |
391 #endif // defined(OS_LINUX) | 393 #endif // WEBKIT_USING_SKIA |
392 | 394 |
393 // The plugin print interface. This nested struct adds functions needed for | 395 // The plugin print interface. This nested struct adds functions needed for |
394 // backwards compatibility. | 396 // backwards compatibility. |
395 struct PPP_Printing_Dev_Combined : public PPP_Printing_Dev { | 397 struct PPP_Printing_Dev_Combined : public PPP_Printing_Dev { |
396 // Conversion constructor for the most current interface. Sets all old | 398 // Conversion constructor for the most current interface. Sets all old |
397 // functions to NULL, so we know not to try to use them. | 399 // functions to NULL, so we know not to try to use them. |
398 PPP_Printing_Dev_Combined(const PPP_Printing_Dev& base_if) | 400 PPP_Printing_Dev_Combined(const PPP_Printing_Dev& base_if) |
399 : PPP_Printing_Dev(base_if), | 401 : PPP_Printing_Dev(base_if), |
400 QuerySupportedFormats_0_3(NULL), | 402 QuerySupportedFormats_0_3(NULL), |
401 Begin_0_3(NULL) {} | 403 Begin_0_3(NULL) {} |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; | 456 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; |
455 NPObjectToObjectVarMap np_object_to_object_var_; | 457 NPObjectToObjectVarMap np_object_to_object_var_; |
456 | 458 |
457 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 459 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
458 }; | 460 }; |
459 | 461 |
460 } // namespace ppapi | 462 } // namespace ppapi |
461 } // namespace webkit | 463 } // namespace webkit |
462 | 464 |
463 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 465 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |