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

Side by Side Diff: webkit/glue/plugins/pepper_url_util.cc

Issue 3255003: Pull new PPAPI, rename non-P0 interfaces to Dev, rename DeviceContext2D to Gr... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 3 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
« no previous file with comments | « webkit/glue/plugins/pepper_url_util.h ('k') | webkit/glue/plugins/pepper_var.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "webkit/glue/plugins/pepper_url_util.h" 5 #include "webkit/glue/plugins/pepper_url_util.h"
6 6
7 #include "googleurl/src/gurl.h" 7 #include "googleurl/src/gurl.h"
8 #include "third_party/ppapi/c/ppb_url_util.h" 8 #include "third_party/ppapi/c/dev/ppb_url_util_dev.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
14 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" 14 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" 15 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
16 #include "webkit/glue/plugins/pepper_plugin_instance.h" 16 #include "webkit/glue/plugins/pepper_plugin_instance.h"
17 #include "webkit/glue/plugins/pepper_string.h" 17 #include "webkit/glue/plugins/pepper_string.h"
18 #include "webkit/glue/plugins/pepper_var.h" 18 #include "webkit/glue/plugins/pepper_var.h"
19 19
20 namespace pepper { 20 namespace pepper {
21 21
22 namespace { 22 namespace {
23 23
24 void ConvertComponent(const url_parse::Component& input, 24 void ConvertComponent(const url_parse::Component& input,
25 PP_UrlComponent* output) { 25 PP_UrlComponent_Dev* output) {
26 output->begin = input.begin; 26 output->begin = input.begin;
27 output->len = input.len; 27 output->len = input.len;
28 } 28 }
29 29
30 // Output can be NULL to specify "do nothing." This rule is followed by all the 30 // Output can be NULL to specify "do nothing." This rule is followed by all the
31 // url util functions, so we implement it once here. 31 // url util functions, so we implement it once here.
32 void ConvertComponents(const url_parse::Parsed& input, 32 void ConvertComponents(const url_parse::Parsed& input,
33 PP_UrlComponents* output) { 33 PP_UrlComponents_Dev* output) {
34 if (!output) 34 if (!output)
35 return; 35 return;
36 36
37 ConvertComponent(input.scheme, &output->scheme); 37 ConvertComponent(input.scheme, &output->scheme);
38 ConvertComponent(input.username, &output->username); 38 ConvertComponent(input.username, &output->username);
39 ConvertComponent(input.password, &output->password); 39 ConvertComponent(input.password, &output->password);
40 ConvertComponent(input.host, &output->host); 40 ConvertComponent(input.host, &output->host);
41 ConvertComponent(input.port, &output->port); 41 ConvertComponent(input.port, &output->port);
42 ConvertComponent(input.path, &output->path); 42 ConvertComponent(input.path, &output->path);
43 ConvertComponent(input.query, &output->query); 43 ConvertComponent(input.query, &output->query);
44 ConvertComponent(input.ref, &output->ref); 44 ConvertComponent(input.ref, &output->ref);
45 } 45 }
46 46
47 // Used for returning the given GURL from a PPAPI function, with an optional 47 // Used for returning the given GURL from a PPAPI function, with an optional
48 // out param indicating the components. 48 // out param indicating the components.
49 PP_Var GenerateUrlReturn(const GURL& url, PP_UrlComponents* components) { 49 PP_Var GenerateUrlReturn(const GURL& url, PP_UrlComponents_Dev* components) {
50 if (!url.is_valid()) 50 if (!url.is_valid())
51 return PP_MakeNull(); 51 return PP_MakeNull();
52 ConvertComponents(url.parsed_for_possibly_invalid_spec(), components); 52 ConvertComponents(url.parsed_for_possibly_invalid_spec(), components);
53 return StringToPPVar(url.possibly_invalid_spec()); 53 return StringToPPVar(url.possibly_invalid_spec());
54 } 54 }
55 55
56 // Sets |*security_origin| to be the WebKit security origin associated with the 56 // Sets |*security_origin| to be the WebKit security origin associated with the
57 // document containing the given plugin instance. On success, returns true. If 57 // document containing the given plugin instance. On success, returns true. If
58 // the instance is invalid, returns false and |*security_origin| will be 58 // the instance is invalid, returns false and |*security_origin| will be
59 // unchanged. 59 // unchanged.
60 bool SecurityOriginForInstance(PP_Instance instance_id, 60 bool SecurityOriginForInstance(PP_Instance instance_id,
61 WebKit::WebSecurityOrigin* security_origin) { 61 WebKit::WebSecurityOrigin* security_origin) {
62 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); 62 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
63 if (!instance) 63 if (!instance)
64 return false; 64 return false;
65 65
66 WebKit::WebElement plugin_element = instance->container()->element(); 66 WebKit::WebElement plugin_element = instance->container()->element();
67 WebKit::WebFrame* plugin_frame = plugin_element.document().frame(); 67 WebKit::WebFrame* plugin_frame = plugin_element.document().frame();
68 if (!plugin_frame) 68 if (!plugin_frame)
69 return false; 69 return false;
70 70
71 *security_origin = plugin_frame->securityOrigin(); 71 *security_origin = plugin_frame->securityOrigin();
72 return true; 72 return true;
73 } 73 }
74 74
75 PP_Var Canonicalize(PP_Var url, PP_UrlComponents* components) { 75 PP_Var Canonicalize(PP_Var url, PP_UrlComponents_Dev* components) {
76 String* url_string = GetString(url); 76 String* url_string = GetString(url);
77 if (!url_string) 77 if (!url_string)
78 return PP_MakeNull(); 78 return PP_MakeNull();
79 return GenerateUrlReturn(GURL(url_string->value()), components); 79 return GenerateUrlReturn(GURL(url_string->value()), components);
80 } 80 }
81 81
82 PP_Var ResolveRelativeToUrl(PP_Var base_url, 82 PP_Var ResolveRelativeToUrl(PP_Var base_url,
83 PP_Var relative, 83 PP_Var relative,
84 PP_UrlComponents* components) { 84 PP_UrlComponents_Dev* components) {
85 String* base_url_string = GetString(base_url); 85 String* base_url_string = GetString(base_url);
86 String* relative_string = GetString(relative); 86 String* relative_string = GetString(relative);
87 if (!base_url_string || !relative_string) 87 if (!base_url_string || !relative_string)
88 return PP_MakeNull(); 88 return PP_MakeNull();
89 89
90 GURL base_gurl(base_url_string->value()); 90 GURL base_gurl(base_url_string->value());
91 if (!base_gurl.is_valid()) 91 if (!base_gurl.is_valid())
92 return PP_MakeNull(); 92 return PP_MakeNull();
93 return GenerateUrlReturn(base_gurl.Resolve(relative_string->value()), 93 return GenerateUrlReturn(base_gurl.Resolve(relative_string->value()),
94 components); 94 components);
95 } 95 }
96 96
97 PP_Var ResolveRelativeToDocument(PP_Instance instance_id, 97 PP_Var ResolveRelativeToDocument(PP_Instance instance_id,
98 PP_Var relative, 98 PP_Var relative,
99 PP_UrlComponents* components) { 99 PP_UrlComponents_Dev* components) {
100 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); 100 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
101 if (!instance) 101 if (!instance)
102 return PP_MakeNull(); 102 return PP_MakeNull();
103 103
104 String* relative_string = GetString(relative); 104 String* relative_string = GetString(relative);
105 if (!relative_string) 105 if (!relative_string)
106 return PP_MakeNull(); 106 return PP_MakeNull();
107 107
108 WebKit::WebElement plugin_element = instance->container()->element(); 108 WebKit::WebElement plugin_element = instance->container()->element();
109 GURL document_url = plugin_element.document().baseURL(); 109 GURL document_url = plugin_element.document().baseURL();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 WebKit::WebSecurityOrigin target_origin; 149 WebKit::WebSecurityOrigin target_origin;
150 if (!SecurityOriginForInstance(active, &target_origin)) 150 if (!SecurityOriginForInstance(active, &target_origin))
151 return false; 151 return false;
152 152
153 return active_origin.canAccess(target_origin); 153 return active_origin.canAccess(target_origin);
154 } 154 }
155 155
156 } // namespace 156 } // namespace
157 157
158 const PPB_UrlUtil ppb_url_util = { 158 const PPB_UrlUtil_Dev ppb_url_util = {
159 &Canonicalize, 159 &Canonicalize,
160 &ResolveRelativeToUrl, 160 &ResolveRelativeToUrl,
161 &ResolveRelativeToDocument, 161 &ResolveRelativeToDocument,
162 &IsSameSecurityOrigin, 162 &IsSameSecurityOrigin,
163 &DocumentCanRequest, 163 &DocumentCanRequest,
164 &DocumentCanAccessDocument 164 &DocumentCanAccessDocument
165 }; 165 };
166 166
167 const PPB_UrlUtil* GetUrlUtilInterface() { 167 // static
168 const PPB_UrlUtil_Dev* UrlUtil::GetInterface() {
168 return &ppb_url_util; 169 return &ppb_url_util;
169 } 170 }
170 171
171 } // namespace pepper 172 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_url_util.h ('k') | webkit/glue/plugins/pepper_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698