| 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" | 19 #include "chrome/renderer/command_buffer_proxy.h" |
| 20 #include "gfx/native_widget_types.h" | 20 #include "gfx/native_widget_types.h" |
| 21 #include "gfx/rect.h" | 21 #include "gfx/rect.h" |
| 22 #include "third_party/npapi/bindings/npapi.h" | 22 #include "third_party/npapi/bindings/npapi.h" |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
| 24 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h" |
| 25 #include "webkit/plugins/npapi/webplugin_delegate.h" | 25 #include "webkit/glue/plugins/webplugin_delegate.h" |
| 26 | 26 |
| 27 class FilePath; | 27 class FilePath; |
| 28 class RenderView; | 28 class RenderView; |
| 29 class WebCursor; | 29 class WebCursor; |
| 30 class WebPluginDelegateProxy; | 30 class WebPluginDelegateProxy; |
| 31 | 31 |
| 32 namespace webkit { | 32 namespace NPAPI { |
| 33 namespace npapi { | |
| 34 class PluginInstance; | 33 class PluginInstance; |
| 35 } | 34 } |
| 36 } | |
| 37 | 35 |
| 38 // An implementation of WebPluginDelegate for Pepper in-process plugins. | 36 // An implementation of WebPluginDelegate for Pepper in-process plugins. |
| 39 class WebPluginDelegatePepper : public webkit::npapi::WebPluginDelegate, | 37 class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate, |
| 40 public WebKit::WebFileChooserCompletion { | 38 public WebKit::WebFileChooserCompletion { |
| 41 public: | 39 public: |
| 42 static WebPluginDelegatePepper* Create( | 40 static WebPluginDelegatePepper* Create( |
| 43 const FilePath& filename, | 41 const FilePath& filename, |
| 44 const std::string& mime_type, | 42 const std::string& mime_type, |
| 45 const base::WeakPtr<RenderView>& render_view); | 43 const base::WeakPtr<RenderView>& render_view); |
| 46 | 44 |
| 47 webkit::npapi::PluginInstance* instance() { return instance_.get(); } | 45 NPAPI::PluginInstance* instance() { return instance_.get(); } |
| 48 | 46 |
| 49 // WebKit::WebFileChooserCompletion implementation. | 47 // WebKit::WebFileChooserCompletion implementation. |
| 50 virtual void didChooseFile( | 48 virtual void didChooseFile( |
| 51 const WebKit::WebVector<WebKit::WebString>& file_names); | 49 const WebKit::WebVector<WebKit::WebString>& file_names); |
| 52 | 50 |
| 53 // WebPluginDelegate implementation | 51 // WebPluginDelegate implementation |
| 54 virtual bool Initialize(const GURL& url, | 52 virtual bool Initialize(const GURL& url, |
| 55 const std::vector<std::string>& arg_names, | 53 const std::vector<std::string>& arg_names, |
| 56 const std::vector<std::string>& arg_values, | 54 const std::vector<std::string>& arg_values, |
| 57 webkit::npapi::WebPlugin* plugin, | 55 webkit_glue::WebPlugin* plugin, |
| 58 bool load_manually); | 56 bool load_manually); |
| 59 virtual void PluginDestroyed(); | 57 virtual void PluginDestroyed(); |
| 60 virtual void UpdateGeometry(const gfx::Rect& window_rect, | 58 virtual void UpdateGeometry(const gfx::Rect& window_rect, |
| 61 const gfx::Rect& clip_rect); | 59 const gfx::Rect& clip_rect); |
| 62 virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect); | 60 virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect); |
| 63 virtual void Print(gfx::NativeDrawingContext context); | 61 virtual void Print(gfx::NativeDrawingContext context); |
| 64 virtual void SetFocus(bool focused); | 62 virtual void SetFocus(bool focused); |
| 65 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, | 63 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, |
| 66 WebKit::WebCursorInfo* cursor); | 64 WebKit::WebCursorInfo* cursor); |
| 67 virtual NPObject* GetPluginScriptableObject(); | 65 virtual NPObject* GetPluginScriptableObject(); |
| 68 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, | 66 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, |
| 69 int notify_id); | 67 int notify_id); |
| 70 virtual int GetProcessId(); | 68 virtual int GetProcessId(); |
| 71 virtual void SendJavaScriptStream(const GURL& url, | 69 virtual void SendJavaScriptStream(const GURL& url, |
| 72 const std::string& result, | 70 const std::string& result, |
| 73 bool success, | 71 bool success, |
| 74 int notify_id); | 72 int notify_id); |
| 75 virtual void DidReceiveManualResponse(const GURL& url, | 73 virtual void DidReceiveManualResponse(const GURL& url, |
| 76 const std::string& mime_type, | 74 const std::string& mime_type, |
| 77 const std::string& headers, | 75 const std::string& headers, |
| 78 uint32 expected_length, | 76 uint32 expected_length, |
| 79 uint32 last_modified); | 77 uint32 last_modified); |
| 80 virtual void DidReceiveManualData(const char* buffer, int length); | 78 virtual void DidReceiveManualData(const char* buffer, int length); |
| 81 virtual void DidFinishManualLoading(); | 79 virtual void DidFinishManualLoading(); |
| 82 virtual void DidManualLoadFail(); | 80 virtual void DidManualLoadFail(); |
| 83 virtual void InstallMissingPlugin(); | 81 virtual void InstallMissingPlugin(); |
| 84 virtual webkit::npapi::WebPluginResourceClient* CreateResourceClient( | 82 virtual webkit_glue::WebPluginResourceClient* CreateResourceClient( |
| 85 unsigned long resource_id, const GURL& url, int notify_id); | 83 unsigned long resource_id, const GURL& url, int notify_id); |
| 86 virtual webkit::npapi::WebPluginResourceClient* CreateSeekableResourceClient( | 84 virtual webkit_glue::WebPluginResourceClient* CreateSeekableResourceClient( |
| 87 unsigned long resource_id, int range_request_id); | 85 unsigned long resource_id, int range_request_id); |
| 88 virtual bool StartFind(const string16& search_text, | 86 virtual bool StartFind(const string16& search_text, |
| 89 bool case_sensitive, | 87 bool case_sensitive, |
| 90 int identifier); | 88 int identifier); |
| 91 virtual void SelectFindResult(bool forward); | 89 virtual void SelectFindResult(bool forward); |
| 92 virtual void StopFind(); | 90 virtual void StopFind(); |
| 93 virtual void NumberOfFindResultsChanged(int total, bool final_result); | 91 virtual void NumberOfFindResultsChanged(int total, bool final_result); |
| 94 virtual void SelectedFindResultChanged(int index); | 92 virtual void SelectedFindResultChanged(int index); |
| 95 virtual bool ChooseFile(const char* mime_types, | 93 virtual bool ChooseFile(const char* mime_types, |
| 96 int mode, | 94 int mode, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // when an ack was received that the browser copied it to the screen | 201 // when an ack was received that the browser copied it to the screen |
| 204 // (FlushedPaint). | 202 // (FlushedPaint). |
| 205 void RenderViewInitiatedPaint(); | 203 void RenderViewInitiatedPaint(); |
| 206 void RenderViewFlushedPaint(); | 204 void RenderViewFlushedPaint(); |
| 207 | 205 |
| 208 Graphics2DDeviceContext* GetGraphicsContext(NPDeviceContext2D* context); | 206 Graphics2DDeviceContext* GetGraphicsContext(NPDeviceContext2D* context); |
| 209 | 207 |
| 210 private: | 208 private: |
| 211 WebPluginDelegatePepper( | 209 WebPluginDelegatePepper( |
| 212 const base::WeakPtr<RenderView>& render_view, | 210 const base::WeakPtr<RenderView>& render_view, |
| 213 webkit::npapi::PluginInstance *instance); | 211 NPAPI::PluginInstance *instance); |
| 214 ~WebPluginDelegatePepper(); | 212 ~WebPluginDelegatePepper(); |
| 215 | 213 |
| 216 // Set a task that calls the repaint callback the next time the window | 214 // Set a task that calls the repaint callback the next time the window |
| 217 // is invalid and needs to be repainted. | 215 // is invalid and needs to be repainted. |
| 218 void ScheduleHandleRepaint(NPP npp, NPDeviceContext3D* context); | 216 void ScheduleHandleRepaint(NPP npp, NPDeviceContext3D* context); |
| 219 | 217 |
| 220 //----------------------------------------- | 218 //----------------------------------------- |
| 221 // used for windowed and windowless plugins | 219 // used for windowed and windowless plugins |
| 222 | 220 |
| 223 // Closes down and destroys our plugin instance. | 221 // Closes down and destroys our plugin instance. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // the page. | 268 // the page. |
| 271 void SendNestedDelegateGeometryToBrowser(const gfx::Rect& window_rect, | 269 void SendNestedDelegateGeometryToBrowser(const gfx::Rect& window_rect, |
| 272 const gfx::Rect& clip_rect); | 270 const gfx::Rect& clip_rect); |
| 273 | 271 |
| 274 // Returns the selection. If nothing is selected, returns an empty string. | 272 // 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. | 273 // If html is true, it will return a string only if html data is available. |
| 276 string16 GetSelectedText(bool html) const; | 274 string16 GetSelectedText(bool html) const; |
| 277 | 275 |
| 278 base::WeakPtr<RenderView> render_view_; | 276 base::WeakPtr<RenderView> render_view_; |
| 279 | 277 |
| 280 webkit::npapi::WebPlugin* plugin_; | 278 webkit_glue::WebPlugin* plugin_; |
| 281 scoped_refptr<webkit::npapi::PluginInstance> instance_; | 279 scoped_refptr<NPAPI::PluginInstance> instance_; |
| 282 | 280 |
| 283 NPWindow window_; | 281 NPWindow window_; |
| 284 gfx::Rect window_rect_; | 282 gfx::Rect window_rect_; |
| 285 gfx::Rect clip_rect_; | 283 gfx::Rect clip_rect_; |
| 286 std::vector<gfx::Rect> cutout_rects_; | 284 std::vector<gfx::Rect> cutout_rects_; |
| 287 | 285 |
| 288 // Open device contexts | 286 // Open device contexts |
| 289 typedef IDMap<Graphics2DDeviceContext, IDMapOwnPointer> Graphics2DMap; | 287 typedef IDMap<Graphics2DDeviceContext, IDMapOwnPointer> Graphics2DMap; |
| 290 Graphics2DMap graphic2d_contexts_; | 288 Graphics2DMap graphic2d_contexts_; |
| 291 IDMap<AudioDeviceContext, IDMapOwnPointer> audio_contexts_; | 289 IDMap<AudioDeviceContext, IDMapOwnPointer> audio_contexts_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // pointer to the callback specified by the plugin. Will be NULL otherwise. | 336 // pointer to the callback specified by the plugin. Will be NULL otherwise. |
| 339 NPChooseFileCallback current_choose_file_callback_; | 337 NPChooseFileCallback current_choose_file_callback_; |
| 340 void* current_choose_file_user_data_; | 338 void* current_choose_file_user_data_; |
| 341 | 339 |
| 342 scoped_ptr<WebKit::WebCursorInfo> cursor_; | 340 scoped_ptr<WebKit::WebCursorInfo> cursor_; |
| 343 | 341 |
| 344 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepper); | 342 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepper); |
| 345 }; | 343 }; |
| 346 | 344 |
| 347 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ | 345 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ |
| OLD | NEW |