OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_PEPPER_IMPL_H_ | |
6 #define WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_PEPPER_IMPL_H_ | |
7 | |
8 #include "build/build_config.h" | |
9 | |
10 #include <list> | |
11 #include <string> | |
12 #include <vector> | |
13 | |
14 #include "app/gfx/native_widget_types.h" | |
15 #include "base/file_path.h" | |
16 #include "base/gfx/rect.h" | |
17 #include "base/ref_counted.h" | |
18 #include "base/task.h" | |
19 #include "third_party/npapi/bindings/npapi.h" | |
20 #include "webkit/glue/webcursor.h" | |
21 #include "webkit/glue/webplugin_delegate.h" | |
22 | |
23 namespace NPAPI { | |
24 class PluginInstance; | |
25 } | |
26 | |
27 // An implementation of WebPluginDelegate for Pepper in-process plugins. | |
28 class WebPluginDelegatePepperImpl : public webkit_glue::WebPluginDelegate { | |
29 public: | |
30 static WebPluginDelegatePepperImpl* Create(const FilePath& filename, | |
31 const std::string& mime_type, gfx::PluginWindowHandle containing_view); | |
32 | |
33 static bool IsPluginDelegateWindow(gfx::NativeWindow window); | |
34 static bool GetPluginNameFromWindow(gfx::NativeWindow window, | |
35 std::wstring *plugin_name); | |
36 | |
37 // Returns true if the window handle passed in is that of the dummy | |
38 // activation window for windowless plugins. | |
39 static bool IsDummyActivationWindow(gfx::NativeWindow window); | |
40 | |
41 // WebPluginDelegate implementation | |
42 virtual bool Initialize(const GURL& url, | |
43 const std::vector<std::string>& arg_names, | |
44 const std::vector<std::string>& arg_values, | |
45 webkit_glue::WebPlugin* plugin, | |
46 bool load_manually); | |
47 virtual void PluginDestroyed(); | |
48 virtual void UpdateGeometry(const gfx::Rect& window_rect, | |
49 const gfx::Rect& clip_rect); | |
50 virtual void Paint(gfx::NativeDrawingContext context, const gfx::Rect& rect); | |
51 virtual void Print(gfx::NativeDrawingContext context); | |
52 virtual void SetFocus(); | |
53 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, | |
54 WebKit::WebCursorInfo* cursor); | |
55 virtual NPObject* GetPluginScriptableObject(); | |
56 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, | |
57 intptr_t notify_data); | |
58 virtual int GetProcessId(); | |
59 virtual void SendJavaScriptStream(const GURL& url, | |
60 const std::string& result, | |
61 bool success, bool notify_needed, | |
62 intptr_t notify_data); | |
63 virtual void DidReceiveManualResponse(const GURL& url, | |
64 const std::string& mime_type, | |
65 const std::string& headers, | |
66 uint32 expected_length, | |
67 uint32 last_modified); | |
68 virtual void DidReceiveManualData(const char* buffer, int length); | |
69 virtual void DidFinishManualLoading(); | |
70 virtual void DidManualLoadFail(); | |
71 virtual void InstallMissingPlugin(); | |
72 virtual webkit_glue::WebPluginResourceClient* CreateResourceClient( | |
73 int resource_id, | |
74 const GURL& url, | |
75 bool notify_needed, | |
76 intptr_t notify_data, | |
77 intptr_t stream); | |
78 // End of WebPluginDelegate implementation. | |
79 | |
80 bool IsWindowless() const { return true; } | |
81 gfx::Rect GetRect() const { return window_rect_; } | |
82 gfx::Rect GetClipRect() const { return clip_rect_; } | |
83 | |
84 // Returns the path for the library implementing this plugin. | |
85 FilePath GetPluginPath(); | |
86 | |
87 private: | |
88 friend class DeleteTask<WebPluginDelegatePepperImpl>; | |
89 | |
90 WebPluginDelegatePepperImpl(gfx::PluginWindowHandle containing_view, | |
91 NPAPI::PluginInstance *instance); | |
92 ~WebPluginDelegatePepperImpl(); | |
93 | |
94 //---------------------------- | |
95 // used for windowless plugins | |
96 void WindowlessUpdateGeometry(const gfx::Rect& window_rect, | |
97 const gfx::Rect& clip_rect); | |
98 void WindowlessPaint(gfx::NativeDrawingContext hdc, const gfx::Rect& rect); | |
99 | |
100 // Tells the plugin about the current state of the window. | |
101 // See NPAPI NPP_SetWindow for more information. | |
102 void WindowlessSetWindow(bool force_set_window); | |
103 | |
104 //----------------------------------------- | |
105 // used for windowed and windowless plugins | |
106 | |
107 NPAPI::PluginInstance* instance() { return instance_.get(); } | |
108 | |
109 // Closes down and destroys our plugin instance. | |
110 void DestroyInstance(); | |
111 | |
112 webkit_glue::WebPlugin* plugin_; | |
113 scoped_refptr<NPAPI::PluginInstance> instance_; | |
114 | |
115 gfx::PluginWindowHandle parent_; | |
116 NPWindow window_; | |
117 gfx::Rect window_rect_; | |
118 gfx::Rect clip_rect_; | |
119 std::vector<gfx::Rect> cutout_rects_; | |
120 | |
121 // The url with which the plugin was instantiated. | |
122 std::string plugin_url_; | |
123 | |
124 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepperImpl); | |
125 }; | |
126 | |
127 #endif // WEBKIT_GLUE_PLUGIN_WEBPLUGIN_DELEGATE_PEPPER_IMPL_H_ | |
OLD | NEW |