OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/cpp/dev/url_util_dev.h" | 5 #include "ppapi/cpp/dev/url_util_dev.h" |
6 | 6 |
7 #include "ppapi/cpp/instance.h" | 7 #include "ppapi/cpp/instance_handle.h" |
8 #include "ppapi/cpp/module.h" | 8 #include "ppapi/cpp/module.h" |
9 | 9 |
10 namespace pp { | 10 namespace pp { |
11 | 11 |
12 // static | 12 // static |
13 const URLUtil_Dev* URLUtil_Dev::Get() { | 13 const URLUtil_Dev* URLUtil_Dev::Get() { |
14 static bool tried_to_init = false; | 14 static bool tried_to_init = false; |
15 static URLUtil_Dev util; | 15 static URLUtil_Dev util; |
16 | 16 |
17 if (!tried_to_init) { | 17 if (!tried_to_init) { |
18 tried_to_init = true; | 18 tried_to_init = true; |
19 util.interface_ = static_cast<const PPB_URLUtil_Dev*>( | 19 util.interface_ = static_cast<const PPB_URLUtil_Dev*>( |
20 Module::Get()->GetBrowserInterface(PPB_URLUTIL_DEV_INTERFACE)); | 20 Module::Get()->GetBrowserInterface(PPB_URLUTIL_DEV_INTERFACE)); |
21 } | 21 } |
22 | 22 |
23 if (!util.interface_) | 23 if (!util.interface_) |
24 return NULL; | 24 return NULL; |
25 return &util; | 25 return &util; |
26 } | 26 } |
27 | 27 |
28 Var URLUtil_Dev::Canonicalize(const Var& url, | 28 Var URLUtil_Dev::Canonicalize(const Var& url, |
29 PP_URLComponents_Dev* components) const { | 29 PP_URLComponents_Dev* components) const { |
30 return Var(Var::PassRef(), | 30 return Var(PASS_REF, interface_->Canonicalize(url.pp_var(), components)); |
31 interface_->Canonicalize(url.pp_var(), components)); | |
32 } | 31 } |
33 | 32 |
34 Var URLUtil_Dev::ResolveRelativeToURL(const Var& base_url, | 33 Var URLUtil_Dev::ResolveRelativeToURL(const Var& base_url, |
35 const Var& relative_string, | 34 const Var& relative_string, |
36 PP_URLComponents_Dev* components) const { | 35 PP_URLComponents_Dev* components) const { |
37 return Var(Var::PassRef(), | 36 return Var(PASS_REF, |
38 interface_->ResolveRelativeToURL(base_url.pp_var(), | 37 interface_->ResolveRelativeToURL(base_url.pp_var(), |
39 relative_string.pp_var(), | 38 relative_string.pp_var(), |
40 components)); | 39 components)); |
41 } | 40 } |
42 | 41 |
43 Var URLUtil_Dev::ResolveRelativeToDocument( | 42 Var URLUtil_Dev::ResolveRelativeToDocument( |
44 const Instance& instance, | 43 const InstanceHandle& instance, |
45 const Var& relative_string, | 44 const Var& relative_string, |
46 PP_URLComponents_Dev* components) const { | 45 PP_URLComponents_Dev* components) const { |
47 return Var(Var::PassRef(), | 46 return Var(PASS_REF, |
48 interface_->ResolveRelativeToDocument(instance.pp_instance(), | 47 interface_->ResolveRelativeToDocument(instance.pp_instance(), |
49 relative_string.pp_var(), | 48 relative_string.pp_var(), |
50 components)); | 49 components)); |
51 } | 50 } |
52 | 51 |
53 bool URLUtil_Dev::IsSameSecurityOrigin(const Var& url_a, | 52 bool URLUtil_Dev::IsSameSecurityOrigin(const Var& url_a, |
54 const Var& url_b) const { | 53 const Var& url_b) const { |
55 return PP_ToBool(interface_->IsSameSecurityOrigin(url_a.pp_var(), | 54 return PP_ToBool(interface_->IsSameSecurityOrigin(url_a.pp_var(), |
56 url_b.pp_var())); | 55 url_b.pp_var())); |
57 } | 56 } |
58 | 57 |
59 bool URLUtil_Dev::DocumentCanRequest(const Instance& instance, | 58 bool URLUtil_Dev::DocumentCanRequest(const InstanceHandle& instance, |
60 const Var& url) const { | 59 const Var& url) const { |
61 return PP_ToBool(interface_->DocumentCanRequest(instance.pp_instance(), | 60 return PP_ToBool(interface_->DocumentCanRequest(instance.pp_instance(), |
62 url.pp_var())); | 61 url.pp_var())); |
63 } | 62 } |
64 | 63 |
65 bool URLUtil_Dev::DocumentCanAccessDocument(const Instance& active, | 64 bool URLUtil_Dev::DocumentCanAccessDocument( |
66 const Instance& target) const { | 65 const InstanceHandle& active, |
| 66 const InstanceHandle& target) const { |
67 return PP_ToBool( | 67 return PP_ToBool( |
68 interface_->DocumentCanAccessDocument(active.pp_instance(), | 68 interface_->DocumentCanAccessDocument(active.pp_instance(), |
69 target.pp_instance())); | 69 target.pp_instance())); |
70 } | 70 } |
71 | 71 |
72 Var URLUtil_Dev::GetDocumentURL(const Instance& instance, | 72 Var URLUtil_Dev::GetDocumentURL(const InstanceHandle& instance, |
73 PP_URLComponents_Dev* components) const { | 73 PP_URLComponents_Dev* components) const { |
74 return Var(Var::PassRef(), | 74 return Var(PASS_REF, |
75 interface_->GetDocumentURL(instance.pp_instance(), components)); | 75 interface_->GetDocumentURL(instance.pp_instance(), components)); |
76 } | 76 } |
77 | 77 |
78 Var URLUtil_Dev::GetPluginInstanceURL(const Instance& instance, | 78 Var URLUtil_Dev::GetPluginInstanceURL(const InstanceHandle& instance, |
79 PP_URLComponents_Dev* components) const { | 79 PP_URLComponents_Dev* components) const { |
80 return Var(Var::PassRef(), | 80 return Var(PASS_REF, |
81 interface_->GetPluginInstanceURL(instance.pp_instance(), | 81 interface_->GetPluginInstanceURL(instance.pp_instance(), |
82 components)); | 82 components)); |
83 } | 83 } |
84 | 84 |
85 } // namespace pp | 85 } // namespace pp |
OLD | NEW |