Roll leveldb from r73 to r75.
[chromium-blink-merge.git] / ppapi / cpp / dev / url_util_dev.cc
blob0353883265f2122e8d42da2ff6db59dccdb044e5
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"
10 namespace pp {
12 // static
13 const URLUtil_Dev* URLUtil_Dev::Get() {
14 static bool tried_to_init = false;
15 static URLUtil_Dev util;
17 if (!tried_to_init) {
18 tried_to_init = true;
19 util.interface_ = static_cast<const PPB_URLUtil_Dev*>(
20 Module::Get()->GetBrowserInterface(PPB_URLUTIL_DEV_INTERFACE));
23 if (!util.interface_)
24 return NULL;
25 return &util;
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 {
36 return Var(PASS_REF,
37 interface_->ResolveRelativeToURL(base_url.pp_var(),
38 relative_string.pp_var(),
39 components));
42 Var URLUtil_Dev::ResolveRelativeToDocument(
43 const InstanceHandle& instance,
44 const Var& relative_string,
45 PP_URLComponents_Dev* components) const {
46 return Var(PASS_REF,
47 interface_->ResolveRelativeToDocument(instance.pp_instance(),
48 relative_string.pp_var(),
49 components));
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(),
55 url_b.pp_var()));
58 bool URLUtil_Dev::DocumentCanRequest(const InstanceHandle& instance,
59 const Var& url) const {
60 return PP_ToBool(interface_->DocumentCanRequest(instance.pp_instance(),
61 url.pp_var()));
64 bool URLUtil_Dev::DocumentCanAccessDocument(
65 const InstanceHandle& active,
66 const InstanceHandle& target) const {
67 return PP_ToBool(
68 interface_->DocumentCanAccessDocument(active.pp_instance(),
69 target.pp_instance()));
72 Var URLUtil_Dev::GetDocumentURL(const InstanceHandle& instance,
73 PP_URLComponents_Dev* components) const {
74 return Var(PASS_REF,
75 interface_->GetDocumentURL(instance.pp_instance(), components));
78 Var URLUtil_Dev::GetPluginInstanceURL(const InstanceHandle& instance,
79 PP_URLComponents_Dev* components) const {
80 return Var(PASS_REF,
81 interface_->GetPluginInstanceURL(instance.pp_instance(),
82 components));
85 } // namespace pp