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