OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef PPAPI_SHARED_IMPL_URL_UTIL_IMPL_H_ |
| 6 #define PPAPI_SHARED_IMPL_URL_UTIL_IMPL_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "googleurl/src/url_parse.h" |
| 12 #include "ppapi/c/dev/ppb_url_util_dev.h" |
| 13 #include "ppapi/c/pp_module.h" |
| 14 #include "ppapi/c/pp_var.h" |
| 15 |
| 16 class GURL; |
| 17 |
| 18 namespace pp { |
| 19 namespace shared_impl { |
| 20 |
| 21 // Contains the implementation of PPB_URLUtil that is shared between the proxy |
| 22 // and the renderer. |
| 23 class URLUtilImpl { |
| 24 public: |
| 25 // The functions here would normally take the var interface for constructing |
| 26 // return strings. However, at the current time there's some mixup between |
| 27 // using Var and VarDeprecated. To resolve this, we instead pass the pointer |
| 28 // to the string creation function so can be used independently of this. |
| 29 typedef PP_Var (*VarFromUtf8)(PP_Module, const char*, uint32_t); |
| 30 |
| 31 // Function that converts the given var to a std::string or NULL if the |
| 32 // var is not a string or is invalid. |
| 33 // |
| 34 // We could use PPB_Var for this, but that interface requires an additional |
| 35 // string conversion. Both the proxy and the host side maintain the strings |
| 36 // in a std::string, and the form we want for passing to GURL is also a |
| 37 // std::string. Parameterizing this separately saves this, and also solves |
| 38 // the same problem that VarFromUtf8 does. |
| 39 typedef const std::string* (*StringFromVar)(PP_Var var); |
| 40 |
| 41 // PPB_URLUtil shared functions. |
| 42 static PP_Var Canonicalize(StringFromVar string_from_var, |
| 43 VarFromUtf8 var_from_utf8, |
| 44 PP_Module pp_module, |
| 45 PP_Var url, |
| 46 PP_URLComponents_Dev* components); |
| 47 static PP_Var ResolveRelativeToURL(StringFromVar string_from_var, |
| 48 VarFromUtf8 var_from_utf8, |
| 49 PP_Module pp_module, |
| 50 PP_Var base_url, |
| 51 PP_Var relative, |
| 52 PP_URLComponents_Dev* components); |
| 53 static PP_Bool IsSameSecurityOrigin(StringFromVar string_from_var, |
| 54 PP_Var url_a, PP_Var url_b); |
| 55 |
| 56 // Used for returning the given GURL from a PPAPI function, with an optional |
| 57 // out param indicating the components. |
| 58 static PP_Var GenerateURLReturn(VarFromUtf8 var_from_utf8, |
| 59 PP_Module pp_module, |
| 60 const GURL& url, |
| 61 PP_URLComponents_Dev* components); |
| 62 }; |
| 63 |
| 64 } // namespace shared_impl |
| 65 } // namespace pp |
| 66 |
| 67 #endif |
OLD | NEW |