Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: ppapi/c/dev/ppb_url_util_dev.h

Issue 6594107: Add PPB_URLUtil_Dev::GetDocumentURL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "add TestGetDocumentURL Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ 5 #ifndef PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_
6 #define PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ 6 #define PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_
7 7
8 #include "ppapi/c/pp_bool.h" 8 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/c/pp_instance.h" 9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/c/pp_macros.h" 10 #include "ppapi/c/pp_macros.h"
11 #include "ppapi/c/pp_stdint.h" 11 #include "ppapi/c/pp_stdint.h"
12 #include "ppapi/c/pp_var.h" 12 #include "ppapi/c/pp_var.h"
13 13
14 #define PPB_URLUTIL_DEV_INTERFACE "PPB_UrlUtil(Dev);0.4" 14 #define PPB_URLUTIL_DEV_INTERFACE "PPB_URLUtil(Dev);0.5"
15 15
16 // A component specifies the range of the part of the URL. The begin specifies 16 // A component specifies the range of the part of the URL. The begin specifies
17 // the index into the string of the first character of that component. The len 17 // the index into the string of the first character of that component. The len
18 // specifies the length of that component. 18 // specifies the length of that component.
19 // 19 //
20 // This range does not include any special delimiter for that component, so 20 // This range does not include any special delimiter for that component, so
21 // the scheme doesn't include the trailing colon, the username and password 21 // the scheme doesn't include the trailing colon, the username and password
22 // don't include the @ and :, the port doesn't include the colon, the query 22 // don't include the @ and :, the port doesn't include the colon, the query
23 // doesn't include the ?, and the ref doesn't include the #. 23 // doesn't include the ?, and the ref doesn't include the #.
24 // 24 //
25 // The exception is that the path *does* include the first /, since that's an 25 // The exception is that the path *does* include the first /, since that's an
26 // integral part of the path. 26 // integral part of the path.
27 // 27 //
28 // If the component is not present at all, begin will be 0 and len will be -1. 28 // If the component is not present at all, begin will be 0 and len will be -1.
29 // If the component is present but empty, the length will be 0 instead. Example: 29 // If the component is present but empty, the length will be 0 instead. Example:
30 // http://foo/search -> query = (0, -1) 30 // http://foo/search -> query = (0, -1)
31 // http://foo/search? -> query = (18, 0) 31 // http://foo/search? -> query = (18, 0)
32 struct PP_UrlComponent_Dev { 32 struct PP_URLComponent_Dev {
33 int32_t begin; 33 int32_t begin;
34 int32_t len; 34 int32_t len;
35 }; 35 };
36 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_UrlComponent_Dev, 8); 36 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponent_Dev, 8);
37 37
38 struct PP_UrlComponents_Dev { 38 struct PP_URLComponents_Dev {
39 struct PP_UrlComponent_Dev scheme; 39 struct PP_URLComponent_Dev scheme;
40 struct PP_UrlComponent_Dev username; 40 struct PP_URLComponent_Dev username;
41 struct PP_UrlComponent_Dev password; 41 struct PP_URLComponent_Dev password;
42 struct PP_UrlComponent_Dev host; 42 struct PP_URLComponent_Dev host;
43 struct PP_UrlComponent_Dev port; 43 struct PP_URLComponent_Dev port;
44 struct PP_UrlComponent_Dev path; 44 struct PP_URLComponent_Dev path;
45 struct PP_UrlComponent_Dev query; 45 struct PP_URLComponent_Dev query;
46 struct PP_UrlComponent_Dev ref; 46 struct PP_URLComponent_Dev ref;
47 }; 47 };
48 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_UrlComponents_Dev, 64); 48 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponents_Dev, 64);
49 49
50 // URL encoding: URLs are supplied to this interface as NULL-terminated 8-bit 50 // URL encoding: URLs are supplied to this interface as NULL-terminated 8-bit
51 // strings. You can pass non-ASCII characters which will be interpreted as 51 // strings. You can pass non-ASCII characters which will be interpreted as
52 // UTF-8. Canonicalized URL strings returned by these functions will be ASCII 52 // UTF-8. Canonicalized URL strings returned by these functions will be ASCII
53 // except for the reference fragment (stuff after the '#') which will be 53 // except for the reference fragment (stuff after the '#') which will be
54 // encoded as UTF-8. 54 // encoded as UTF-8.
55 struct PPB_UrlUtil_Dev { 55 struct PPB_URLUtil_Dev {
56 // Canonicalizes the given URL string according to the rules of the host 56 // Canonicalizes the given URL string according to the rules of the host
57 // browser. If the URL is invalid or the var is not a string, this will 57 // browser. If the URL is invalid or the var is not a string, this will
58 // return a Null var and the components structure will be unchanged. 58 // return a Null var and the components structure will be unchanged.
59 // 59 //
60 // The components pointer, if non-NULL and the canonicalized URL is valid, 60 // The components pointer, if non-NULL and the canonicalized URL is valid,
61 // will identify the components of the resulting URL. Components may be NULL 61 // will identify the components of the resulting URL. Components may be NULL
62 // to specify that no component information is necessary. 62 // to specify that no component information is necessary.
63 struct PP_Var (*Canonicalize)(struct PP_Var url, 63 struct PP_Var (*Canonicalize)(struct PP_Var url,
64 struct PP_UrlComponents_Dev* components); 64 struct PP_URLComponents_Dev* components);
65 65
66 // Resolves the given URL relative to the given base URL. The resulting URL 66 // Resolves the given URL relative to the given base URL. The resulting URL
67 // is returned as a string. If the resolution is invalid or either of the 67 // is returned as a string. If the resolution is invalid or either of the
68 // inputs are not strings, a Null var will be returned. The resulting URL 68 // inputs are not strings, a Null var will be returned. The resulting URL
69 // will also be canonicalized according to the rules of the browser. 69 // will also be canonicalized according to the rules of the browser.
70 // 70 //
71 // Note that the "relative" URL bay in fact be absolute, in which case it 71 // Note that the "relative" URL may in fact be absolute, in which case it
72 // will be returned. This function is identical to resolving the full URL 72 // will be returned. This function is identical to resolving the full URL
73 // for an <a href="..."> on a web page. Attempting to resolve a relative URL 73 // for an <a href="..."> on a web page. Attempting to resolve a relative URL
74 // on a base URL that doesn't support this (e.g. "data") will fail and will 74 // on a base URL that doesn't support this (e.g. "data") will fail and will
75 // return a Null var, unless the relative URL is itself absolute. 75 // return a Null var, unless the relative URL is itself absolute.
76 // 76 //
77 // The components pointer, if non-NULL and the canonicalized URL is valid, 77 // The components pointer, if non-NULL and the canonicalized URL is valid,
78 // will identify the components of the resulting URL. Components may be NULL 78 // will identify the components of the resulting URL. Components may be NULL
79 // to specify that no component information is necessary. 79 // to specify that no component information is necessary.
80 struct PP_Var (*ResolveRelativeToUrl)( 80 struct PP_Var (*ResolveRelativeToURL)(
81 struct PP_Var base_url, 81 struct PP_Var base_url,
82 struct PP_Var relative_string, 82 struct PP_Var relative_string,
83 struct PP_UrlComponents_Dev* components); 83 struct PP_URLComponents_Dev* components);
84 84
85 // Identical to ResolveRelativeToUrl except that the base URL is the base 85 // Identical to ResolveRelativeToURL except that the base URL is the base
86 // URL of the document containing the given plugin instance. 86 // URL of the document containing the given plugin instance.
87 // 87 //
88 // Danger: This will be identical to resolving a relative URL on the page, 88 // Danger: This will be identical to resolving a relative URL on the page,
89 // and might be overridden by the page to something different than its actual 89 // and might be overridden by the page to something different than its actual
90 // URL via the <base> tag. Therefore, resolving a relative URL of "" won't 90 // URL via the <base> tag. Therefore, resolving a relative URL of "" won't
91 // necessarily give you the URL of the page! 91 // necessarily give you the URL of the page!
92 struct PP_Var (*ResolveRelativeToDocument)( 92 struct PP_Var (*ResolveRelativeToDocument)(
93 PP_Instance instance, 93 PP_Instance instance,
94 struct PP_Var relative_string, 94 struct PP_Var relative_string,
95 struct PP_UrlComponents_Dev* components); 95 struct PP_URLComponents_Dev* components);
96 96
97 // Checks whether the given two URLs are in the same security origin. Returns 97 // Checks whether the given two URLs are in the same security origin. Returns
98 // FALSE if either of the URLs are invalid. 98 // FALSE if either of the URLs are invalid.
99 PP_Bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b); 99 PP_Bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b);
100 100
101 // Checks whether the document hosting the given plugin instance can access 101 // Checks whether the document hosting the given plugin instance can access
102 // the given URL according to the same origin policy of the browser. Returns 102 // the given URL according to the same origin policy of the browser. Returns
103 // PP_FALSE if the instance or the URL is invalid. 103 // PP_FALSE if the instance or the URL is invalid.
104 PP_Bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url); 104 PP_Bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url);
105 105
106 // Checks whether the document containing the |active| plugin instance can 106 // Checks whether the document containing the |active| plugin instance can
107 // access the document containing the |target| plugin instance according to 107 // access the document containing the |target| plugin instance according to
108 // the security policy of the browser. This includes the same origin policy 108 // the security policy of the browser. This includes the same origin policy
109 // and any cross-origin capabilities enabled by the document. If either of 109 // and any cross-origin capabilities enabled by the document. If either of
110 // the plugin instances are invalid, returns PP_FALSE. 110 // the plugin instances are invalid, returns PP_FALSE.
111 PP_Bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target); 111 PP_Bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target);
112
113 // Returns the URL for the document. This is a safe way to retrieve
114 // window.location.href.
viettrungluu 2011/03/02 21:00:54 You should presumably say that |components| may be
115 struct PP_Var (*GetDocumentURL)(PP_Instance instance,
116 struct PP_URLComponents_Dev* components);
112 }; 117 };
113 118
114 #endif /* PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ */ 119 #endif /* PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ */
115 120
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698