summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk/ppb_url_util_thunk.cc
blob: e4ba7b547ca643402d98db6e841d178fef0f6190 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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/c/pp_errors.h"
#include "ppapi/shared_impl/ppb_url_util_shared.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/thunk.h"

namespace ppapi {
namespace thunk {

namespace {

PP_Var ResolveRelativeToDocument(PP_Instance instance,
                                 PP_Var relative,
                                 PP_URLComponents_Dev* components) {
  EnterInstance enter(instance);
  if (enter.failed())
    return PP_MakeUndefined();
  return enter.functions()->ResolveRelativeToDocument(instance, relative,
                                                      components);
}

PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) {
  EnterInstance enter(instance);
  if (enter.failed())
    return PP_FALSE;
  return enter.functions()->DocumentCanRequest(instance, url);
}

PP_Bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) {
  EnterInstance enter(active);
  if (enter.failed())
    return PP_FALSE;
  return enter.functions()->DocumentCanAccessDocument(active, target);
}

PP_Var GetDocumentURL(PP_Instance instance,
                      PP_URLComponents_Dev* components) {
  EnterInstance enter(instance);
  if (enter.failed())
    return PP_MakeUndefined();
  return enter.functions()->GetDocumentURL(instance, components);
}

PP_Var GetPluginInstanceURL(PP_Instance instance,
                            PP_URLComponents_Dev* components) {
  EnterInstance enter(instance);
  if (enter.failed())
    return PP_MakeUndefined();
  return enter.functions()->GetPluginInstanceURL(instance, components);
}

PP_Var GetPluginReferrerURL(PP_Instance instance,
                            PP_URLComponents_Dev* components) {
  EnterInstance enter(instance);
  if (enter.failed())
    return PP_MakeUndefined();
  return enter.functions()->GetPluginReferrerURL(instance, components);
}

const PPB_URLUtil_Dev_0_6 g_ppb_url_util_0_6 = {
  &PPB_URLUtil_Shared::Canonicalize,
  &PPB_URLUtil_Shared::ResolveRelativeToURL,
  &ResolveRelativeToDocument,
  &PPB_URLUtil_Shared::IsSameSecurityOrigin,
  &DocumentCanRequest,
  &DocumentCanAccessDocument,
  &GetDocumentURL,
  &GetPluginInstanceURL
};

const PPB_URLUtil_Dev_0_7 g_ppb_url_util_0_7 = {
  &PPB_URLUtil_Shared::Canonicalize,
  &PPB_URLUtil_Shared::ResolveRelativeToURL,
  &ResolveRelativeToDocument,
  &PPB_URLUtil_Shared::IsSameSecurityOrigin,
  &DocumentCanRequest,
  &DocumentCanAccessDocument,
  &GetDocumentURL,
  &GetPluginInstanceURL,
  &GetPluginReferrerURL
};

}  // namespace

const PPB_URLUtil_Dev_0_6* GetPPB_URLUtil_Dev_0_6_Thunk() {
  return &g_ppb_url_util_0_6;
}

const PPB_URLUtil_Dev_0_7* GetPPB_URLUtil_Dev_0_7_Thunk() {
  return &g_ppb_url_util_0_7;
}

}  // namespace thunk
}  // namespace ppapi