| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/common.h" | 7 #include "ppapi/cpp/common.h" |
| 8 #include "ppapi/cpp/instance.h" | 8 #include "ppapi/cpp/instance.h" |
| 9 #include "ppapi/cpp/module.h" | 9 #include "ppapi/cpp/module.h" |
| 10 | 10 |
| 11 namespace pp { | 11 namespace pp { |
| 12 | 12 |
| 13 // static | 13 // static |
| 14 const UrlUtil_Dev* UrlUtil_Dev::Get() { | 14 const URLUtil_Dev* URLUtil_Dev::Get() { |
| 15 static bool tried_to_init = false; | 15 static bool tried_to_init = false; |
| 16 static UrlUtil_Dev util; | 16 static URLUtil_Dev util; |
| 17 | 17 |
| 18 if (!tried_to_init) { | 18 if (!tried_to_init) { |
| 19 tried_to_init = true; | 19 tried_to_init = true; |
| 20 util.interface_ = static_cast<const PPB_UrlUtil_Dev*>( | 20 util.interface_ = static_cast<const PPB_URLUtil_Dev*>( |
| 21 Module::Get()->GetBrowserInterface(PPB_URLUTIL_DEV_INTERFACE)); | 21 Module::Get()->GetBrowserInterface(PPB_URLUTIL_DEV_INTERFACE)); |
| 22 } | 22 } |
| 23 | 23 |
| 24 if (!util.interface_) | 24 if (!util.interface_) |
| 25 return NULL; | 25 return NULL; |
| 26 return &util; | 26 return &util; |
| 27 } | 27 } |
| 28 | 28 |
| 29 Var UrlUtil_Dev::Canonicalize(const Var& url, | 29 Var URLUtil_Dev::Canonicalize(const Var& url, |
| 30 PP_UrlComponents_Dev* components) const { | 30 PP_URLComponents_Dev* components) const { |
| 31 return Var(Var::PassRef(), | 31 return Var(Var::PassRef(), |
| 32 interface_->Canonicalize(url.pp_var(), components)); | 32 interface_->Canonicalize(url.pp_var(), components)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 Var UrlUtil_Dev::ResolveRelativeToUrl(const Var& base_url, | 35 Var URLUtil_Dev::ResolveRelativeToURL(const Var& base_url, |
| 36 const Var& relative_string, | 36 const Var& relative_string, |
| 37 PP_UrlComponents_Dev* components) const { | 37 PP_URLComponents_Dev* components) const { |
| 38 return Var(Var::PassRef(), | 38 return Var(Var::PassRef(), |
| 39 interface_->ResolveRelativeToUrl(base_url.pp_var(), | 39 interface_->ResolveRelativeToURL(base_url.pp_var(), |
| 40 relative_string.pp_var(), | 40 relative_string.pp_var(), |
| 41 components)); | 41 components)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 Var UrlUtil_Dev::ResoveRelativeToDocument( | 44 Var URLUtil_Dev::ResoveRelativeToDocument( |
| 45 const Instance& instance, | 45 const Instance& instance, |
| 46 const Var& relative_string, | 46 const Var& relative_string, |
| 47 PP_UrlComponents_Dev* components) const { | 47 PP_URLComponents_Dev* components) const { |
| 48 return Var(Var::PassRef(), | 48 return Var(Var::PassRef(), |
| 49 interface_->ResolveRelativeToDocument(instance.pp_instance(), | 49 interface_->ResolveRelativeToDocument(instance.pp_instance(), |
| 50 relative_string.pp_var(), | 50 relative_string.pp_var(), |
| 51 components)); | 51 components)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool UrlUtil_Dev::IsSameSecurityOrigin(const Var& url_a, | 54 bool URLUtil_Dev::IsSameSecurityOrigin(const Var& url_a, |
| 55 const Var& url_b) const { | 55 const Var& url_b) const { |
| 56 return PPBoolToBool(interface_->IsSameSecurityOrigin(url_a.pp_var(), | 56 return PPBoolToBool(interface_->IsSameSecurityOrigin(url_a.pp_var(), |
| 57 url_b.pp_var())); | 57 url_b.pp_var())); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool UrlUtil_Dev::DocumentCanRequest(const Instance& instance, | 60 bool URLUtil_Dev::DocumentCanRequest(const Instance& instance, |
| 61 const Var& url) const { | 61 const Var& url) const { |
| 62 return PPBoolToBool(interface_->DocumentCanRequest(instance.pp_instance(), | 62 return PPBoolToBool(interface_->DocumentCanRequest(instance.pp_instance(), |
| 63 url.pp_var())); | 63 url.pp_var())); |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool UrlUtil_Dev::DocumentCanAccessDocument(const Instance& active, | 66 bool URLUtil_Dev::DocumentCanAccessDocument(const Instance& active, |
| 67 const Instance& target) const { | 67 const Instance& target) const { |
| 68 return PPBoolToBool( | 68 return PPBoolToBool( |
| 69 interface_->DocumentCanAccessDocument(active.pp_instance(), | 69 interface_->DocumentCanAccessDocument(active.pp_instance(), |
| 70 target.pp_instance())); | 70 target.pp_instance())); |
| 71 } | 71 } |
| 72 | 72 |
| 73 Var URLUtil_Dev::GetDocumentURL(const Instance& instance, |
| 74 PP_URLComponents_Dev* components) const { |
| 75 return Var(Var::PassRef(), |
| 76 interface_->GetDocumentURL(instance.pp_instance(), components)); |
| 77 } |
| 78 |
| 73 } // namespace pp | 79 } // namespace pp |
| OLD | NEW |