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

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

Issue 10681006: Add ppapi interface for setting crash data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months 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
« no previous file with comments | « ppapi/cpp/private/flash.h ('k') | ppapi/proxy/plugin_proxy_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/font_dev.h" 11 #include "ppapi/cpp/dev/font_dev.h"
12 #include "ppapi/cpp/image_data.h" 12 #include "ppapi/cpp/image_data.h"
13 #include "ppapi/cpp/instance_handle.h" 13 #include "ppapi/cpp/instance_handle.h"
14 #include "ppapi/cpp/module.h" 14 #include "ppapi/cpp/module.h"
15 #include "ppapi/cpp/module_impl.h" 15 #include "ppapi/cpp/module_impl.h"
16 #include "ppapi/cpp/point.h" 16 #include "ppapi/cpp/point.h"
17 #include "ppapi/cpp/rect.h" 17 #include "ppapi/cpp/rect.h"
18 #include "ppapi/cpp/url_request_info.h" 18 #include "ppapi/cpp/url_request_info.h"
19 #include "ppapi/cpp/var.h" 19 #include "ppapi/cpp/var.h"
20 #include "ppapi/c/private/ppb_flash.h" 20 #include "ppapi/c/private/ppb_flash.h"
21 #include "ppapi/c/private/ppb_flash_print.h" 21 #include "ppapi/c/private/ppb_flash_print.h"
22 22
23 namespace pp { 23 namespace pp {
24 24
25 namespace { 25 namespace {
26 26
27 template <> const char* interface_name<PPB_Flash_12_5>() {
28 return PPB_FLASH_INTERFACE_12_5;
29 }
30
27 template <> const char* interface_name<PPB_Flash_12_4>() { 31 template <> const char* interface_name<PPB_Flash_12_4>() {
28 return PPB_FLASH_INTERFACE_12_4; 32 return PPB_FLASH_INTERFACE_12_4;
29 } 33 }
30 34
31 template <> const char* interface_name<PPB_Flash_12_3>() { 35 template <> const char* interface_name<PPB_Flash_12_3>() {
32 return PPB_FLASH_INTERFACE_12_3; 36 return PPB_FLASH_INTERFACE_12_3;
33 } 37 }
34 38
35 template <> const char* interface_name<PPB_Flash_12_2>() { 39 template <> const char* interface_name<PPB_Flash_12_2>() {
36 return PPB_FLASH_INTERFACE_12_2; 40 return PPB_FLASH_INTERFACE_12_2;
(...skipping 17 matching lines...) Expand all
54 // null if they're not supported on the current Chrome version. 58 // null if they're not supported on the current Chrome version.
55 bool initialized_combined_interface = false; 59 bool initialized_combined_interface = false;
56 PPB_Flash flash_12_combined_interface; 60 PPB_Flash flash_12_combined_interface;
57 61
58 // Makes sure that the most recent version is loaded into the combined 62 // Makes sure that the most recent version is loaded into the combined
59 // interface struct above. Any unsupported functions will be NULL. If there 63 // interface struct above. Any unsupported functions will be NULL. If there
60 // is no Flash interface supported, all functions will be NULL. 64 // is no Flash interface supported, all functions will be NULL.
61 void InitializeCombinedInterface() { 65 void InitializeCombinedInterface() {
62 if (initialized_combined_interface) 66 if (initialized_combined_interface)
63 return; 67 return;
64 if (has_interface<PPB_Flash_12_4>()) { 68 if (has_interface<PPB_Flash_12_5>()) {
69 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_5>(),
70 sizeof(PPB_Flash_12_5));
71 } else if (has_interface<PPB_Flash_12_4>()) {
65 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(), 72 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(),
66 sizeof(PPB_Flash_12_4)); 73 sizeof(PPB_Flash_12_4));
67 } else if (has_interface<PPB_Flash_12_3>()) { 74 } else if (has_interface<PPB_Flash_12_3>()) {
68 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_3>(), 75 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_3>(),
69 sizeof(PPB_Flash_12_3)); 76 sizeof(PPB_Flash_12_3));
70 } else if (has_interface<PPB_Flash_12_2>()) { 77 } else if (has_interface<PPB_Flash_12_2>()) {
71 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_2>(), 78 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_2>(),
72 sizeof(PPB_Flash_12_2)); 79 sizeof(PPB_Flash_12_2));
73 } else if (has_interface<PPB_Flash_12_1>()) { 80 } else if (has_interface<PPB_Flash_12_1>()) {
74 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_1>(), 81 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_1>(),
75 sizeof(PPB_Flash_12_1)); 82 sizeof(PPB_Flash_12_1));
76 } else if (has_interface<PPB_Flash_12_0>()) { 83 } else if (has_interface<PPB_Flash_12_0>()) {
77 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_0>(), 84 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_0>(),
78 sizeof(PPB_Flash_12_0)); 85 sizeof(PPB_Flash_12_0));
79 } 86 }
80 initialized_combined_interface = true; 87 initialized_combined_interface = true;
81 } 88 }
82 89
83 } // namespace 90 } // namespace
84 91
85 namespace flash { 92 namespace flash {
86 93
87 // static 94 // static
88 bool Flash::IsAvailable() { 95 bool Flash::IsAvailable() {
89 return has_interface<PPB_Flash_12_4>() || 96 return has_interface<PPB_Flash_12_5>() ||
97 has_interface<PPB_Flash_12_4>() ||
90 has_interface<PPB_Flash_12_3>() || 98 has_interface<PPB_Flash_12_3>() ||
91 has_interface<PPB_Flash_12_2>() || 99 has_interface<PPB_Flash_12_2>() ||
92 has_interface<PPB_Flash_12_1>() || 100 has_interface<PPB_Flash_12_1>() ||
93 has_interface<PPB_Flash_12_0>(); 101 has_interface<PPB_Flash_12_0>();
94 } 102 }
95 103
96 // static 104 // static
97 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance, 105 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance,
98 bool on_top) { 106 bool on_top) {
99 InitializeCombinedInterface(); 107 InitializeCombinedInterface();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 int32_t result = flash_12_combined_interface.GetSettingInt( 250 int32_t result = flash_12_combined_interface.GetSettingInt(
243 instance.pp_instance(), setting); 251 instance.pp_instance(), setting);
244 if (result == 0 || result == 1) 252 if (result == 0 || result == 1)
245 return Var(!!result); 253 return Var(!!result);
246 } 254 }
247 255
248 return Var(); 256 return Var();
249 } 257 }
250 258
251 // static 259 // static
260 bool Flash::SetCrashData(const InstanceHandle& instance,
261 PP_FlashCrashKey key,
262 const pp::Var& value) {
263 InitializeCombinedInterface();
264 if (flash_12_combined_interface.SetCrashData) {
265 return PP_ToBool(
266 flash_12_combined_interface.SetCrashData(instance.pp_instance(),
267 key, value.pp_var()));
268 }
269 return false;
270 }
271
272 // static
252 bool Flash::InvokePrinting(const InstanceHandle& instance) { 273 bool Flash::InvokePrinting(const InstanceHandle& instance) {
253 if (has_interface<PPB_Flash_Print_1_0>()) { 274 if (has_interface<PPB_Flash_Print_1_0>()) {
254 get_interface<PPB_Flash_Print_1_0>()->InvokePrinting( 275 get_interface<PPB_Flash_Print_1_0>()->InvokePrinting(
255 instance.pp_instance()); 276 instance.pp_instance());
256 return true; 277 return true;
257 } 278 }
258 return false; 279 return false;
259 } 280 }
260 281
261 } // namespace flash 282 } // namespace flash
262 } // namespace pp 283 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/private/flash.h ('k') | ppapi/proxy/plugin_proxy_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698