summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-08 00:56:36 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-08 00:56:36 +0000
commit23cf9bd77696ac52ef7b3c9f61d6ad6e8528f5ea (patch)
treef1817b0024dc0b9e0f6619202c32378507286807 /ppapi/cpp
parent576f4ff53b4e0d9ec1c9d127df306d8c8c403c13 (diff)
downloadchromium_src-23cf9bd77696ac52ef7b3c9f61d6ad6e8528f5ea.zip
chromium_src-23cf9bd77696ac52ef7b3c9f61d6ad6e8528f5ea.tar.gz
chromium_src-23cf9bd77696ac52ef7b3c9f61d6ad6e8528f5ea.tar.bz2
"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
Diffstat (limited to 'ppapi/cpp')
-rw-r--r--ppapi/cpp/private/flash.cc31
-rw-r--r--ppapi/cpp/private/flash.h4
2 files changed, 26 insertions, 9 deletions
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<PPB_Flash_12_4>() {
+ return PPB_FLASH_INTERFACE_12_4;
+}
+
template <> const char* interface_name<PPB_Flash_12_3>() {
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<PPB_Flash_12_3>()) {
+ if (has_interface<PPB_Flash_12_4>()) {
+ memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(),
+ sizeof(PPB_Flash_12_4));
+ } else if (has_interface<PPB_Flash_12_3>()) {
memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_3>(),
sizeof(PPB_Flash_12_3));
} else if (has_interface<PPB_Flash_12_2>()) {
@@ -79,7 +86,8 @@ namespace flash {
// static
bool Flash::IsAvailable() {
- return has_interface<PPB_Flash_12_3>() ||
+ return has_interface<PPB_Flash_12_4>() ||
+ has_interface<PPB_Flash_12_3>() ||
has_interface<PPB_Flash_12_2>() ||
has_interface<PPB_Flash_12_1>() ||
has_interface<PPB_Flash_12_0>();
@@ -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
diff --git a/ppapi/cpp/private/flash.h b/ppapi/cpp/private/flash.h
index 8b1e81b..c32007e 100644
--- a/ppapi/cpp/private/flash.h
+++ b/ppapi/cpp/private/flash.h
@@ -58,8 +58,8 @@ class Flash {
static bool IsRectTopmost(const InstanceHandle& instance, const Rect& rect);
static void UpdateActivity(const InstanceHandle& instance);
static Var GetDeviceID(const InstanceHandle& instance);
- static int32_t GetSettingInt(const InstanceHandle& instance,
- PP_FlashSetting setting);
+ static Var GetSetting(const InstanceHandle& instance,
+ PP_FlashSetting setting);
// PPB_Flash_Print.
static bool InvokePrinting(const InstanceHandle& instance);