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

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

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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_response_info.cc ('k') | webkit/glue/plugins/pepper_var.cc » ('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 "ppapi/c/dev/ppb_url_util_dev.h" 8 #include "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_common.h"
16 #include "webkit/glue/plugins/pepper_plugin_instance.h" 17 #include "webkit/glue/plugins/pepper_plugin_instance.h"
17 #include "webkit/glue/plugins/pepper_string.h" 18 #include "webkit/glue/plugins/pepper_string.h"
18 #include "webkit/glue/plugins/pepper_var.h" 19 #include "webkit/glue/plugins/pepper_var.h"
19 20
20 namespace pepper { 21 namespace pepper {
21 22
22 namespace { 23 namespace {
23 24
24 void ConvertComponent(const url_parse::Component& input, 25 void ConvertComponent(const url_parse::Component& input,
25 PP_UrlComponent_Dev* output) { 26 PP_UrlComponent_Dev* output) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (!relative_string) 109 if (!relative_string)
109 return PP_MakeNull(); 110 return PP_MakeNull();
110 111
111 WebKit::WebElement plugin_element = instance->container()->element(); 112 WebKit::WebElement plugin_element = instance->container()->element();
112 GURL document_url = plugin_element.document().baseURL(); 113 GURL document_url = plugin_element.document().baseURL();
113 return GenerateUrlReturn(instance->module(), 114 return GenerateUrlReturn(instance->module(),
114 document_url.Resolve(relative_string->value()), 115 document_url.Resolve(relative_string->value()),
115 components); 116 components);
116 } 117 }
117 118
118 bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { 119 PP_Bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) {
119 scoped_refptr<StringVar> url_a_string(StringVar::FromPPVar(url_a)); 120 scoped_refptr<StringVar> url_a_string(StringVar::FromPPVar(url_a));
120 scoped_refptr<StringVar> url_b_string(StringVar::FromPPVar(url_b)); 121 scoped_refptr<StringVar> url_b_string(StringVar::FromPPVar(url_b));
121 if (!url_a_string || !url_b_string) 122 if (!url_a_string || !url_b_string)
122 return false; 123 return PP_FALSE;
123 124
124 GURL gurl_a(url_a_string->value()); 125 GURL gurl_a(url_a_string->value());
125 GURL gurl_b(url_b_string->value()); 126 GURL gurl_b(url_b_string->value());
126 if (!gurl_a.is_valid() || !gurl_b.is_valid()) 127 if (!gurl_a.is_valid() || !gurl_b.is_valid())
127 return false; 128 return PP_FALSE;
128 129
129 return gurl_a.GetOrigin() == gurl_b.GetOrigin(); 130 return BoolToPPBool(gurl_a.GetOrigin() == gurl_b.GetOrigin());
130 } 131 }
131 132
132 bool DocumentCanRequest(PP_Instance instance, PP_Var url) { 133 PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) {
133 scoped_refptr<StringVar> url_string(StringVar::FromPPVar(url)); 134 scoped_refptr<StringVar> url_string(StringVar::FromPPVar(url));
134 if (!url_string) 135 if (!url_string)
135 return false; 136 return PP_FALSE;
136 137
137 WebKit::WebSecurityOrigin security_origin; 138 WebKit::WebSecurityOrigin security_origin;
138 if (!SecurityOriginForInstance(instance, &security_origin)) 139 if (!SecurityOriginForInstance(instance, &security_origin))
139 return false; 140 return PP_FALSE;
140 141
141 GURL gurl(url_string->value()); 142 GURL gurl(url_string->value());
142 if (!gurl.is_valid()) 143 if (!gurl.is_valid())
143 return false; 144 return PP_FALSE;
144 145
145 return security_origin.canRequest(gurl); 146 return BoolToPPBool(security_origin.canRequest(gurl));
146 } 147 }
147 148
148 bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) { 149 PP_Bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) {
149 WebKit::WebSecurityOrigin active_origin; 150 WebKit::WebSecurityOrigin active_origin;
150 if (!SecurityOriginForInstance(active, &active_origin)) 151 if (!SecurityOriginForInstance(active, &active_origin))
151 return false; 152 return PP_FALSE;
152 153
153 WebKit::WebSecurityOrigin target_origin; 154 WebKit::WebSecurityOrigin target_origin;
154 if (!SecurityOriginForInstance(active, &target_origin)) 155 if (!SecurityOriginForInstance(active, &target_origin))
155 return false; 156 return PP_FALSE;
156 157
157 return active_origin.canAccess(target_origin); 158 return BoolToPPBool(active_origin.canAccess(target_origin));
158 } 159 }
159 160
160 } // namespace 161 } // namespace
161 162
162 const PPB_UrlUtil_Dev ppb_url_util = { 163 const PPB_UrlUtil_Dev ppb_url_util = {
163 &Canonicalize, 164 &Canonicalize,
164 &ResolveRelativeToUrl, 165 &ResolveRelativeToUrl,
165 &ResolveRelativeToDocument, 166 &ResolveRelativeToDocument,
166 &IsSameSecurityOrigin, 167 &IsSameSecurityOrigin,
167 &DocumentCanRequest, 168 &DocumentCanRequest,
168 &DocumentCanAccessDocument 169 &DocumentCanAccessDocument
169 }; 170 };
170 171
171 // static 172 // static
172 const PPB_UrlUtil_Dev* UrlUtil::GetInterface() { 173 const PPB_UrlUtil_Dev* UrlUtil::GetInterface() {
173 return &ppb_url_util; 174 return &ppb_url_util;
174 } 175 }
175 176
176 } // namespace pepper 177 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_url_response_info.cc ('k') | webkit/glue/plugins/pepper_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698