| 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/shared_impl/url_util_impl.h" | 5 #include "ppapi/shared_impl/url_util_impl.h" |
| 6 | 6 |
| 7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
| 8 #include "ppapi/shared_impl/var.h" | 8 #include "ppapi/shared_impl/var.h" |
| 9 | 9 |
| 10 namespace ppapi { | 10 namespace ppapi { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 ConvertComponent(input.query, &output->query); | 37 ConvertComponent(input.query, &output->query); |
| 38 ConvertComponent(input.ref, &output->ref); | 38 ConvertComponent(input.ref, &output->ref); |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 PP_Var URLUtilImpl::Canonicalize(PP_Module pp_module, | 44 PP_Var URLUtilImpl::Canonicalize(PP_Module pp_module, |
| 45 PP_Var url, | 45 PP_Var url, |
| 46 PP_URLComponents_Dev* components) { | 46 PP_URLComponents_Dev* components) { |
| 47 scoped_refptr<StringVar> url_string(StringVar::FromPPVar(url)); | 47 StringVar* url_string = StringVar::FromPPVar(url); |
| 48 if (!url_string) | 48 if (!url_string) |
| 49 return PP_MakeNull(); | 49 return PP_MakeNull(); |
| 50 return GenerateURLReturn(pp_module, GURL(url_string->value()), components); | 50 return GenerateURLReturn(pp_module, GURL(url_string->value()), components); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 PP_Var URLUtilImpl::ResolveRelativeToURL(PP_Module pp_module, | 54 PP_Var URLUtilImpl::ResolveRelativeToURL(PP_Module pp_module, |
| 55 PP_Var base_url, | 55 PP_Var base_url, |
| 56 PP_Var relative, | 56 PP_Var relative, |
| 57 PP_URLComponents_Dev* components) { | 57 PP_URLComponents_Dev* components) { |
| 58 scoped_refptr<StringVar> base_url_string(StringVar::FromPPVar(base_url)); | 58 StringVar* base_url_string = StringVar::FromPPVar(base_url); |
| 59 scoped_refptr<StringVar> relative_string(StringVar::FromPPVar(relative)); | 59 StringVar* relative_string = StringVar::FromPPVar(relative); |
| 60 if (!base_url_string || !relative_string) | 60 if (!base_url_string || !relative_string) |
| 61 return PP_MakeNull(); | 61 return PP_MakeNull(); |
| 62 | 62 |
| 63 GURL base_gurl(base_url_string->value()); | 63 GURL base_gurl(base_url_string->value()); |
| 64 if (!base_gurl.is_valid()) | 64 if (!base_gurl.is_valid()) |
| 65 return PP_MakeNull(); | 65 return PP_MakeNull(); |
| 66 return GenerateURLReturn(pp_module, | 66 return GenerateURLReturn(pp_module, |
| 67 base_gurl.Resolve(relative_string->value()), | 67 base_gurl.Resolve(relative_string->value()), |
| 68 components); | 68 components); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // static | 71 // static |
| 72 PP_Bool URLUtilImpl::IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { | 72 PP_Bool URLUtilImpl::IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { |
| 73 scoped_refptr<StringVar> url_a_string(StringVar::FromPPVar(url_a)); | 73 StringVar* url_a_string = StringVar::FromPPVar(url_a); |
| 74 scoped_refptr<StringVar> url_b_string(StringVar::FromPPVar(url_b)); | 74 StringVar* url_b_string = StringVar::FromPPVar(url_b); |
| 75 if (!url_a_string || !url_b_string) | 75 if (!url_a_string || !url_b_string) |
| 76 return PP_FALSE; | 76 return PP_FALSE; |
| 77 | 77 |
| 78 GURL gurl_a(url_a_string->value()); | 78 GURL gurl_a(url_a_string->value()); |
| 79 GURL gurl_b(url_b_string->value()); | 79 GURL gurl_b(url_b_string->value()); |
| 80 if (!gurl_a.is_valid() || !gurl_b.is_valid()) | 80 if (!gurl_a.is_valid() || !gurl_b.is_valid()) |
| 81 return PP_FALSE; | 81 return PP_FALSE; |
| 82 | 82 |
| 83 return gurl_a.GetOrigin() == gurl_b.GetOrigin() ? PP_TRUE : PP_FALSE; | 83 return gurl_a.GetOrigin() == gurl_b.GetOrigin() ? PP_TRUE : PP_FALSE; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Used for returning the given GURL from a PPAPI function, with an optional | 86 // Used for returning the given GURL from a PPAPI function, with an optional |
| 87 // out param indicating the components. | 87 // out param indicating the components. |
| 88 PP_Var URLUtilImpl::GenerateURLReturn(PP_Module module, | 88 PP_Var URLUtilImpl::GenerateURLReturn(PP_Module module, |
| 89 const GURL& url, | 89 const GURL& url, |
| 90 PP_URLComponents_Dev* components) { | 90 PP_URLComponents_Dev* components) { |
| 91 if (!url.is_valid()) | 91 if (!url.is_valid()) |
| 92 return PP_MakeNull(); | 92 return PP_MakeNull(); |
| 93 ConvertComponents(url.parsed_for_possibly_invalid_spec(), components); | 93 ConvertComponents(url.parsed_for_possibly_invalid_spec(), components); |
| 94 return StringVar::StringToPPVar(module, url.possibly_invalid_spec()); | 94 return StringVar::StringToPPVar(module, url.possibly_invalid_spec()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace ppapi | 97 } // namespace ppapi |
| OLD | NEW |