Home | History | Annotate | Download | only in private
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "ppapi/cpp/private/flash_fullscreen.h"
      6 
      7 #include "ppapi/c/private/ppb_flash_fullscreen.h"
      8 #include "ppapi/cpp/instance.h"
      9 #include "ppapi/cpp/module.h"
     10 #include "ppapi/cpp/module_impl.h"
     11 #include "ppapi/cpp/size.h"
     12 
     13 namespace pp {
     14 
     15 namespace {
     16 
     17 template <> const char* interface_name<PPB_FlashFullscreen_0_1>() {
     18   return PPB_FLASHFULLSCREEN_INTERFACE_0_1;
     19 }
     20 
     21 template <> const char* interface_name<PPB_FlashFullscreen_1_0>() {
     22   return PPB_FLASHFULLSCREEN_INTERFACE_1_0;
     23 }
     24 
     25 }  // namespace
     26 
     27 FlashFullscreen::FlashFullscreen(const InstanceHandle& instance)
     28     : instance_(instance) {
     29 }
     30 
     31 FlashFullscreen::~FlashFullscreen() {
     32 }
     33 
     34 bool FlashFullscreen::IsFullscreen() {
     35   if (has_interface<PPB_FlashFullscreen_1_0>()) {
     36     return PP_ToBool(get_interface<PPB_FlashFullscreen_1_0>()->IsFullscreen(
     37         instance_.pp_instance()));
     38   }
     39   if (has_interface<PPB_FlashFullscreen_0_1>()) {
     40     return PP_ToBool(get_interface<PPB_FlashFullscreen_0_1>()->IsFullscreen(
     41         instance_.pp_instance()));
     42   }
     43   return false;
     44 }
     45 
     46 bool FlashFullscreen::SetFullscreen(bool fullscreen) {
     47   if (has_interface<PPB_FlashFullscreen_1_0>()) {
     48     return PP_ToBool(get_interface<PPB_FlashFullscreen_1_0>()->SetFullscreen(
     49         instance_.pp_instance(), PP_FromBool(fullscreen)));
     50   }
     51   if (has_interface<PPB_FlashFullscreen_0_1>()) {
     52     return PP_ToBool(get_interface<PPB_FlashFullscreen_0_1>()->SetFullscreen(
     53         instance_.pp_instance(), PP_FromBool(fullscreen)));
     54   }
     55   return false;
     56 }
     57 
     58 bool FlashFullscreen::GetScreenSize(Size* size) {
     59   if (has_interface<PPB_FlashFullscreen_1_0>()) {
     60     return PP_ToBool(get_interface<PPB_FlashFullscreen_1_0>()->GetScreenSize(
     61         instance_.pp_instance(), &size->pp_size()));
     62   }
     63   if (has_interface<PPB_FlashFullscreen_0_1>()) {
     64     return PP_ToBool(get_interface<PPB_FlashFullscreen_0_1>()->GetScreenSize(
     65         instance_.pp_instance(), &size->pp_size()));
     66   }
     67   return false;
     68 }
     69 
     70 bool FlashFullscreen::MustRecreateContexts() {
     71   return !get_interface<PPB_FlashFullscreen_1_0>();
     72 }
     73 
     74 }  // namespace pp
     75