summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/fullscreen.cc
blob: c5ad4f034ab3a056c0a50371edd1d05d8a29fed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ppapi/cpp/fullscreen.h"

#include "ppapi/c/ppb_fullscreen.h"
#include "ppapi/cpp/instance_handle.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/size.h"

namespace pp {

namespace {

template <> const char* interface_name<PPB_Fullscreen_1_0>() {
  return PPB_FULLSCREEN_INTERFACE_1_0;
}

}  // namespace

Fullscreen::Fullscreen(const InstanceHandle& instance)
    : instance_(instance) {
}

Fullscreen::~Fullscreen() {
}

bool Fullscreen::IsFullscreen() {
  return has_interface<PPB_Fullscreen_1_0>() &&
      get_interface<PPB_Fullscreen_1_0>()->IsFullscreen(
          instance_.pp_instance());
}

bool Fullscreen::SetFullscreen(bool fullscreen) {
  if (!has_interface<PPB_Fullscreen_1_0>())
    return false;
  return PP_ToBool(get_interface<PPB_Fullscreen_1_0>()->SetFullscreen(
      instance_.pp_instance(), PP_FromBool(fullscreen)));
}

bool Fullscreen::GetScreenSize(Size* size) {
  if (!has_interface<PPB_Fullscreen_1_0>())
    return false;
  return PP_ToBool(get_interface<PPB_Fullscreen_1_0>()->GetScreenSize(
      instance_.pp_instance(), &size->pp_size()));
}

}  // namespace pp