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 | |
6 /** | |
7 * This file defines the <code>PPB_URLUtil_Dev</code> interface. | |
brettw
2011/12/14 22:36:47
Thanks for writing this.
ygorshenin
2011/12/15 11:48:22
Done.
| |
8 */ | |
9 | |
10 label Chrome { | |
11 M17 = 0.6 | |
12 }; | |
13 | |
14 /* | |
15 * A component specifies the range of the part of the URL. The begin specifies | |
16 * the index into the string of the first character of that component. The len | |
17 * specifies the length of that component. | |
18 * | |
19 * This range does not include any special delimiter for that component, so | |
20 * the scheme doesn't include the trailing colon, the username and password | |
21 * don't include the @ and :, the port doesn't include the colon, the query | |
22 * doesn't include the ?, and the ref doesn't include the #. | |
23 * | |
24 * The exception is that the path *does* include the first /, since that's an | |
25 * integral part of the path. | |
26 * | |
27 * If the component is not present at all, begin will be 0 and len will be -1. | |
28 * If the component is present but empty, the length will be 0 instead. Example: | |
29 * http://foo/search -> query = (0, -1) | |
30 * http://foo/search? -> query = (18, 0) | |
31 */ | |
32 [assert_size(8)] | |
33 struct PP_URLComponent_Dev { | |
34 int32_t begin; | |
35 int32_t len; | |
36 }; | |
37 | |
38 [assert_size(64)] | |
39 struct PP_URLComponents_Dev { | |
40 PP_URLComponent_Dev scheme; | |
41 PP_URLComponent_Dev username; | |
42 PP_URLComponent_Dev password; | |
43 PP_URLComponent_Dev host; | |
44 PP_URLComponent_Dev port; | |
45 PP_URLComponent_Dev path; | |
46 PP_URLComponent_Dev query; | |
47 PP_URLComponent_Dev ref; | |
48 }; | |
49 | |
50 /* | |
51 * URL encoding: URLs are supplied to this interface as NULL-terminated 8-bit | |
52 * strings. You can pass non-ASCII characters which will be interpreted as | |
53 * UTF-8. Canonicalized URL strings returned by these functions will be ASCII | |
54 * except for the reference fragment (stuff after the '#') which will be | |
55 * encoded as UTF-8. | |
56 */ | |
57 interface PPB_URLUtil_Dev { | |
58 /* | |
59 * Canonicalizes the given URL string according to the rules of the host | |
60 * browser. If the URL is invalid or the var is not a string, this will | |
61 * return a Null var and the components structure will be unchanged. | |
62 * | |
63 * The components pointer, if non-NULL and the canonicalized URL is valid, | |
64 * will identify the components of the resulting URL. Components may be NULL | |
65 * to specify that no component information is necessary. | |
66 */ | |
67 PP_Var Canonicalize([in] PP_Var url, [out] PP_URLComponents_Dev components); | |
68 | |
69 /* | |
70 * Resolves the given URL relative to the given base URL. The resulting URL | |
71 * is returned as a string. If the resolution is invalid or either of the | |
72 * inputs are not strings, a Null var will be returned. The resulting URL | |
73 * will also be canonicalized according to the rules of the browser. | |
74 * | |
75 * Note that the "relative" URL may in fact be absolute, in which case it | |
76 * will be returned. This function is identical to resolving the full URL | |
77 * for an <a href="..."> on a web page. Attempting to resolve a relative URL | |
78 * on a base URL that doesn't support this (e.g. "data") will fail and will | |
79 * return a Null var, unless the relative URL is itself absolute. | |
80 * | |
81 * The components pointer, if non-NULL and the canonicalized URL is valid, | |
82 * will identify the components of the resulting URL. Components may be NULL | |
83 * to specify that no component information is necessary. | |
84 */ | |
85 PP_Var ResolveRelativeToURL( | |
86 [in] PP_Var base_url, | |
87 [in] PP_Var relative_string, | |
88 [out] PP_URLComponents_Dev components); | |
89 | |
90 /* | |
91 * Identical to ResolveRelativeToURL except that the base URL is the base | |
92 * URL of the document containing the given plugin instance. | |
93 * | |
94 * Danger: This will be identical to resolving a relative URL on the page, | |
95 * and might be overridden by the page to something different than its actual | |
96 * URL via the <base> tag. Therefore, resolving a relative URL of "" won't | |
97 * necessarily give you the URL of the page! | |
98 */ | |
99 PP_Var ResolveRelativeToDocument( | |
100 [in] PP_Instance instance, | |
101 [in] PP_Var relative_string, | |
102 [out] PP_URLComponents_Dev components); | |
103 | |
104 /* | |
105 * Checks whether the given two URLs are in the same security origin. Returns | |
106 * FALSE if either of the URLs are invalid. | |
107 */ | |
108 PP_Bool IsSameSecurityOrigin([in] PP_Var url_a, [in] PP_Var url_b); | |
109 | |
110 /* | |
111 * Checks whether the document hosting the given plugin instance can access | |
112 * the given URL according to the same origin policy of the browser. Returns | |
113 * PP_FALSE if the instance or the URL is invalid. | |
114 */ | |
115 PP_Bool DocumentCanRequest([in] PP_Instance instance, [in] PP_Var url); | |
116 | |
117 /* | |
118 * Checks whether the document containing the |active| plugin instance can | |
119 * access the document containing the |target| plugin instance according to | |
120 * the security policy of the browser. This includes the same origin policy | |
121 * and any cross-origin capabilities enabled by the document. If either of | |
122 * the plugin instances are invalid, returns PP_FALSE. | |
123 */ | |
124 PP_Bool DocumentCanAccessDocument([in] PP_Instance active, | |
125 [in] PP_Instance target); | |
126 | |
127 /* | |
128 * Returns the URL for the document. This is a safe way to retrieve | |
129 * window.location.href. | |
130 * The components pointer, if non-NULL and the canonicalized URL is valid, | |
131 * will identify the components of the resulting URL. Components may be NULL | |
132 * to specify that no component information is necessary. | |
133 */ | |
134 PP_Var GetDocumentURL([in] PP_Instance instance, | |
135 [out] PP_URLComponents_Dev components); | |
136 | |
137 /* | |
138 * Returns the Source URL for the plugin. This returns the URL that would be | |
139 * streamed to the plugin if it were a NPAPI plugin. This is usually the src | |
140 * attribute on the <embed> element, but the rules are obscure and different | |
141 * based on whether the plugin is loaded from an <embed> element or an | |
142 * <object> element. | |
143 * The components pointer, if non-NULL and the canonicalized URL is valid, | |
144 * will identify the components of the resulting URL. Components may be NULL | |
145 * to specify that no component information is necessary. | |
146 */ | |
147 PP_Var GetPluginInstanceURL([in] PP_Instance instance, | |
148 [out] PP_URLComponents_Dev components); | |
149 }; | |
OLD | NEW |