OLD | NEW |
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_loader.h" | 5 #include "webkit/glue/plugins/pepper_url_loader.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/dev/ppb_url_loader_dev.h" | 10 #include "ppapi/c/ppb_url_loader.h" |
11 #include "ppapi/c/dev/ppb_url_loader_trusted_dev.h" | 11 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" |
12 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" |
14 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
16 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoader.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoader.h" |
20 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" |
21 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 void Close(PP_Resource loader_id) { | 137 void Close(PP_Resource loader_id) { |
138 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 138 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
139 if (!loader) | 139 if (!loader) |
140 return; | 140 return; |
141 | 141 |
142 loader->Close(); | 142 loader->Close(); |
143 } | 143 } |
144 | 144 |
145 const PPB_URLLoader_Dev ppb_urlloader = { | 145 const PPB_URLLoader ppb_urlloader = { |
146 &Create, | 146 &Create, |
147 &IsURLLoader, | 147 &IsURLLoader, |
148 &Open, | 148 &Open, |
149 &FollowRedirect, | 149 &FollowRedirect, |
150 &GetUploadProgress, | 150 &GetUploadProgress, |
151 &GetDownloadProgress, | 151 &GetDownloadProgress, |
152 &GetResponseInfo, | 152 &GetResponseInfo, |
153 &ReadResponseBody, | 153 &ReadResponseBody, |
154 &FinishStreamingToFile, | 154 &FinishStreamingToFile, |
155 &Close | 155 &Close |
156 }; | 156 }; |
157 | 157 |
158 void GrantUniversalAccess(PP_Resource loader_id) { | 158 void GrantUniversalAccess(PP_Resource loader_id) { |
159 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 159 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
160 if (!loader) | 160 if (!loader) |
161 return; | 161 return; |
162 | 162 |
163 loader->GrantUniversalAccess(); | 163 loader->GrantUniversalAccess(); |
164 } | 164 } |
165 | 165 |
166 void SetStatusCallback(PP_Resource loader_id, | 166 void SetStatusCallback(PP_Resource loader_id, |
167 PP_URLLoaderTrusted_StatusCallback cb) { | 167 PP_URLLoaderTrusted_StatusCallback cb) { |
168 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); | 168 scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); |
169 if (!loader) | 169 if (!loader) |
170 return; | 170 return; |
171 loader->SetStatusCallback(cb); | 171 loader->SetStatusCallback(cb); |
172 } | 172 } |
173 | 173 |
174 const PPB_URLLoaderTrusted_Dev ppb_urlloadertrusted = { | 174 const PPB_URLLoaderTrusted ppb_urlloadertrusted = { |
175 &GrantUniversalAccess, | 175 &GrantUniversalAccess, |
176 &SetStatusCallback | 176 &SetStatusCallback |
177 }; | 177 }; |
178 | 178 |
179 WebKit::WebFrame* GetFrame(PluginInstance* instance) { | 179 WebKit::WebFrame* GetFrame(PluginInstance* instance) { |
180 return instance->container()->element().document().frame(); | 180 return instance->container()->element().document().frame(); |
181 } | 181 } |
182 | 182 |
183 } // namespace | 183 } // namespace |
184 | 184 |
(...skipping 15 matching lines...) Expand all Loading... |
200 status_callback_(NULL) { | 200 status_callback_(NULL) { |
201 instance->AddObserver(this); | 201 instance->AddObserver(this); |
202 } | 202 } |
203 | 203 |
204 URLLoader::~URLLoader() { | 204 URLLoader::~URLLoader() { |
205 if (instance_) | 205 if (instance_) |
206 instance_->RemoveObserver(this); | 206 instance_->RemoveObserver(this); |
207 } | 207 } |
208 | 208 |
209 // static | 209 // static |
210 const PPB_URLLoader_Dev* URLLoader::GetInterface() { | 210 const PPB_URLLoader* URLLoader::GetInterface() { |
211 return &ppb_urlloader; | 211 return &ppb_urlloader; |
212 } | 212 } |
213 | 213 |
214 // static | 214 // static |
215 const PPB_URLLoaderTrusted_Dev* URLLoader::GetTrustedInterface() { | 215 const PPB_URLLoaderTrusted* URLLoader::GetTrustedInterface() { |
216 return &ppb_urlloadertrusted; | 216 return &ppb_urlloadertrusted; |
217 } | 217 } |
218 | 218 |
219 int32_t URLLoader::Open(URLRequestInfo* request, | 219 int32_t URLLoader::Open(URLRequestInfo* request, |
220 PP_CompletionCallback callback) { | 220 PP_CompletionCallback callback) { |
221 if (loader_.get()) | 221 if (loader_.get()) |
222 return PP_ERROR_INPROGRESS; | 222 return PP_ERROR_INPROGRESS; |
223 | 223 |
224 // We only support non-blocking calls. | 224 // We only support non-blocking calls. |
225 if (!callback.func) | 225 if (!callback.func) |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 instance_->pp_instance(), pp_resource, | 519 instance_->pp_instance(), pp_resource, |
520 record_upload_progress_ ? bytes_sent_ : -1, | 520 record_upload_progress_ ? bytes_sent_ : -1, |
521 record_upload_progress_ ? total_bytes_to_be_sent_ : -1, | 521 record_upload_progress_ ? total_bytes_to_be_sent_ : -1, |
522 record_download_progress_ ? bytes_received_ : -1, | 522 record_download_progress_ ? bytes_received_ : -1, |
523 record_download_progress_ ? total_bytes_to_be_received_ : -1); | 523 record_download_progress_ ? total_bytes_to_be_received_ : -1); |
524 } | 524 } |
525 } | 525 } |
526 } | 526 } |
527 | 527 |
528 } // namespace pepper | 528 } // namespace pepper |
OLD | NEW |