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
|
// Copyright (c) 2010 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/dev/url_util_dev.h"
#include "ppapi/cpp/common.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
namespace pp {
// static
const UrlUtil_Dev* UrlUtil_Dev::Get() {
static bool tried_to_init = false;
static UrlUtil_Dev util;
if (!tried_to_init) {
tried_to_init = true;
util.interface_ = static_cast<const PPB_UrlUtil_Dev*>(
Module::Get()->GetBrowserInterface(PPB_URLUTIL_DEV_INTERFACE));
}
if (!util.interface_)
return NULL;
return &util;
}
Var UrlUtil_Dev::Canonicalize(const Var& url,
PP_UrlComponents_Dev* components) const {
return Var(Var::PassRef(),
interface_->Canonicalize(url.pp_var(), components));
}
Var UrlUtil_Dev::ResolveRelativeToUrl(const Var& base_url,
const Var& relative_string,
PP_UrlComponents_Dev* components) const {
return Var(Var::PassRef(),
interface_->ResolveRelativeToUrl(base_url.pp_var(),
relative_string.pp_var(),
components));
}
Var UrlUtil_Dev::ResoveRelativeToDocument(
const Instance& instance,
const Var& relative_string,
PP_UrlComponents_Dev* components) const {
return Var(Var::PassRef(),
interface_->ResolveRelativeToDocument(instance.pp_instance(),
relative_string.pp_var(),
components));
}
bool UrlUtil_Dev::IsSameSecurityOrigin(const Var& url_a,
const Var& url_b) const {
return PPBoolToBool(interface_->IsSameSecurityOrigin(url_a.pp_var(),
url_b.pp_var()));
}
bool UrlUtil_Dev::DocumentCanRequest(const Instance& instance,
const Var& url) const {
return PPBoolToBool(interface_->DocumentCanRequest(instance.pp_instance(),
url.pp_var()));
}
bool UrlUtil_Dev::DocumentCanAccessDocument(const Instance& active,
const Instance& target) const {
return PPBoolToBool(
interface_->DocumentCanAccessDocument(active.pp_instance(),
target.pp_instance()));
}
} // namespace pp
|