OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ | |
6 #define CHROME_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ | |
7 #pragma once | |
8 | |
9 #include <set> | |
10 #include <string> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/id_map.h" | |
14 #include "base/ref_counted.h" | |
15 #include "base/weak_ptr.h" | |
16 #include "webkit/plugins/ppapi/plugin_delegate.h" | |
17 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" | |
18 | |
19 class FilePath; | |
20 class RenderView; | |
21 | |
22 namespace gfx { | |
23 class Point; | |
24 class Rect; | |
25 } | |
26 | |
27 namespace webkit { | |
28 namespace ppapi { | |
29 class PepperFilePath; | |
30 class PluginInstance; | |
31 class PluginModule; | |
32 } | |
33 } | |
34 | |
35 namespace WebKit { | |
36 class WebFileChooserCompletion; | |
37 struct WebFileChooserParams; | |
38 } | |
39 | |
40 namespace webkit_glue { | |
41 struct CustomContextMenuContext; | |
42 } | |
43 | |
44 class TransportDIB; | |
45 | |
46 class PepperPluginDelegateImpl | |
47 : public webkit::ppapi::PluginDelegate, | |
48 public base::SupportsWeakPtr<PepperPluginDelegateImpl> { | |
49 public: | |
50 explicit PepperPluginDelegateImpl(RenderView* render_view); | |
51 virtual ~PepperPluginDelegateImpl(); | |
52 | |
53 scoped_refptr<webkit::ppapi::PluginModule> CreatePepperPlugin( | |
54 const FilePath& path); | |
55 | |
56 // Called by RenderView to tell us about painting events, these two functions | |
57 // just correspond to the DidInitiatePaint and DidFlushPaint in R.V.. | |
58 void ViewInitiatedPaint(); | |
59 void ViewFlushedPaint(); | |
60 | |
61 // Called by RenderView to implement the corresponding function in its base | |
62 // class RenderWidget (see that for more). | |
63 webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( | |
64 const gfx::Rect& paint_bounds, | |
65 TransportDIB** dib, | |
66 gfx::Rect* location, | |
67 gfx::Rect* clip); | |
68 | |
69 // Called by RenderView when ViewMsg_AsyncOpenFile_ACK. | |
70 void OnAsyncFileOpened(base::PlatformFileError error_code, | |
71 base::PlatformFile file, | |
72 int message_id); | |
73 | |
74 // Notification that the render view has been focused or defocused. This | |
75 // notifies all of the plugins. | |
76 void OnSetFocus(bool has_focus); | |
77 | |
78 // PluginDelegate implementation. | |
79 virtual void InstanceCreated( | |
80 webkit::ppapi::PluginInstance* instance); | |
81 virtual void InstanceDeleted( | |
82 webkit::ppapi::PluginInstance* instance); | |
83 virtual PlatformAudio* CreateAudio( | |
84 uint32_t sample_rate, | |
85 uint32_t sample_count, | |
86 PlatformAudio::Client* client); | |
87 virtual PlatformImage2D* CreateImage2D(int width, int height); | |
88 virtual PlatformContext3D* CreateContext3D(); | |
89 virtual PlatformVideoDecoder* CreateVideoDecoder( | |
90 const PP_VideoDecoderConfig_Dev& decoder_config); | |
91 virtual void NumberOfFindResultsChanged(int identifier, | |
92 int total, | |
93 bool final_result); | |
94 virtual void SelectedFindResultChanged(int identifier, int index); | |
95 virtual bool RunFileChooser( | |
96 const WebKit::WebFileChooserParams& params, | |
97 WebKit::WebFileChooserCompletion* chooser_completion); | |
98 virtual bool AsyncOpenFile(const FilePath& path, | |
99 int flags, | |
100 AsyncOpenFileCallback* callback); | |
101 virtual bool OpenFileSystem( | |
102 const GURL& url, | |
103 fileapi::FileSystemType type, | |
104 long long size, | |
105 fileapi::FileSystemCallbackDispatcher* dispatcher); | |
106 virtual bool MakeDirectory(const FilePath& path, | |
107 bool recursive, | |
108 fileapi::FileSystemCallbackDispatcher* dispatcher); | |
109 virtual bool Query(const FilePath& path, | |
110 fileapi::FileSystemCallbackDispatcher* dispatcher); | |
111 virtual bool Touch(const FilePath& path, | |
112 const base::Time& last_access_time, | |
113 const base::Time& last_modified_time, | |
114 fileapi::FileSystemCallbackDispatcher* dispatcher); | |
115 virtual bool Delete(const FilePath& path, | |
116 fileapi::FileSystemCallbackDispatcher* dispatcher); | |
117 virtual bool Rename(const FilePath& file_path, | |
118 const FilePath& new_file_path, | |
119 fileapi::FileSystemCallbackDispatcher* dispatcher); | |
120 virtual bool ReadDirectory(const FilePath& directory_path, | |
121 fileapi::FileSystemCallbackDispatcher* dispatcher); | |
122 virtual base::PlatformFileError OpenFile( | |
123 const webkit::ppapi::PepperFilePath& path, | |
124 int flags, | |
125 base::PlatformFile* file); | |
126 virtual base::PlatformFileError RenameFile( | |
127 const webkit::ppapi::PepperFilePath& from_path, | |
128 const webkit::ppapi::PepperFilePath& to_path); | |
129 virtual base::PlatformFileError DeleteFileOrDir( | |
130 const webkit::ppapi::PepperFilePath& path, | |
131 bool recursive); | |
132 virtual base::PlatformFileError CreateDir( | |
133 const webkit::ppapi::PepperFilePath& path); | |
134 virtual base::PlatformFileError QueryFile( | |
135 const webkit::ppapi::PepperFilePath& path, | |
136 base::PlatformFileInfo* info); | |
137 virtual base::PlatformFileError GetDirContents( | |
138 const webkit::ppapi::PepperFilePath& path, | |
139 webkit::ppapi::DirContents* contents); | |
140 virtual scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy(); | |
141 virtual int32_t ConnectTcp( | |
142 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, | |
143 const char* host, | |
144 uint16_t port); | |
145 virtual int32_t ConnectTcpAddress( | |
146 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, | |
147 const struct PP_Flash_NetAddress* addr); | |
148 // This is the completion for both |ConnectTcp()| and |ConnectTcpAddress()|. | |
149 void OnConnectTcpACK( | |
150 int request_id, | |
151 base::PlatformFile socket, | |
152 const PP_Flash_NetAddress& local_addr, | |
153 const PP_Flash_NetAddress& remote_addr); | |
154 virtual int32_t ShowContextMenu( | |
155 webkit::ppapi::PPB_Flash_Menu_Impl* menu, | |
156 const gfx::Point& position); | |
157 void OnContextMenuClosed( | |
158 const webkit_glue::CustomContextMenuContext& custom_context); | |
159 void OnCustomContextMenuAction( | |
160 const webkit_glue::CustomContextMenuContext& custom_context, | |
161 unsigned action); | |
162 void CompleteShowContextMenu(int request_id, | |
163 bool did_select, | |
164 unsigned action); | |
165 virtual webkit::ppapi::FullscreenContainer* | |
166 CreateFullscreenContainer( | |
167 webkit::ppapi::PluginInstance* instance); | |
168 virtual gfx::Size GetScreenSize(); | |
169 virtual std::string GetDefaultEncoding(); | |
170 virtual void ZoomLimitsChanged(double minimum_factor, double maximum_factor); | |
171 virtual std::string ResolveProxy(const GURL& url); | |
172 virtual void DidStartLoading(); | |
173 virtual void DidStopLoading(); | |
174 virtual void SetContentRestriction(int restrictions); | |
175 virtual void HasUnsupportedFeature(); | |
176 virtual P2PSocketDispatcher* GetP2PSocketDispatcher(); | |
177 | |
178 private: | |
179 // Pointer to the RenderView that owns us. | |
180 RenderView* render_view_; | |
181 | |
182 std::set<webkit::ppapi::PluginInstance*> active_instances_; | |
183 | |
184 // Used to send a single context menu "completion" upon menu close. | |
185 bool has_saved_context_menu_action_; | |
186 unsigned saved_context_menu_action_; | |
187 | |
188 // TODO(viettrungluu): Get rid of |id_generator_| -- just use |IDMap::Add()|. | |
189 // Rename |messages_waiting_replies_| (to specify async open file). | |
190 int id_generator_; | |
191 IDMap<AsyncOpenFileCallback> messages_waiting_replies_; | |
192 | |
193 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>, | |
194 IDMapOwnPointer> pending_connect_tcps_; | |
195 | |
196 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>, | |
197 IDMapOwnPointer> pending_context_menus_; | |
198 | |
199 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); | |
200 }; | |
201 | |
202 #endif // CHROME_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ | |
OLD | NEW |