OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ppapi/cpp/private/flash.h" | 5 #include "ppapi/cpp/private/flash.h" |
6 | 6 |
7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/cpp/dev/font_dev.h" | 9 #include "ppapi/cpp/dev/font_dev.h" |
10 #include "ppapi/cpp/image_data.h" | 10 #include "ppapi/cpp/image_data.h" |
11 #include "ppapi/cpp/instance_handle.h" | 11 #include "ppapi/cpp/instance_handle.h" |
12 #include "ppapi/cpp/module.h" | 12 #include "ppapi/cpp/module.h" |
13 #include "ppapi/cpp/module_impl.h" | 13 #include "ppapi/cpp/module_impl.h" |
14 #include "ppapi/cpp/point.h" | 14 #include "ppapi/cpp/point.h" |
15 #include "ppapi/cpp/rect.h" | 15 #include "ppapi/cpp/rect.h" |
16 #include "ppapi/cpp/url_request_info.h" | 16 #include "ppapi/cpp/url_request_info.h" |
17 #include "ppapi/cpp/var.h" | 17 #include "ppapi/cpp/var.h" |
18 #include "ppapi/c/private/ppb_flash.h" | 18 #include "ppapi/c/private/ppb_flash.h" |
19 | 19 |
20 namespace pp { | 20 namespace pp { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 template <> const char* interface_name<PPB_Flash>() { | 24 template <> const char* interface_name<PPB_Flash_12_2>() { |
25 return PPB_FLASH_INTERFACE; | 25 return PPB_FLASH_INTERFACE_12_2; |
| 26 } |
| 27 |
| 28 template <> const char* interface_name<PPB_Flash_12_1>() { |
| 29 return PPB_FLASH_INTERFACE_12_1; |
26 } | 30 } |
27 | 31 |
28 template <> const char* interface_name<PPB_Flash_12_0>() { | 32 template <> const char* interface_name<PPB_Flash_12_0>() { |
29 return PPB_FLASH_INTERFACE_12_0; | 33 return PPB_FLASH_INTERFACE_12_0; |
30 } | 34 } |
31 | 35 |
32 template <> const char* interface_name<PPB_Flash_11>() { | 36 template <> const char* interface_name<PPB_Flash_11>() { |
33 return PPB_FLASH_INTERFACE_11_0; | 37 return PPB_FLASH_INTERFACE_11_0; |
34 } | 38 } |
35 | 39 |
36 } // namespace | 40 } // namespace |
37 | 41 |
38 namespace flash { | 42 namespace flash { |
39 | 43 |
40 // static | 44 // static |
41 bool Flash::IsAvailable() { | 45 bool Flash::IsAvailable() { |
42 return has_interface<PPB_Flash>() || | 46 return has_interface<PPB_Flash_12_2>() || |
| 47 has_interface<PPB_Flash_12_1>() || |
43 has_interface<PPB_Flash_12_0>() || | 48 has_interface<PPB_Flash_12_0>() || |
44 has_interface<PPB_Flash_11>(); | 49 has_interface<PPB_Flash_11>(); |
45 } | 50 } |
46 | 51 |
47 // static | 52 // static |
48 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance, | 53 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance, |
49 bool on_top) { | 54 bool on_top) { |
50 if (has_interface<PPB_Flash>()) { | 55 if (has_interface<PPB_Flash_12_2>()) { |
51 get_interface<PPB_Flash>()->SetInstanceAlwaysOnTop(instance.pp_instance(), | 56 get_interface<PPB_Flash_12_2>()->SetInstanceAlwaysOnTop( |
52 PP_FromBool(on_top)); | 57 instance.pp_instance(), PP_FromBool(on_top)); |
| 58 } else if (has_interface<PPB_Flash_12_1>()) { |
| 59 get_interface<PPB_Flash_12_1>()->SetInstanceAlwaysOnTop( |
| 60 instance.pp_instance(), PP_FromBool(on_top)); |
53 } else if (has_interface<PPB_Flash_12_0>()) { | 61 } else if (has_interface<PPB_Flash_12_0>()) { |
54 get_interface<PPB_Flash_12_0>()->SetInstanceAlwaysOnTop( | 62 get_interface<PPB_Flash_12_0>()->SetInstanceAlwaysOnTop( |
55 instance.pp_instance(), PP_FromBool(on_top)); | 63 instance.pp_instance(), PP_FromBool(on_top)); |
56 } else if (has_interface<PPB_Flash_11>()) { | 64 } else if (has_interface<PPB_Flash_11>()) { |
57 get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop( | 65 get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop( |
58 instance.pp_instance(), PP_FromBool(on_top)); | 66 instance.pp_instance(), PP_FromBool(on_top)); |
59 } | 67 } |
60 } | 68 } |
61 | 69 |
62 // static | 70 // static |
63 bool Flash::DrawGlyphs(const InstanceHandle& instance, | 71 bool Flash::DrawGlyphs(const InstanceHandle& instance, |
64 ImageData* image, | 72 ImageData* image, |
65 const FontDescription_Dev& font_desc, | 73 const FontDescription_Dev& font_desc, |
66 uint32_t color, | 74 uint32_t color, |
67 const Point& position, | 75 const Point& position, |
68 const Rect& clip, | 76 const Rect& clip, |
69 const float transformation[3][3], | 77 const float transformation[3][3], |
70 bool allow_subpixel_aa, | 78 bool allow_subpixel_aa, |
71 uint32_t glyph_count, | 79 uint32_t glyph_count, |
72 const uint16_t glyph_indices[], | 80 const uint16_t glyph_indices[], |
73 const PP_Point glyph_advances[]) { | 81 const PP_Point glyph_advances[]) { |
74 bool rv = false; | 82 bool rv = false; |
75 if (has_interface<PPB_Flash>()) { | 83 if (has_interface<PPB_Flash_12_2>()) { |
76 rv = PP_ToBool(get_interface<PPB_Flash>()->DrawGlyphs( | 84 rv = PP_ToBool(get_interface<PPB_Flash_12_2>()->DrawGlyphs( |
77 instance.pp_instance(), | 85 instance.pp_instance(), |
78 image->pp_resource(), | 86 image->pp_resource(), |
79 &font_desc.pp_font_description(), | 87 &font_desc.pp_font_description(), |
| 88 color, |
| 89 &position.pp_point(), |
| 90 &clip.pp_rect(), |
| 91 transformation, |
| 92 PP_FromBool(allow_subpixel_aa), |
| 93 glyph_count, |
| 94 glyph_indices, |
| 95 glyph_advances)); |
| 96 } else if (has_interface<PPB_Flash_12_1>()) { |
| 97 rv = PP_ToBool(get_interface<PPB_Flash_12_1>()->DrawGlyphs( |
| 98 instance.pp_instance(), |
| 99 image->pp_resource(), |
| 100 &font_desc.pp_font_description(), |
80 color, | 101 color, |
81 &position.pp_point(), | 102 &position.pp_point(), |
82 &clip.pp_rect(), | 103 &clip.pp_rect(), |
83 transformation, | 104 transformation, |
84 PP_FromBool(allow_subpixel_aa), | 105 PP_FromBool(allow_subpixel_aa), |
85 glyph_count, | 106 glyph_count, |
86 glyph_indices, | 107 glyph_indices, |
87 glyph_advances)); | 108 glyph_advances)); |
88 } else if (has_interface<PPB_Flash_12_0>()) { | 109 } else if (has_interface<PPB_Flash_12_0>()) { |
89 rv = PP_ToBool(get_interface<PPB_Flash_12_0>()->DrawGlyphs( | 110 rv = PP_ToBool(get_interface<PPB_Flash_12_0>()->DrawGlyphs( |
(...skipping 21 matching lines...) Expand all Loading... |
111 glyph_indices, | 132 glyph_indices, |
112 glyph_advances)); | 133 glyph_advances)); |
113 } | 134 } |
114 return rv; | 135 return rv; |
115 } | 136 } |
116 | 137 |
117 // static | 138 // static |
118 Var Flash::GetProxyForURL(const InstanceHandle& instance, | 139 Var Flash::GetProxyForURL(const InstanceHandle& instance, |
119 const std::string& url) { | 140 const std::string& url) { |
120 Var rv; | 141 Var rv; |
121 if (has_interface<PPB_Flash>()) { | 142 if (has_interface<PPB_Flash_12_2>()) { |
122 rv = Var(PASS_REF, | 143 rv = Var(PASS_REF, |
123 get_interface<PPB_Flash>()->GetProxyForURL(instance.pp_instance(), | 144 get_interface<PPB_Flash_12_2>()->GetProxyForURL( |
124 url.c_str())); | 145 instance.pp_instance(), url.c_str())); |
| 146 } else if (has_interface<PPB_Flash_12_1>()) { |
| 147 rv = Var(PASS_REF, |
| 148 get_interface<PPB_Flash_12_1>()->GetProxyForURL( |
| 149 instance.pp_instance(), url.c_str())); |
125 } else if (has_interface<PPB_Flash_12_0>()) { | 150 } else if (has_interface<PPB_Flash_12_0>()) { |
126 rv = Var(PASS_REF, | 151 rv = Var(PASS_REF, |
127 get_interface<PPB_Flash_12_0>()->GetProxyForURL( | 152 get_interface<PPB_Flash_12_0>()->GetProxyForURL( |
128 instance.pp_instance(), url.c_str())); | 153 instance.pp_instance(), url.c_str())); |
129 } else if (has_interface<PPB_Flash_11>()) { | 154 } else if (has_interface<PPB_Flash_11>()) { |
130 rv = Var(PASS_REF, | 155 rv = Var(PASS_REF, |
131 get_interface<PPB_Flash_11>()->GetProxyForURL( | 156 get_interface<PPB_Flash_11>()->GetProxyForURL( |
132 instance.pp_instance(), url.c_str())); | 157 instance.pp_instance(), url.c_str())); |
133 } | 158 } |
134 return rv; | 159 return rv; |
135 } | 160 } |
136 | 161 |
137 // static | 162 // static |
138 int32_t Flash::Navigate(const URLRequestInfo& request_info, | 163 int32_t Flash::Navigate(const URLRequestInfo& request_info, |
139 const std::string& target, | 164 const std::string& target, |
140 bool from_user_action) { | 165 bool from_user_action) { |
141 int32_t rv = PP_ERROR_FAILED; | 166 int32_t rv = PP_ERROR_FAILED; |
142 if (has_interface<PPB_Flash>()) { | 167 if (has_interface<PPB_Flash_12_2>()) { |
143 rv = get_interface<PPB_Flash>()->Navigate(request_info.pp_resource(), | 168 rv = get_interface<PPB_Flash_12_2>()->Navigate( |
144 target.c_str(), | 169 request_info.pp_resource(), |
145 PP_FromBool(from_user_action)); | 170 target.c_str(), |
| 171 PP_FromBool(from_user_action)); |
| 172 } else if (has_interface<PPB_Flash_12_1>()) { |
| 173 rv = get_interface<PPB_Flash_12_1>()->Navigate( |
| 174 request_info.pp_resource(), |
| 175 target.c_str(), |
| 176 PP_FromBool(from_user_action)); |
146 } else if (has_interface<PPB_Flash_12_0>()) { | 177 } else if (has_interface<PPB_Flash_12_0>()) { |
147 rv = get_interface<PPB_Flash_12_0>()->Navigate( | 178 rv = get_interface<PPB_Flash_12_0>()->Navigate( |
148 request_info.pp_resource(), | 179 request_info.pp_resource(), |
149 target.c_str(), | 180 target.c_str(), |
150 PP_FromBool(from_user_action)); | 181 PP_FromBool(from_user_action)); |
151 } else if (has_interface<PPB_Flash_11>()) { | 182 } else if (has_interface<PPB_Flash_11>()) { |
152 rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(), | 183 rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(), |
153 target.c_str(), | 184 target.c_str(), |
154 from_user_action); | 185 from_user_action); |
155 } | 186 } |
156 return rv; | 187 return rv; |
157 } | 188 } |
158 | 189 |
159 // static | 190 // static |
160 void Flash::RunMessageLoop(const InstanceHandle& instance) { | 191 void Flash::RunMessageLoop(const InstanceHandle& instance) { |
161 if (has_interface<PPB_Flash>()) | 192 if (has_interface<PPB_Flash_12_2>()) |
162 get_interface<PPB_Flash>()->RunMessageLoop(instance.pp_instance()); | 193 get_interface<PPB_Flash_12_2>()->RunMessageLoop(instance.pp_instance()); |
| 194 else if (has_interface<PPB_Flash_12_1>()) |
| 195 get_interface<PPB_Flash_12_1>()->RunMessageLoop(instance.pp_instance()); |
163 else if (has_interface<PPB_Flash_12_0>()) | 196 else if (has_interface<PPB_Flash_12_0>()) |
164 get_interface<PPB_Flash_12_0>()->RunMessageLoop(instance.pp_instance()); | 197 get_interface<PPB_Flash_12_0>()->RunMessageLoop(instance.pp_instance()); |
165 else if (has_interface<PPB_Flash_11>()) | 198 else if (has_interface<PPB_Flash_11>()) |
166 get_interface<PPB_Flash_11>()->RunMessageLoop(instance.pp_instance()); | 199 get_interface<PPB_Flash_11>()->RunMessageLoop(instance.pp_instance()); |
167 } | 200 } |
168 | 201 |
169 // static | 202 // static |
170 void Flash::QuitMessageLoop(const InstanceHandle& instance) { | 203 void Flash::QuitMessageLoop(const InstanceHandle& instance) { |
171 if (has_interface<PPB_Flash>()) | 204 if (has_interface<PPB_Flash_12_2>()) |
172 get_interface<PPB_Flash>()->QuitMessageLoop(instance.pp_instance()); | 205 get_interface<PPB_Flash_12_2>()->QuitMessageLoop(instance.pp_instance()); |
| 206 else if (has_interface<PPB_Flash_12_1>()) |
| 207 get_interface<PPB_Flash_12_1>()->QuitMessageLoop(instance.pp_instance()); |
173 else if (has_interface<PPB_Flash_12_0>()) | 208 else if (has_interface<PPB_Flash_12_0>()) |
174 get_interface<PPB_Flash_12_0>()->QuitMessageLoop(instance.pp_instance()); | 209 get_interface<PPB_Flash_12_0>()->QuitMessageLoop(instance.pp_instance()); |
175 else if (has_interface<PPB_Flash_11>()) | 210 else if (has_interface<PPB_Flash_11>()) |
176 get_interface<PPB_Flash_11>()->QuitMessageLoop(instance.pp_instance()); | 211 get_interface<PPB_Flash_11>()->QuitMessageLoop(instance.pp_instance()); |
177 } | 212 } |
178 | 213 |
179 // static | 214 // static |
180 double Flash::GetLocalTimeZoneOffset(const InstanceHandle& instance, | 215 double Flash::GetLocalTimeZoneOffset(const InstanceHandle& instance, |
181 PP_Time t) { | 216 PP_Time t) { |
182 double rv = 0; | 217 double rv = 0; |
183 if (has_interface<PPB_Flash>()) { | 218 if (has_interface<PPB_Flash_12_2>()) { |
184 rv = get_interface<PPB_Flash>()->GetLocalTimeZoneOffset( | 219 rv = get_interface<PPB_Flash_12_2>()->GetLocalTimeZoneOffset( |
| 220 instance.pp_instance(), t); |
| 221 } else if (has_interface<PPB_Flash_12_1>()) { |
| 222 rv = get_interface<PPB_Flash_12_1>()->GetLocalTimeZoneOffset( |
185 instance.pp_instance(), t); | 223 instance.pp_instance(), t); |
186 } else if (has_interface<PPB_Flash_12_0>()) { | 224 } else if (has_interface<PPB_Flash_12_0>()) { |
187 rv = get_interface<PPB_Flash_12_0>()->GetLocalTimeZoneOffset( | 225 rv = get_interface<PPB_Flash_12_0>()->GetLocalTimeZoneOffset( |
188 instance.pp_instance(), t); | 226 instance.pp_instance(), t); |
189 } else if (has_interface<PPB_Flash_11>()) { | 227 } else if (has_interface<PPB_Flash_11>()) { |
190 rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset( | 228 rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset( |
191 instance.pp_instance(), t); | 229 instance.pp_instance(), t); |
192 } | 230 } |
193 return rv; | 231 return rv; |
194 } | 232 } |
195 | 233 |
196 // static | 234 // static |
197 Var Flash::GetCommandLineArgs(Module* module) { | 235 Var Flash::GetCommandLineArgs(Module* module) { |
198 Var rv; | 236 Var rv; |
199 if (has_interface<PPB_Flash>()) { | 237 if (has_interface<PPB_Flash_12_2>()) { |
200 rv = Var(PASS_REF, | 238 rv = Var(PASS_REF, |
201 get_interface<PPB_Flash>()->GetCommandLineArgs( | 239 get_interface<PPB_Flash_12_2>()->GetCommandLineArgs( |
| 240 module->pp_module())); |
| 241 } else if (has_interface<PPB_Flash_12_1>()) { |
| 242 rv = Var(PASS_REF, |
| 243 get_interface<PPB_Flash_12_1>()->GetCommandLineArgs( |
202 module->pp_module())); | 244 module->pp_module())); |
203 } else if (has_interface<PPB_Flash_12_0>()) { | 245 } else if (has_interface<PPB_Flash_12_0>()) { |
204 rv = Var(PASS_REF, | 246 rv = Var(PASS_REF, |
205 get_interface<PPB_Flash_12_0>()->GetCommandLineArgs( | 247 get_interface<PPB_Flash_12_0>()->GetCommandLineArgs( |
206 module->pp_module())); | 248 module->pp_module())); |
207 } else if (has_interface<PPB_Flash_11>()) { | 249 } else if (has_interface<PPB_Flash_11>()) { |
208 rv = Var(PASS_REF, | 250 rv = Var(PASS_REF, |
209 get_interface<PPB_Flash_11>()->GetCommandLineArgs( | 251 get_interface<PPB_Flash_11>()->GetCommandLineArgs( |
210 module->pp_module())); | 252 module->pp_module())); |
211 } | 253 } |
212 return rv; | 254 return rv; |
213 } | 255 } |
214 | 256 |
215 // static | 257 // static |
216 void Flash::PreloadFontWin(const void* logfontw) { | 258 void Flash::PreloadFontWin(const void* logfontw) { |
217 if (has_interface<PPB_Flash>()) | 259 if (has_interface<PPB_Flash_12_2>()) |
218 get_interface<PPB_Flash>()->PreloadFontWin(logfontw); | 260 get_interface<PPB_Flash_12_2>()->PreloadFontWin(logfontw); |
| 261 else if (has_interface<PPB_Flash_12_1>()) |
| 262 get_interface<PPB_Flash_12_1>()->PreloadFontWin(logfontw); |
219 else if (has_interface<PPB_Flash_12_0>()) | 263 else if (has_interface<PPB_Flash_12_0>()) |
220 get_interface<PPB_Flash_12_0>()->PreloadFontWin(logfontw); | 264 get_interface<PPB_Flash_12_0>()->PreloadFontWin(logfontw); |
221 } | 265 } |
222 | 266 |
223 // static | 267 // static |
224 bool Flash::IsRectTopmost(const InstanceHandle& instance, const Rect& rect) { | 268 bool Flash::IsRectTopmost(const InstanceHandle& instance, const Rect& rect) { |
225 bool rv = false; | 269 bool rv = false; |
226 if (has_interface<PPB_Flash>()) { | 270 if (has_interface<PPB_Flash_12_2>()) { |
227 rv = PP_ToBool(get_interface<PPB_Flash>()->IsRectTopmost( | 271 rv = PP_ToBool(get_interface<PPB_Flash_12_2>()->IsRectTopmost( |
| 272 instance.pp_instance(), &rect.pp_rect())); |
| 273 } else if (has_interface<PPB_Flash_12_1>()) { |
| 274 rv = PP_ToBool(get_interface<PPB_Flash_12_1>()->IsRectTopmost( |
228 instance.pp_instance(), &rect.pp_rect())); | 275 instance.pp_instance(), &rect.pp_rect())); |
229 } | 276 } |
230 return rv; | 277 return rv; |
231 } | 278 } |
232 | 279 |
233 // static | 280 // static |
234 int32_t Flash::InvokePrinting(const InstanceHandle& instance) { | 281 int32_t Flash::InvokePrinting(const InstanceHandle& instance) { |
235 int32_t rv = PP_ERROR_NOTSUPPORTED; | 282 int32_t rv = PP_ERROR_NOTSUPPORTED; |
236 if (has_interface<PPB_Flash>()) | 283 if (has_interface<PPB_Flash_12_2>()) { |
237 rv = get_interface<PPB_Flash>()->InvokePrinting(instance.pp_instance()); | 284 rv = get_interface<PPB_Flash_12_2>()->InvokePrinting( |
| 285 instance.pp_instance()); |
| 286 } else if (has_interface<PPB_Flash_12_1>()) { |
| 287 rv = get_interface<PPB_Flash_12_1>()->InvokePrinting( |
| 288 instance.pp_instance()); |
| 289 } |
238 return rv; | 290 return rv; |
239 } | 291 } |
240 | 292 |
241 // static | 293 // static |
242 void Flash::UpdateActivity(const InstanceHandle& instance) { | 294 void Flash::UpdateActivity(const InstanceHandle& instance) { |
243 if (has_interface<PPB_Flash>()) | 295 if (has_interface<PPB_Flash_12_2>()) |
244 get_interface<PPB_Flash>()->UpdateActivity(instance.pp_instance()); | 296 get_interface<PPB_Flash_12_2>()->UpdateActivity(instance.pp_instance()); |
| 297 if (has_interface<PPB_Flash_12_1>()) |
| 298 get_interface<PPB_Flash_12_1>()->UpdateActivity(instance.pp_instance()); |
| 299 } |
| 300 |
| 301 // static |
| 302 Var Flash::GetDeviceID(const InstanceHandle& instance) { |
| 303 if (has_interface<PPB_Flash_12_2>()) { |
| 304 return Var( |
| 305 PASS_REF, |
| 306 get_interface<PPB_Flash_12_2>()->GetDeviceID(instance.pp_instance())); |
| 307 } |
| 308 return Var(); |
245 } | 309 } |
246 | 310 |
247 } // namespace flash | 311 } // namespace flash |
248 } // namespace pp | 312 } // namespace pp |
OLD | NEW |