| 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 <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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 template <> const char* interface_name<PPB_Flash_12_4>() { | 31 template <> const char* interface_name<PPB_Flash_12_4>() { |
| 32 return PPB_FLASH_INTERFACE_12_4; | 32 return PPB_FLASH_INTERFACE_12_4; |
| 33 } | 33 } |
| 34 | 34 |
| 35 template <> const char* interface_name<PPB_Flash_12_3>() { | 35 template <> const char* interface_name<PPB_Flash_12_3>() { |
| 36 return PPB_FLASH_INTERFACE_12_3; | 36 return PPB_FLASH_INTERFACE_12_3; |
| 37 } | 37 } |
| 38 | 38 |
| 39 template <> const char* interface_name<PPB_Flash_12_2>() { | |
| 40 return PPB_FLASH_INTERFACE_12_2; | |
| 41 } | |
| 42 | |
| 43 template <> const char* interface_name<PPB_Flash_12_1>() { | |
| 44 return PPB_FLASH_INTERFACE_12_1; | |
| 45 } | |
| 46 | |
| 47 template <> const char* interface_name<PPB_Flash_12_0>() { | |
| 48 return PPB_FLASH_INTERFACE_12_0; | |
| 49 } | |
| 50 | |
| 51 template <> const char* interface_name<PPB_Flash_Print_1_0>() { | 39 template <> const char* interface_name<PPB_Flash_Print_1_0>() { |
| 52 return PPB_FLASH_PRINT_INTERFACE_1_0; | 40 return PPB_FLASH_PRINT_INTERFACE_1_0; |
| 53 } | 41 } |
| 54 | 42 |
| 55 // The combined Flash interface is all Flash v12.* interfaces. All v12 | 43 // The combined Flash interface is all Flash v12.* interfaces. All v12 |
| 56 // interfaces just append one or more functions to the previous one, so we can | 44 // interfaces just append one or more functions to the previous one, so we can |
| 57 // have this meta one at the most recent version. Function pointers will be | 45 // have this meta one at the most recent version. Function pointers will be |
| 58 // null if they're not supported on the current Chrome version. | 46 // null if they're not supported on the current Chrome version. |
| 59 bool initialized_combined_interface = false; | 47 bool initialized_combined_interface = false; |
| 60 PPB_Flash flash_12_combined_interface; | 48 PPB_Flash flash_12_combined_interface; |
| 61 | 49 |
| 62 // Makes sure that the most recent version is loaded into the combined | 50 // Makes sure that the most recent version is loaded into the combined |
| 63 // interface struct above. Any unsupported functions will be NULL. If there | 51 // interface struct above. Any unsupported functions will be NULL. If there |
| 64 // is no Flash interface supported, all functions will be NULL. | 52 // is no Flash interface supported, all functions will be NULL. |
| 65 void InitializeCombinedInterface() { | 53 void InitializeCombinedInterface() { |
| 66 if (initialized_combined_interface) | 54 if (initialized_combined_interface) |
| 67 return; | 55 return; |
| 68 if (has_interface<PPB_Flash_12_5>()) { | 56 if (has_interface<PPB_Flash_12_5>()) { |
| 69 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_5>(), | 57 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_5>(), |
| 70 sizeof(PPB_Flash_12_5)); | 58 sizeof(PPB_Flash_12_5)); |
| 71 } else if (has_interface<PPB_Flash_12_4>()) { | 59 } else if (has_interface<PPB_Flash_12_4>()) { |
| 72 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(), | 60 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(), |
| 73 sizeof(PPB_Flash_12_4)); | 61 sizeof(PPB_Flash_12_4)); |
| 74 } else if (has_interface<PPB_Flash_12_3>()) { | 62 } else if (has_interface<PPB_Flash_12_3>()) { |
| 75 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_3>(), | 63 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_3>(), |
| 76 sizeof(PPB_Flash_12_3)); | 64 sizeof(PPB_Flash_12_3)); |
| 77 } else if (has_interface<PPB_Flash_12_2>()) { | |
| 78 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_2>(), | |
| 79 sizeof(PPB_Flash_12_2)); | |
| 80 } else if (has_interface<PPB_Flash_12_1>()) { | |
| 81 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_1>(), | |
| 82 sizeof(PPB_Flash_12_1)); | |
| 83 } else if (has_interface<PPB_Flash_12_0>()) { | |
| 84 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_0>(), | |
| 85 sizeof(PPB_Flash_12_0)); | |
| 86 } | 65 } |
| 87 initialized_combined_interface = true; | 66 initialized_combined_interface = true; |
| 88 } | 67 } |
| 89 | 68 |
| 90 } // namespace | 69 } // namespace |
| 91 | 70 |
| 92 namespace flash { | 71 namespace flash { |
| 93 | 72 |
| 94 // static | 73 // static |
| 95 bool Flash::IsAvailable() { | 74 bool Flash::IsAvailable() { |
| 96 return has_interface<PPB_Flash_12_5>() || | 75 return has_interface<PPB_Flash_12_5>() || |
| 97 has_interface<PPB_Flash_12_4>() || | 76 has_interface<PPB_Flash_12_4>() || |
| 98 has_interface<PPB_Flash_12_3>() || | 77 has_interface<PPB_Flash_12_3>(); |
| 99 has_interface<PPB_Flash_12_2>() || | |
| 100 has_interface<PPB_Flash_12_1>() || | |
| 101 has_interface<PPB_Flash_12_0>(); | |
| 102 } | 78 } |
| 103 | 79 |
| 104 // static | 80 // static |
| 105 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance, | 81 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance, |
| 106 bool on_top) { | 82 bool on_top) { |
| 107 InitializeCombinedInterface(); | 83 InitializeCombinedInterface(); |
| 108 if (flash_12_combined_interface.SetInstanceAlwaysOnTop) { | 84 if (flash_12_combined_interface.SetInstanceAlwaysOnTop) { |
| 109 flash_12_combined_interface.SetInstanceAlwaysOnTop( | 85 flash_12_combined_interface.SetInstanceAlwaysOnTop( |
| 110 instance.pp_instance(), PP_FromBool(on_top)); | 86 instance.pp_instance(), PP_FromBool(on_top)); |
| 111 } | 87 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 if (has_interface<PPB_Flash_Print_1_0>()) { | 250 if (has_interface<PPB_Flash_Print_1_0>()) { |
| 275 get_interface<PPB_Flash_Print_1_0>()->InvokePrinting( | 251 get_interface<PPB_Flash_Print_1_0>()->InvokePrinting( |
| 276 instance.pp_instance()); | 252 instance.pp_instance()); |
| 277 return true; | 253 return true; |
| 278 } | 254 } |
| 279 return false; | 255 return false; |
| 280 } | 256 } |
| 281 | 257 |
| 282 } // namespace flash | 258 } // namespace flash |
| 283 } // namespace pp | 259 } // namespace pp |
| OLD | NEW |