| 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 WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PLUGIN_INSTANCE_H_ |
| 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PLUGIN_INSTANCE_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/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "gfx/rect.h" | 16 #include "gfx/rect.h" |
| 17 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 17 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
| 18 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" | 18 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" |
| 19 #include "ppapi/c/dev/ppp_printing_dev.h" | 19 #include "ppapi/c/dev/ppp_printing_dev.h" |
| 20 #include "ppapi/c/pp_instance.h" | 20 #include "ppapi/c/pp_instance.h" |
| 21 #include "ppapi/c/pp_resource.h" | 21 #include "ppapi/c/pp_resource.h" |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" |
| 24 | 24 |
| 25 struct PP_Var; | 25 struct PP_Var; |
| 26 struct PPB_Instance; | 26 struct PPB_Instance; |
| 27 struct PPB_Find_Dev; | 27 struct PPB_Find_Dev; |
| 28 struct PPB_Fullscreen_Dev; | 28 struct PPB_Fullscreen_Dev; |
| 29 struct PPB_Zoom_Dev; | 29 struct PPB_Zoom_Dev; |
| 30 struct PPP_Find_Dev; | 30 struct PPP_Find_Dev; |
| 31 struct PPP_Instance; | 31 struct PPP_Instance; |
| 32 struct PPP_Private; | 32 struct PPP_Pdf; |
| 33 struct PPP_Selection_Dev; | 33 struct PPP_Selection_Dev; |
| 34 struct PPP_Zoom_Dev; | 34 struct PPP_Zoom_Dev; |
| 35 | 35 |
| 36 class SkBitmap; | 36 class SkBitmap; |
| 37 class TransportDIB; | 37 class TransportDIB; |
| 38 | 38 |
| 39 namespace gfx { | 39 namespace gfx { |
| 40 class Rect; | 40 class Rect; |
| 41 } | 41 } |
| 42 | 42 |
| 43 namespace WebKit { | 43 namespace WebKit { |
| 44 struct WebCursorInfo; | 44 struct WebCursorInfo; |
| 45 class WebInputEvent; | 45 class WebInputEvent; |
| 46 class WebPluginContainer; | 46 class WebPluginContainer; |
| 47 } | 47 } |
| 48 | 48 |
| 49 namespace pepper { | 49 namespace webkit { |
| 50 namespace ppapi { |
| 50 | 51 |
| 51 class Graphics2D; | 52 class FullscreenContainer; |
| 52 class Graphics3D; | |
| 53 class ImageData; | |
| 54 class PluginDelegate; | 53 class PluginDelegate; |
| 55 class PluginModule; | 54 class PluginModule; |
| 55 class PPB_Graphics2D_Impl; |
| 56 class PPB_Graphics3D_Impl; |
| 57 class PPB_ImageData_Impl; |
| 58 class PPB_URLLoader_Impl; |
| 56 class Resource; | 59 class Resource; |
| 57 class URLLoader; | |
| 58 class FullscreenContainer; | |
| 59 | 60 |
| 60 // Represents one time a plugin appears on one web page. | 61 // Represents one time a plugin appears on one web page. |
| 61 // | 62 // |
| 62 // Note: to get from a PP_Instance to a PluginInstance*, use the | 63 // Note: to get from a PP_Instance to a PluginInstance*, use the |
| 63 // ResourceTracker. | 64 // ResourceTracker. |
| 64 class PluginInstance : public base::RefCounted<PluginInstance> { | 65 class PluginInstance : public base::RefCounted<PluginInstance> { |
| 65 public: | 66 public: |
| 66 class Observer { | 67 class Observer { |
| 67 public: | 68 public: |
| 68 // Indicates that the instance is being destroyed. This will be called from | 69 // Indicates that the instance is being destroyed. This will be called from |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 bool full_frame() const { return full_frame_; } | 138 bool full_frame() const { return full_frame_; } |
| 138 bool SetCursor(PP_CursorType_Dev type); | 139 bool SetCursor(PP_CursorType_Dev type); |
| 139 PP_Var ExecuteScript(PP_Var script, PP_Var* exception); | 140 PP_Var ExecuteScript(PP_Var script, PP_Var* exception); |
| 140 | 141 |
| 141 // PPP_Instance pass-through. | 142 // PPP_Instance pass-through. |
| 142 void Delete(); | 143 void Delete(); |
| 143 bool Initialize(WebKit::WebPluginContainer* container, | 144 bool Initialize(WebKit::WebPluginContainer* container, |
| 144 const std::vector<std::string>& arg_names, | 145 const std::vector<std::string>& arg_names, |
| 145 const std::vector<std::string>& arg_values, | 146 const std::vector<std::string>& arg_values, |
| 146 bool full_frame); | 147 bool full_frame); |
| 147 bool HandleDocumentLoad(URLLoader* loader); | 148 bool HandleDocumentLoad(PPB_URLLoader_Impl* loader); |
| 148 bool HandleInputEvent(const WebKit::WebInputEvent& event, | 149 bool HandleInputEvent(const WebKit::WebInputEvent& event, |
| 149 WebKit::WebCursorInfo* cursor_info); | 150 WebKit::WebCursorInfo* cursor_info); |
| 150 PP_Var GetInstanceObject(); | 151 PP_Var GetInstanceObject(); |
| 151 void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip); | 152 void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip); |
| 152 | 153 |
| 153 // Notifications about focus changes, see has_webkit_focus_ below. | 154 // Notifications about focus changes, see has_webkit_focus_ below. |
| 154 void SetWebKitFocus(bool has_focus); | 155 void SetWebKitFocus(bool has_focus); |
| 155 void SetContentAreaFocus(bool has_focus); | 156 void SetContentAreaFocus(bool has_focus); |
| 156 | 157 |
| 157 // Notifications that the view has rendered the page and that it has been | 158 // Notifications that the view has rendered the page and that it has been |
| (...skipping 25 matching lines...) Expand all Loading... |
| 183 int PrintBegin(const gfx::Rect& printable_area, int printer_dpi); | 184 int PrintBegin(const gfx::Rect& printable_area, int printer_dpi); |
| 184 bool PrintPage(int page_number, WebKit::WebCanvas* canvas); | 185 bool PrintPage(int page_number, WebKit::WebCanvas* canvas); |
| 185 void PrintEnd(); | 186 void PrintEnd(); |
| 186 | 187 |
| 187 void Graphics3DContextLost(); | 188 void Graphics3DContextLost(); |
| 188 | 189 |
| 189 // Implementation of PPB_Fullscreen_Dev. | 190 // Implementation of PPB_Fullscreen_Dev. |
| 190 bool IsFullscreen(); | 191 bool IsFullscreen(); |
| 191 bool SetFullscreen(bool fullscreen); | 192 bool SetFullscreen(bool fullscreen); |
| 192 | 193 |
| 193 // Implementation of PPB_Private2. | 194 // Implementation of PPB_Flash. |
| 194 bool NavigateToURL(const char* url, const char* target); | 195 bool NavigateToURL(const char* url, const char* target); |
| 195 | 196 |
| 196 private: | 197 private: |
| 197 bool LoadFindInterface(); | 198 bool LoadFindInterface(); |
| 198 bool LoadPrivateInterface(); | 199 bool LoadPdfInterface(); |
| 199 bool LoadSelectionInterface(); | 200 bool LoadSelectionInterface(); |
| 200 bool LoadZoomInterface(); | 201 bool LoadZoomInterface(); |
| 201 | 202 |
| 202 // Determines if we think the plugin has focus, both content area and webkit | 203 // Determines if we think the plugin has focus, both content area and webkit |
| 203 // (see has_webkit_focus_ below). | 204 // (see has_webkit_focus_ below). |
| 204 bool PluginHasFocus() const; | 205 bool PluginHasFocus() const; |
| 205 | 206 |
| 206 // Queries the plugin for supported print formats and sets |format| to the | 207 // Queries the plugin for supported print formats and sets |format| to the |
| 207 // best format to use. Returns false if the plugin does not support any | 208 // best format to use. Returns false if the plugin does not support any |
| 208 // print format that we can handle (we can handle raster and PDF). | 209 // print format that we can handle (we can handle raster and PDF). |
| 209 bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat_Dev* format); | 210 bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat_Dev* format); |
| 210 bool PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); | 211 bool PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); |
| 211 bool PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); | 212 bool PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); |
| 212 #if defined(OS_WIN) | 213 #if defined(OS_WIN) |
| 213 bool DrawJPEGToPlatformDC(const SkBitmap& bitmap, | 214 bool DrawJPEGToPlatformDC(const SkBitmap& bitmap, |
| 214 const gfx::Rect& printable_area, | 215 const gfx::Rect& printable_area, |
| 215 WebKit::WebCanvas* canvas); | 216 WebKit::WebCanvas* canvas); |
| 216 #elif defined(OS_MACOSX) | 217 #elif defined(OS_MACOSX) |
| 217 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting | 218 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting |
| 218 // at the specified destination rect. | 219 // at the specified destination rect. |
| 219 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas, | 220 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas, |
| 220 const gfx::Rect& dest_rect, int canvas_height); | 221 const gfx::Rect& dest_rect, int canvas_height); |
| 221 #endif // OS_MACOSX | 222 #endif // OS_MACOSX |
| 222 | 223 |
| 223 // Get the bound graphics context as a concrete 2D graphics context or returns | 224 // Get the bound graphics context as a concrete 2D graphics context or returns |
| 224 // null if the context is not 2D. | 225 // null if the context is not 2D. |
| 225 Graphics2D* bound_graphics_2d() const; | 226 PPB_Graphics2D_Impl* bound_graphics_2d() const; |
| 226 | 227 |
| 227 // Get the bound graphics context as a concrete 3D graphics context or returns | 228 // Get the bound graphics context as a concrete 3D graphics context or returns |
| 228 // null if the context is not 3D. | 229 // null if the context is not 3D. |
| 229 Graphics3D* bound_graphics_3d() const; | 230 PPB_Graphics3D_Impl* bound_graphics_3d() const; |
| 230 | 231 |
| 231 PluginDelegate* delegate_; | 232 PluginDelegate* delegate_; |
| 232 scoped_refptr<PluginModule> module_; | 233 scoped_refptr<PluginModule> module_; |
| 233 const PPP_Instance* instance_interface_; | 234 const PPP_Instance* instance_interface_; |
| 234 | 235 |
| 235 PP_Instance pp_instance_; | 236 PP_Instance pp_instance_; |
| 236 | 237 |
| 237 // NULL until we have been initialized. | 238 // NULL until we have been initialized. |
| 238 WebKit::WebPluginContainer* container_; | 239 WebKit::WebPluginContainer* container_; |
| 239 | 240 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 259 // tab/window has focus. We tell the plugin it has focus only when both of | 260 // tab/window has focus. We tell the plugin it has focus only when both of |
| 260 // these values are set to true. | 261 // these values are set to true. |
| 261 bool has_webkit_focus_; | 262 bool has_webkit_focus_; |
| 262 bool has_content_area_focus_; | 263 bool has_content_area_focus_; |
| 263 | 264 |
| 264 // The id of the current find operation, or -1 if none is in process. | 265 // The id of the current find operation, or -1 if none is in process. |
| 265 int find_identifier_; | 266 int find_identifier_; |
| 266 | 267 |
| 267 // The plugin-provided interfaces. | 268 // The plugin-provided interfaces. |
| 268 const PPP_Find_Dev* plugin_find_interface_; | 269 const PPP_Find_Dev* plugin_find_interface_; |
| 269 const PPP_Private* plugin_private_interface_; | 270 const PPP_Pdf* plugin_pdf_interface_; |
| 270 const PPP_Selection_Dev* plugin_selection_interface_; | 271 const PPP_Selection_Dev* plugin_selection_interface_; |
| 271 const PPP_Zoom_Dev* plugin_zoom_interface_; | 272 const PPP_Zoom_Dev* plugin_zoom_interface_; |
| 272 | 273 |
| 273 // This is only valid between a successful PrintBegin call and a PrintEnd | 274 // This is only valid between a successful PrintBegin call and a PrintEnd |
| 274 // call. | 275 // call. |
| 275 PP_PrintSettings_Dev current_print_settings_; | 276 PP_PrintSettings_Dev current_print_settings_; |
| 276 #if defined(OS_MACOSX) | 277 #if defined(OS_MACOSX) |
| 277 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary | 278 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary |
| 278 // to keep the pixels valid until CGContextEndPage is called. We use this | 279 // to keep the pixels valid until CGContextEndPage is called. We use this |
| 279 // variable to hold on to the pixels. | 280 // variable to hold on to the pixels. |
| 280 scoped_refptr<ImageData> last_printed_page_; | 281 scoped_refptr<PPB_ImageData_Impl> last_printed_page_; |
| 281 #elif defined(OS_LINUX) | 282 #elif defined(OS_LINUX) |
| 282 // On Linux, we always send all pages from the renderer to the browser. | 283 // On Linux, we always send all pages from the renderer to the browser. |
| 283 // So, if the plugin supports printPagesAsPDF we print the entire output | 284 // So, if the plugin supports printPagesAsPDF we print the entire output |
| 284 // in one shot in the first call to PrintPage. | 285 // in one shot in the first call to PrintPage. |
| 285 // (This is a temporary hack until we change the WebFrame and WebPlugin print | 286 // (This is a temporary hack until we change the WebFrame and WebPlugin print |
| 286 // interfaces). | 287 // interfaces). |
| 287 // Specifies the total number of pages to be printed. It it set in PrintBegin. | 288 // Specifies the total number of pages to be printed. It it set in PrintBegin. |
| 288 int32 num_pages_; | 289 int32 num_pages_; |
| 289 // Specifies whether we have already output all pages. This is used to ignore | 290 // Specifies whether we have already output all pages. This is used to ignore |
| 290 // subsequent PrintPage requests. | 291 // subsequent PrintPage requests. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 306 | 307 |
| 307 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. | 308 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. |
| 308 FullscreenContainer* fullscreen_container_; | 309 FullscreenContainer* fullscreen_container_; |
| 309 | 310 |
| 310 // Non-owning pointers to all active observers. | 311 // Non-owning pointers to all active observers. |
| 311 ObserverList<Observer, false> observers_; | 312 ObserverList<Observer, false> observers_; |
| 312 | 313 |
| 313 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 314 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
| 314 }; | 315 }; |
| 315 | 316 |
| 316 } // namespace pepper | 317 } // namespace ppapi |
| 318 } // namespace webkit |
| 317 | 319 |
| 318 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ | 320 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_INSTANCE_H_ |
| OLD | NEW |