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.
5 #include "ppapi/cpp/dev/url_util_dev.h"
7 #include "ppapi/cpp/instance_handle.h"
8 #include "ppapi/cpp/module.h"
13 const URLUtil_Dev
* URLUtil_Dev::Get() {
14 static bool tried_to_init
= false;
15 static URLUtil_Dev util
;
19 util
.interface_
= static_cast<const PPB_URLUtil_Dev
*>(
20 Module::Get()->GetBrowserInterface(PPB_URLUTIL_DEV_INTERFACE
));
28 Var
URLUtil_Dev::Canonicalize(const Var
& url
,
29 PP_URLComponents_Dev
* components
) const {
30 return Var(PASS_REF
, interface_
->Canonicalize(url
.pp_var(), components
));
33 Var
URLUtil_Dev::ResolveRelativeToURL(const Var
& base_url
,
34 const Var
& relative_string
,
35 PP_URLComponents_Dev
* components
) const {
37 interface_
->ResolveRelativeToURL(base_url
.pp_var(),
38 relative_string
.pp_var(),
42 Var
URLUtil_Dev::ResolveRelativeToDocument(
43 const InstanceHandle
& instance
,
44 const Var
& relative_string
,
45 PP_URLComponents_Dev
* components
) const {
47 interface_
->ResolveRelativeToDocument(instance
.pp_instance(),
48 relative_string
.pp_var(),
52 bool URLUtil_Dev::IsSameSecurityOrigin(const Var
& url_a
,
53 const Var
& url_b
) const {
54 return PP_ToBool(interface_
->IsSameSecurityOrigin(url_a
.pp_var(),
58 bool URLUtil_Dev::DocumentCanRequest(const InstanceHandle
& instance
,
59 const Var
& url
) const {
60 return PP_ToBool(interface_
->DocumentCanRequest(instance
.pp_instance(),
64 bool URLUtil_Dev::DocumentCanAccessDocument(
65 const InstanceHandle
& active
,
66 const InstanceHandle
& target
) const {
68 interface_
->DocumentCanAccessDocument(active
.pp_instance(),
69 target
.pp_instance()));
72 Var
URLUtil_Dev::GetDocumentURL(const InstanceHandle
& instance
,
73 PP_URLComponents_Dev
* components
) const {
75 interface_
->GetDocumentURL(instance
.pp_instance(), components
));
78 Var
URLUtil_Dev::GetPluginInstanceURL(const InstanceHandle
& instance
,
79 PP_URLComponents_Dev
* components
) const {
81 interface_
->GetPluginInstanceURL(instance
.pp_instance(),