From 23cf9bd77696ac52ef7b3c9f61d6ad6e8528f5ea Mon Sep 17 00:00:00 2001 From: "viettrungluu@chromium.org" Date: Fri, 8 Jun 2012 00:56:36 +0000 Subject: "Replace" PPB_Flash's GetSettingInt with a more general GetSetting. BUG=none TEST=ui_tests PPAPITest.Flash and OutOfProcessPPAPITest.Flash Review URL: https://chromiumcodereview.appspot.com/10546060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141138 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/cpp/private/flash.cc | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'ppapi/cpp/private/flash.cc') diff --git a/ppapi/cpp/private/flash.cc b/ppapi/cpp/private/flash.cc index f5fd7f0..6af7c3d 100644 --- a/ppapi/cpp/private/flash.cc +++ b/ppapi/cpp/private/flash.cc @@ -24,6 +24,10 @@ namespace pp { namespace { +template <> const char* interface_name() { + return PPB_FLASH_INTERFACE_12_4; +} + template <> const char* interface_name() { return PPB_FLASH_INTERFACE_12_3; } @@ -57,7 +61,10 @@ PPB_Flash flash_12_combined_interface; void InitializeCombinedInterface() { if (initialized_combined_interface) return; - if (has_interface()) { + if (has_interface()) { + memcpy(&flash_12_combined_interface, get_interface(), + sizeof(PPB_Flash_12_4)); + } else if (has_interface()) { memcpy(&flash_12_combined_interface, get_interface(), sizeof(PPB_Flash_12_3)); } else if (has_interface()) { @@ -79,7 +86,8 @@ namespace flash { // static bool Flash::IsAvailable() { - return has_interface() || + return has_interface() || + has_interface() || has_interface() || has_interface() || has_interface(); @@ -221,14 +229,23 @@ Var Flash::GetDeviceID(const InstanceHandle& instance) { } // static -int32_t Flash::GetSettingInt(const InstanceHandle& instance, - PP_FlashSetting setting) { +Var Flash::GetSetting(const InstanceHandle& instance, PP_FlashSetting setting) { InitializeCombinedInterface(); + if (flash_12_combined_interface.GetSetting) { + return Var(PASS_REF, + flash_12_combined_interface.GetSetting(instance.pp_instance(), + setting)); + } if (flash_12_combined_interface.GetSettingInt) { - return flash_12_combined_interface.GetSettingInt(instance.pp_instance(), - setting); + // All the |PP_FlashSetting|s supported by |GetSettingInt()| return + // "booleans" (0 for false, 1 for true, -1 for undefined/unsupported/error). + int32_t result = flash_12_combined_interface.GetSettingInt( + instance.pp_instance(), setting); + if (result == 0 || result == 1) + return Var(!!result); } - return -1; + + return Var(); } // static -- cgit v1.1