Move prefs::kLastPolicyStatisticsUpdate to the policy component.
[chromium-blink-merge.git] / ppapi / cpp / view.cc
blobce347859d70f3cc33db4cb15af28fd6672f8488e
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
3 // found in the LICENSE file.
5 #include "ppapi/cpp/view.h"
7 #include "ppapi/c/ppb_view.h"
8 #include "ppapi/cpp/module_impl.h"
10 namespace pp {
12 namespace {
14 template <> const char* interface_name<PPB_View_1_0>() {
15 return PPB_VIEW_INTERFACE_1_0;
18 template <> const char* interface_name<PPB_View_1_1>() {
19 return PPB_VIEW_INTERFACE_1_1;
22 } // namespace
24 View::View() : Resource() {
27 View::View(PP_Resource view_resource) : Resource(view_resource) {
30 Rect View::GetRect() const {
31 PP_Rect out;
32 if (has_interface<PPB_View_1_1>()) {
33 if (PP_ToBool(get_interface<PPB_View_1_1>()->GetRect(pp_resource(), &out)))
34 return Rect(out);
35 } else if (has_interface<PPB_View_1_0>()) {
36 if (PP_ToBool(get_interface<PPB_View_1_0>()->GetRect(pp_resource(), &out)))
37 return Rect(out);
39 return Rect();
42 bool View::IsFullscreen() const {
43 if (has_interface<PPB_View_1_1>()) {
44 return PP_ToBool(get_interface<PPB_View_1_1>()->IsFullscreen(
45 pp_resource()));
46 } else if (has_interface<PPB_View_1_0>()) {
47 return PP_ToBool(get_interface<PPB_View_1_0>()->IsFullscreen(
48 pp_resource()));
50 return false;
53 bool View::IsVisible() const {
54 if (has_interface<PPB_View_1_1>())
55 return PP_ToBool(get_interface<PPB_View_1_1>()->IsVisible(pp_resource()));
56 else if (has_interface<PPB_View_1_0>())
57 return PP_ToBool(get_interface<PPB_View_1_0>()->IsVisible(pp_resource()));
58 return false;
61 bool View::IsPageVisible() const {
62 if (has_interface<PPB_View_1_1>()) {
63 return PP_ToBool(get_interface<PPB_View_1_1>()->IsPageVisible(
64 pp_resource()));
65 } else if (has_interface<PPB_View_1_0>()) {
66 return PP_ToBool(get_interface<PPB_View_1_0>()->IsPageVisible(
67 pp_resource()));
69 return true;
72 Rect View::GetClipRect() const {
73 PP_Rect out;
74 if (has_interface<PPB_View_1_1>()) {
75 if (PP_ToBool(get_interface<PPB_View_1_1>()->GetClipRect(pp_resource(),
76 &out)))
77 return Rect(out);
78 } else if (has_interface<PPB_View_1_0>()) {
79 if (PP_ToBool(get_interface<PPB_View_1_0>()->GetClipRect(pp_resource(),
80 &out)))
81 return Rect(out);
83 return Rect();
86 float View::GetDeviceScale() const {
87 if (has_interface<PPB_View_1_1>())
88 return get_interface<PPB_View_1_1>()->GetDeviceScale(pp_resource());
89 return 1.0f;
92 float View::GetCSSScale() const {
93 if (has_interface<PPB_View_1_1>())
94 return get_interface<PPB_View_1_1>()->GetCSSScale(pp_resource());
95 return 1.0f;
98 } // namespace pp