Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: ppapi/cpp/private/flash.cc

Issue 11411102: Deprecate and remove unused PPB_Flash functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string.h> 7 #include <string.h>
8 8
9 #include "ppapi/c/pp_bool.h" 9 #include "ppapi/c/pp_bool.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/cpp/dev/device_ref_dev.h" 11 #include "ppapi/cpp/dev/device_ref_dev.h"
12 #include "ppapi/cpp/dev/font_dev.h" 12 #include "ppapi/cpp/dev/font_dev.h"
13 #include "ppapi/cpp/dev/video_capture_dev.h" 13 #include "ppapi/cpp/dev/video_capture_dev.h"
14 #include "ppapi/cpp/image_data.h" 14 #include "ppapi/cpp/image_data.h"
15 #include "ppapi/cpp/instance_handle.h" 15 #include "ppapi/cpp/instance_handle.h"
16 #include "ppapi/cpp/module.h" 16 #include "ppapi/cpp/module.h"
17 #include "ppapi/cpp/module_impl.h" 17 #include "ppapi/cpp/module_impl.h"
18 #include "ppapi/cpp/point.h" 18 #include "ppapi/cpp/point.h"
19 #include "ppapi/cpp/rect.h" 19 #include "ppapi/cpp/rect.h"
20 #include "ppapi/cpp/url_request_info.h" 20 #include "ppapi/cpp/url_request_info.h"
21 #include "ppapi/cpp/var.h" 21 #include "ppapi/cpp/var.h"
22 #include "ppapi/c/private/ppb_flash.h" 22 #include "ppapi/c/private/ppb_flash.h"
23 #include "ppapi/c/private/ppb_flash_print.h" 23 #include "ppapi/c/private/ppb_flash_print.h"
24 24
25 namespace pp { 25 namespace pp {
26 26
27 namespace { 27 namespace {
28 28
29 template <> const char* interface_name<PPB_Flash_13_0>() {
30 return PPB_FLASH_INTERFACE_13_0;
31 }
32
29 template <> const char* interface_name<PPB_Flash_12_6>() { 33 template <> const char* interface_name<PPB_Flash_12_6>() {
30 return PPB_FLASH_INTERFACE_12_6; 34 return PPB_FLASH_INTERFACE_12_6;
31 } 35 }
32 36
33 template <> const char* interface_name<PPB_Flash_12_5>() { 37 template <> const char* interface_name<PPB_Flash_12_5>() {
34 return PPB_FLASH_INTERFACE_12_5; 38 return PPB_FLASH_INTERFACE_12_5;
35 } 39 }
36 40
37 template <> const char* interface_name<PPB_Flash_12_4>() { 41 template <> const char* interface_name<PPB_Flash_12_4>() {
38 return PPB_FLASH_INTERFACE_12_4; 42 return PPB_FLASH_INTERFACE_12_4;
39 } 43 }
40 44
41 template <> const char* interface_name<PPB_Flash_12_3>() {
42 return PPB_FLASH_INTERFACE_12_3;
43 }
44
45 template <> const char* interface_name<PPB_Flash_Print_1_0>() { 45 template <> const char* interface_name<PPB_Flash_Print_1_0>() {
46 return PPB_FLASH_PRINT_INTERFACE_1_0; 46 return PPB_FLASH_PRINT_INTERFACE_1_0;
47 } 47 }
48 48
49 // The combined Flash interface is all Flash v12.* interfaces. All v12 49 // The combined Flash interface is all Flash v12.* interfaces. All v12
50 // interfaces just append one or more functions to the previous one, so we can 50 // interfaces just append one or more functions to the previous one, so we can
51 // have this meta one at the most recent version. Function pointers will be 51 // have this meta one at the most recent version. Function pointers will be
52 // null if they're not supported on the current Chrome version. 52 // null if they're not supported on the current Chrome version.
53 bool initialized_combined_interface = false; 53 bool initialized_combined_interface = false;
54 PPB_Flash flash_12_combined_interface; 54 PPB_Flash_12_6 flash_12_combined_interface;
55 55
56 // Makes sure that the most recent version is loaded into the combined 56 // Makes sure that the most recent version is loaded into the combined
57 // interface struct above. Any unsupported functions will be NULL. If there 57 // interface struct above. Any unsupported functions will be NULL. If there
58 // is no Flash interface supported, all functions will be NULL. 58 // is no Flash interface supported, all functions will be NULL.
59 void InitializeCombinedInterface() { 59 void InitializeCombinedInterface() {
60 if (initialized_combined_interface) 60 if (initialized_combined_interface)
61 return; 61 return;
62 if (has_interface<PPB_Flash_12_6>()) { 62 if (has_interface<PPB_Flash_12_6>()) {
63 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_6>(), 63 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_6>(),
64 sizeof(PPB_Flash_12_6)); 64 sizeof(PPB_Flash_12_6));
65 } else if (has_interface<PPB_Flash_12_5>()) { 65 } else if (has_interface<PPB_Flash_12_5>()) {
66 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_5>(), 66 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_5>(),
67 sizeof(PPB_Flash_12_5)); 67 sizeof(PPB_Flash_12_5));
68 } else if (has_interface<PPB_Flash_12_4>()) { 68 } else if (has_interface<PPB_Flash_12_4>()) {
69 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(), 69 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(),
70 sizeof(PPB_Flash_12_4)); 70 sizeof(PPB_Flash_12_4));
71 } else if (has_interface<PPB_Flash_12_3>()) {
72 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_3>(),
73 sizeof(PPB_Flash_12_3));
74 } 71 }
75 initialized_combined_interface = true; 72 initialized_combined_interface = true;
76 } 73 }
77 74
78 } // namespace 75 } // namespace
79 76
80 namespace flash { 77 namespace flash {
81 78
82 // static 79 // static
83 bool Flash::IsAvailable() { 80 bool Flash::IsAvailable() {
84 return has_interface<PPB_Flash_12_6>() || 81 return has_interface<PPB_Flash_13_0>() ||
82 has_interface<PPB_Flash_12_6>() ||
85 has_interface<PPB_Flash_12_5>() || 83 has_interface<PPB_Flash_12_5>() ||
86 has_interface<PPB_Flash_12_4>() || 84 has_interface<PPB_Flash_12_4>();
87 has_interface<PPB_Flash_12_3>();
88 } 85 }
89 86
90 // static 87 // static
91 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance, 88 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance,
92 bool on_top) { 89 bool on_top) {
93 InitializeCombinedInterface(); 90 InitializeCombinedInterface();
94 if (flash_12_combined_interface.SetInstanceAlwaysOnTop) { 91 if (has_interface<PPB_Flash_13_0>()) {
92 get_interface<PPB_Flash_13_0>()->SetInstanceAlwaysOnTop(
93 instance.pp_instance(), PP_FromBool(on_top));
94 } else if (flash_12_combined_interface.SetInstanceAlwaysOnTop) {
95 flash_12_combined_interface.SetInstanceAlwaysOnTop( 95 flash_12_combined_interface.SetInstanceAlwaysOnTop(
96 instance.pp_instance(), PP_FromBool(on_top)); 96 instance.pp_instance(), PP_FromBool(on_top));
97 } 97 }
98 } 98 }
99 99
100 // static 100 // static
101 bool Flash::DrawGlyphs(const InstanceHandle& instance, 101 bool Flash::DrawGlyphs(const InstanceHandle& instance,
102 ImageData* image, 102 ImageData* image,
103 const FontDescription_Dev& font_desc, 103 const FontDescription_Dev& font_desc,
104 uint32_t color, 104 uint32_t color,
105 const Point& position, 105 const Point& position,
106 const Rect& clip, 106 const Rect& clip,
107 const float transformation[3][3], 107 const float transformation[3][3],
108 bool allow_subpixel_aa, 108 bool allow_subpixel_aa,
109 uint32_t glyph_count, 109 uint32_t glyph_count,
110 const uint16_t glyph_indices[], 110 const uint16_t glyph_indices[],
111 const PP_Point glyph_advances[]) { 111 const PP_Point glyph_advances[]) {
112 InitializeCombinedInterface(); 112 InitializeCombinedInterface();
113 if (has_interface<PPB_Flash_13_0>()) {
114 return PP_ToBool(get_interface<PPB_Flash_13_0>()->DrawGlyphs(
115 instance.pp_instance(),
116 image->pp_resource(),
117 &font_desc.pp_font_description(),
118 color,
119 &position.pp_point(),
120 &clip.pp_rect(),
121 transformation,
122 PP_FromBool(allow_subpixel_aa),
123 glyph_count,
124 glyph_indices,
125 glyph_advances));
126 }
113 if (flash_12_combined_interface.DrawGlyphs) { 127 if (flash_12_combined_interface.DrawGlyphs) {
114 return PP_ToBool(flash_12_combined_interface.DrawGlyphs( 128 return PP_ToBool(flash_12_combined_interface.DrawGlyphs(
115 instance.pp_instance(), 129 instance.pp_instance(),
116 image->pp_resource(), 130 image->pp_resource(),
117 &font_desc.pp_font_description(), 131 &font_desc.pp_font_description(),
118 color, 132 color,
119 &position.pp_point(), 133 &position.pp_point(),
120 &clip.pp_rect(), 134 &clip.pp_rect(),
121 transformation, 135 transformation,
122 PP_FromBool(allow_subpixel_aa), 136 PP_FromBool(allow_subpixel_aa),
123 glyph_count, 137 glyph_count,
124 glyph_indices, 138 glyph_indices,
125 glyph_advances)); 139 glyph_advances));
126 } 140 }
127 return false; 141 return false;
128 } 142 }
129 143
130 // static 144 // static
131 Var Flash::GetProxyForURL(const InstanceHandle& instance, 145 Var Flash::GetProxyForURL(const InstanceHandle& instance,
132 const std::string& url) { 146 const std::string& url) {
133 InitializeCombinedInterface(); 147 InitializeCombinedInterface();
148 if (has_interface<PPB_Flash_13_0>()) {
149 return Var(PASS_REF, get_interface<PPB_Flash_13_0>()->GetProxyForURL(
150 instance.pp_instance(), url.c_str()));
151 }
134 if (flash_12_combined_interface.GetProxyForURL) { 152 if (flash_12_combined_interface.GetProxyForURL) {
135 return Var(PASS_REF, flash_12_combined_interface.GetProxyForURL( 153 return Var(PASS_REF, flash_12_combined_interface.GetProxyForURL(
136 instance.pp_instance(), url.c_str())); 154 instance.pp_instance(), url.c_str()));
137 } 155 }
138 return Var(); 156 return Var();
139 } 157 }
140 158
141 // static 159 // static
142 int32_t Flash::Navigate(const URLRequestInfo& request_info, 160 int32_t Flash::Navigate(const URLRequestInfo& request_info,
143 const std::string& target, 161 const std::string& target,
144 bool from_user_action) { 162 bool from_user_action) {
145 InitializeCombinedInterface(); 163 InitializeCombinedInterface();
164 if (has_interface<PPB_Flash_13_0>()) {
165 return get_interface<PPB_Flash_13_0>()->Navigate(
166 request_info.pp_resource(),
167 target.c_str(),
168 PP_FromBool(from_user_action));
169 }
146 if (flash_12_combined_interface.Navigate) { 170 if (flash_12_combined_interface.Navigate) {
147 return flash_12_combined_interface.Navigate( 171 return flash_12_combined_interface.Navigate(
148 request_info.pp_resource(), 172 request_info.pp_resource(),
149 target.c_str(), 173 target.c_str(),
150 PP_FromBool(from_user_action)); 174 PP_FromBool(from_user_action));
151 } 175 }
152 return PP_ERROR_FAILED; 176 return PP_ERROR_FAILED;
153 } 177 }
154 178
155 // static 179 // static
156 void Flash::RunMessageLoop(const InstanceHandle& instance) {
157 InitializeCombinedInterface();
158 if (flash_12_combined_interface.RunMessageLoop)
159 flash_12_combined_interface.RunMessageLoop(instance.pp_instance());
160 }
161
162 // static
163 void Flash::QuitMessageLoop(const InstanceHandle& instance) {
164 InitializeCombinedInterface();
165 if (flash_12_combined_interface.QuitMessageLoop)
166 flash_12_combined_interface.QuitMessageLoop(instance.pp_instance());
167 }
168
169 // static
170 double Flash::GetLocalTimeZoneOffset(const InstanceHandle& instance, 180 double Flash::GetLocalTimeZoneOffset(const InstanceHandle& instance,
171 PP_Time t) { 181 PP_Time t) {
172 InitializeCombinedInterface(); 182 InitializeCombinedInterface();
183 if (has_interface<PPB_Flash_13_0>()) {
184 return get_interface<PPB_Flash_13_0>()->GetLocalTimeZoneOffset(
185 instance.pp_instance(), t);
186 }
173 if (flash_12_combined_interface.GetLocalTimeZoneOffset) { 187 if (flash_12_combined_interface.GetLocalTimeZoneOffset) {
174 return flash_12_combined_interface.GetLocalTimeZoneOffset( 188 return flash_12_combined_interface.GetLocalTimeZoneOffset(
175 instance.pp_instance(), t); 189 instance.pp_instance(), t);
176 } 190 }
177 return 0.0; 191 return 0.0;
178 } 192 }
179 193
180 // static 194 // static
181 Var Flash::GetCommandLineArgs(Module* module) { 195 Var Flash::GetCommandLineArgs(Module* module) {
182 InitializeCombinedInterface(); 196 InitializeCombinedInterface();
197 if (has_interface<PPB_Flash_13_0>()) {
198 return Var(PASS_REF, get_interface<PPB_Flash_13_0>()->GetCommandLineArgs(
199 module->pp_module()));
200 }
183 if (flash_12_combined_interface.GetCommandLineArgs) { 201 if (flash_12_combined_interface.GetCommandLineArgs) {
184 return Var( 202 return Var(
185 PASS_REF, 203 PASS_REF,
186 flash_12_combined_interface.GetCommandLineArgs(module->pp_module())); 204 flash_12_combined_interface.GetCommandLineArgs(module->pp_module()));
187 } 205 }
188 return Var(); 206 return Var();
189 } 207 }
190 208
191 // static 209 // static
192 void Flash::PreloadFontWin(const void* logfontw) { 210 void Flash::PreloadFontWin(const void* logfontw) {
193 InitializeCombinedInterface(); 211 InitializeCombinedInterface();
212 if (has_interface<PPB_Flash_13_0>())
213 return get_interface<PPB_Flash_13_0>()->PreloadFontWin(logfontw);
194 if (flash_12_combined_interface.PreloadFontWin) 214 if (flash_12_combined_interface.PreloadFontWin)
195 return flash_12_combined_interface.PreloadFontWin(logfontw); 215 return flash_12_combined_interface.PreloadFontWin(logfontw);
196 } 216 }
197 217
198 // static 218 // static
199 bool Flash::IsRectTopmost(const InstanceHandle& instance, const Rect& rect) { 219 bool Flash::IsRectTopmost(const InstanceHandle& instance, const Rect& rect) {
200 InitializeCombinedInterface(); 220 InitializeCombinedInterface();
221 if (has_interface<PPB_Flash_13_0>()) {
222 return PP_ToBool(get_interface<PPB_Flash_13_0>()->IsRectTopmost(
223 instance.pp_instance(), &rect.pp_rect()));
224 }
201 if (flash_12_combined_interface.IsRectTopmost) { 225 if (flash_12_combined_interface.IsRectTopmost) {
202 return PP_ToBool(flash_12_combined_interface.IsRectTopmost( 226 return PP_ToBool(flash_12_combined_interface.IsRectTopmost(
203 instance.pp_instance(), &rect.pp_rect())); 227 instance.pp_instance(), &rect.pp_rect()));
204 } 228 }
205 return false; 229 return false;
206 } 230 }
207 231
208 // static 232 // static
209 void Flash::UpdateActivity(const InstanceHandle& instance) { 233 void Flash::UpdateActivity(const InstanceHandle& instance) {
210 InitializeCombinedInterface(); 234 InitializeCombinedInterface();
211 if (flash_12_combined_interface.UpdateActivity) 235 if (has_interface<PPB_Flash_13_0>())
236 get_interface<PPB_Flash_13_0>()->UpdateActivity(instance.pp_instance());
237 else if (flash_12_combined_interface.UpdateActivity)
212 flash_12_combined_interface.UpdateActivity(instance.pp_instance()); 238 flash_12_combined_interface.UpdateActivity(instance.pp_instance());
213 } 239 }
214 240
215 // static 241 // static
216 Var Flash::GetDeviceID(const InstanceHandle& instance) {
217 InitializeCombinedInterface();
218 if (flash_12_combined_interface.GetDeviceID) {
219 return Var(PASS_REF,
220 flash_12_combined_interface.GetDeviceID(instance.pp_instance()));
221 }
222 return Var();
223 }
224
225 // static
226 Var Flash::GetSetting(const InstanceHandle& instance, PP_FlashSetting setting) { 242 Var Flash::GetSetting(const InstanceHandle& instance, PP_FlashSetting setting) {
227 InitializeCombinedInterface(); 243 InitializeCombinedInterface();
244 if (has_interface<PPB_Flash_13_0>()) {
245 return Var(PASS_REF, get_interface<PPB_Flash_13_0>()->GetSetting(
246 instance.pp_instance(), setting));
247 }
228 if (flash_12_combined_interface.GetSetting) { 248 if (flash_12_combined_interface.GetSetting) {
229 return Var(PASS_REF, 249 return Var(PASS_REF,
230 flash_12_combined_interface.GetSetting(instance.pp_instance(), 250 flash_12_combined_interface.GetSetting(instance.pp_instance(),
231 setting)); 251 setting));
232 } 252 }
233 if (flash_12_combined_interface.GetSettingInt) {
234 // All the |PP_FlashSetting|s supported by |GetSettingInt()| return
235 // "booleans" (0 for false, 1 for true, -1 for undefined/unsupported/error).
236 int32_t result = flash_12_combined_interface.GetSettingInt(
237 instance.pp_instance(), setting);
238 if (result == 0 || result == 1)
239 return Var(!!result);
240 }
241 253
242 return Var(); 254 return Var();
243 } 255 }
244 256
245 // static 257 // static
246 bool Flash::SetCrashData(const InstanceHandle& instance, 258 bool Flash::SetCrashData(const InstanceHandle& instance,
247 PP_FlashCrashKey key, 259 PP_FlashCrashKey key,
248 const pp::Var& value) { 260 const pp::Var& value) {
249 InitializeCombinedInterface(); 261 InitializeCombinedInterface();
262 if (has_interface<PPB_Flash_13_0>()) {
263 return PP_ToBool(get_interface<PPB_Flash_13_0>()->SetCrashData(
264 instance.pp_instance(), key, value.pp_var()));
265 }
250 if (flash_12_combined_interface.SetCrashData) { 266 if (flash_12_combined_interface.SetCrashData) {
251 return PP_ToBool( 267 return PP_ToBool(
252 flash_12_combined_interface.SetCrashData(instance.pp_instance(), 268 flash_12_combined_interface.SetCrashData(instance.pp_instance(),
253 key, value.pp_var())); 269 key, value.pp_var()));
254 } 270 }
255 return false; 271 return false;
256 } 272 }
257 273
258 // static 274 // static
259 int32_t Flash::EnumerateVideoCaptureDevices( 275 int32_t Flash::EnumerateVideoCaptureDevices(
260 const InstanceHandle& instance, 276 const InstanceHandle& instance,
261 const VideoCapture_Dev& video_capture, 277 const VideoCapture_Dev& video_capture,
262 std::vector<DeviceRef_Dev>* devices_out) { 278 std::vector<DeviceRef_Dev>* devices_out) {
263 InitializeCombinedInterface(); 279 InitializeCombinedInterface();
280 if (has_interface<PPB_Flash_13_0>()) {
281 ResourceArrayOutputAdapter<DeviceRef_Dev> adapter(devices_out);
282 return get_interface<PPB_Flash_13_0>()->EnumerateVideoCaptureDevices(
283 instance.pp_instance(),
284 video_capture.pp_resource(),
285 adapter.pp_array_output());
286 }
264 if (flash_12_combined_interface.EnumerateVideoCaptureDevices) { 287 if (flash_12_combined_interface.EnumerateVideoCaptureDevices) {
265 ResourceArrayOutputAdapter<DeviceRef_Dev> adapter(devices_out); 288 ResourceArrayOutputAdapter<DeviceRef_Dev> adapter(devices_out);
266 return flash_12_combined_interface.EnumerateVideoCaptureDevices( 289 return flash_12_combined_interface.EnumerateVideoCaptureDevices(
267 instance.pp_instance(), 290 instance.pp_instance(),
268 video_capture.pp_resource(), 291 video_capture.pp_resource(),
269 adapter.pp_array_output()); 292 adapter.pp_array_output());
270 } 293 }
271 return PP_ERROR_FAILED; 294 return PP_ERROR_FAILED;
272 } 295 }
273 296
274 // static 297 // static
275 bool Flash::InvokePrinting(const InstanceHandle& instance) { 298 bool Flash::InvokePrinting(const InstanceHandle& instance) {
276 if (has_interface<PPB_Flash_Print_1_0>()) { 299 if (has_interface<PPB_Flash_Print_1_0>()) {
277 get_interface<PPB_Flash_Print_1_0>()->InvokePrinting( 300 get_interface<PPB_Flash_Print_1_0>()->InvokePrinting(
278 instance.pp_instance()); 301 instance.pp_instance());
279 return true; 302 return true;
280 } 303 }
281 return false; 304 return false;
282 } 305 }
283 306
284 } // namespace flash 307 } // namespace flash
285 } // namespace pp 308 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/c/private/ppb_flash.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698