| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/npapi/webplugin_impl.h" | 5 #include "content/renderer/npapi/webplugin_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 WebHTTPBody http_body; | 643 WebHTTPBody http_body; |
| 644 if (body.size()) { | 644 if (body.size()) { |
| 645 http_body.initialize(); | 645 http_body.initialize(); |
| 646 http_body.appendData(WebData(&body[0], body.size())); | 646 http_body.appendData(WebData(&body[0], body.size())); |
| 647 } | 647 } |
| 648 request->setHTTPBody(http_body); | 648 request->setHTTPBody(http_body); |
| 649 | 649 |
| 650 return rv; | 650 return rv; |
| 651 } | 651 } |
| 652 | 652 |
| 653 bool WebPluginImpl::IsValidUrl(const GURL& url, Referrer referrer_flag) { | 653 bool WebPluginImpl::IsValidUrl(const GURL& url, ReferrerValue referrer_flag) { |
| 654 if (referrer_flag == PLUGIN_SRC && | 654 if (referrer_flag == PLUGIN_SRC && |
| 655 mime_type_ == kFlashPluginSwfMimeType && | 655 mime_type_ == kFlashPluginSwfMimeType && |
| 656 url.GetOrigin() != plugin_url_.GetOrigin()) { | 656 url.GetOrigin() != plugin_url_.GetOrigin()) { |
| 657 // Do url check to make sure that there are no @, ;, \ chars in between url | 657 // Do url check to make sure that there are no @, ;, \ chars in between url |
| 658 // scheme and url path. | 658 // scheme and url path. |
| 659 const char* url_to_check(url.spec().data()); | 659 const char* url_to_check(url.spec().data()); |
| 660 url::Parsed parsed; | 660 url::Parsed parsed; |
| 661 url::ParseStandardURL(url_to_check, strlen(url_to_check), &parsed); | 661 url::ParseStandardURL(url_to_check, strlen(url_to_check), &parsed); |
| 662 if (parsed.path.begin <= parsed.scheme.end()) | 662 if (parsed.path.begin <= parsed.scheme.end()) |
| 663 return true; | 663 return true; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 675 | 675 |
| 676 WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( | 676 WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( |
| 677 const char* url, | 677 const char* url, |
| 678 bool is_javascript_url, | 678 bool is_javascript_url, |
| 679 bool popups_allowed, | 679 bool popups_allowed, |
| 680 const char* method, | 680 const char* method, |
| 681 const char* target, | 681 const char* target, |
| 682 const char* buf, | 682 const char* buf, |
| 683 unsigned int len, | 683 unsigned int len, |
| 684 int notify_id, | 684 int notify_id, |
| 685 Referrer referrer_flag) { | 685 ReferrerValue referrer_flag) { |
| 686 // If there is no target, there is nothing to do | 686 // If there is no target, there is nothing to do |
| 687 if (!target) | 687 if (!target) |
| 688 return NOT_ROUTED; | 688 return NOT_ROUTED; |
| 689 | 689 |
| 690 // This could happen if the WebPluginContainer was already deleted. | 690 // This could happen if the WebPluginContainer was already deleted. |
| 691 if (!webframe_) | 691 if (!webframe_) |
| 692 return NOT_ROUTED; | 692 return NOT_ROUTED; |
| 693 | 693 |
| 694 WebString target_str = WebString::fromUTF8(target); | 694 WebString target_str = WebString::fromUTF8(target); |
| 695 | 695 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 notify_redirects, false); | 1154 notify_redirects, false); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 void WebPluginImpl::HandleURLRequestInternal(const char* url, | 1157 void WebPluginImpl::HandleURLRequestInternal(const char* url, |
| 1158 const char* method, | 1158 const char* method, |
| 1159 const char* target, | 1159 const char* target, |
| 1160 const char* buf, | 1160 const char* buf, |
| 1161 unsigned int len, | 1161 unsigned int len, |
| 1162 int notify_id, | 1162 int notify_id, |
| 1163 bool popups_allowed, | 1163 bool popups_allowed, |
| 1164 Referrer referrer_flag, | 1164 ReferrerValue referrer_flag, |
| 1165 bool notify_redirects, | 1165 bool notify_redirects, |
| 1166 bool is_plugin_src_load) { | 1166 bool is_plugin_src_load) { |
| 1167 // For this request, we either route the output to a frame | 1167 // For this request, we either route the output to a frame |
| 1168 // because a target has been specified, or we handle the request | 1168 // because a target has been specified, or we handle the request |
| 1169 // here, i.e. by executing the script if it is a javascript url | 1169 // here, i.e. by executing the script if it is a javascript url |
| 1170 // or by initiating a download on the URL, etc. There is one special | 1170 // or by initiating a download on the URL, etc. There is one special |
| 1171 // case in that the request is a javascript url and the target is "_self", | 1171 // case in that the request is a javascript url and the target is "_self", |
| 1172 // in which case we route the output to the plugin rather than routing it | 1172 // in which case we route the output to the plugin rather than routing it |
| 1173 // to the plugin's frame. | 1173 // to the plugin's frame. |
| 1174 bool is_javascript_url = | 1174 bool is_javascript_url = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 // we want to fetch the data in the plugin process as the renderer won't be | 1226 // we want to fetch the data in the plugin process as the renderer won't be |
| 1227 // able to request any origin when site isolation is in place. So bounce | 1227 // able to request any origin when site isolation is in place. So bounce |
| 1228 // this request back to the plugin process which will use ResourceDispatcher | 1228 // this request back to the plugin process which will use ResourceDispatcher |
| 1229 // to fetch the url. | 1229 // to fetch the url. |
| 1230 | 1230 |
| 1231 // TODO(jam): any better way of getting this? Can't find a way to get | 1231 // TODO(jam): any better way of getting this? Can't find a way to get |
| 1232 // frame()->loader()->outgoingReferrer() which | 1232 // frame()->loader()->outgoingReferrer() which |
| 1233 // WebFrameImpl::setReferrerForRequest does. | 1233 // WebFrameImpl::setReferrerForRequest does. |
| 1234 WebURLRequest request(complete_url); | 1234 WebURLRequest request(complete_url); |
| 1235 SetReferrer(&request, referrer_flag); | 1235 SetReferrer(&request, referrer_flag); |
| 1236 GURL referrer( | 1236 Referrer referrer( |
| 1237 request.httpHeaderField(WebString::fromUTF8("Referer")).utf8()); | 1237 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 1238 request.referrerPolicy()); |
| 1238 | 1239 |
| 1239 GURL first_party_for_cookies = webframe_->document().firstPartyForCookies(); | 1240 GURL first_party_for_cookies = webframe_->document().firstPartyForCookies(); |
| 1240 delegate_->FetchURL(resource_id, notify_id, complete_url, | 1241 delegate_->FetchURL(resource_id, notify_id, complete_url, |
| 1241 first_party_for_cookies, method, buf, len, referrer, | 1242 first_party_for_cookies, method, buf, len, referrer, |
| 1242 notify_redirects, is_plugin_src_load, 0, | 1243 notify_redirects, is_plugin_src_load, 0, |
| 1243 render_frame_->GetRoutingID(), | 1244 render_frame_->GetRoutingID(), |
| 1244 render_view_->GetRoutingID()); | 1245 render_view_->GetRoutingID()); |
| 1245 } else { | 1246 } else { |
| 1246 WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( | 1247 WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( |
| 1247 resource_id, complete_url, notify_id); | 1248 resource_id, complete_url, notify_id); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1262 return view->createUniqueIdentifierForRequest(); | 1263 return view->createUniqueIdentifierForRequest(); |
| 1263 } | 1264 } |
| 1264 | 1265 |
| 1265 bool WebPluginImpl::InitiateHTTPRequest(unsigned long resource_id, | 1266 bool WebPluginImpl::InitiateHTTPRequest(unsigned long resource_id, |
| 1266 WebPluginResourceClient* client, | 1267 WebPluginResourceClient* client, |
| 1267 const GURL& url, | 1268 const GURL& url, |
| 1268 const char* method, | 1269 const char* method, |
| 1269 const char* buf, | 1270 const char* buf, |
| 1270 int buf_len, | 1271 int buf_len, |
| 1271 const char* range_info, | 1272 const char* range_info, |
| 1272 Referrer referrer_flag, | 1273 ReferrerValue referrer_flag, |
| 1273 bool notify_redirects, | 1274 bool notify_redirects, |
| 1274 bool is_plugin_src_load) { | 1275 bool is_plugin_src_load) { |
| 1275 if (!client) { | 1276 if (!client) { |
| 1276 NOTREACHED(); | 1277 NOTREACHED(); |
| 1277 return false; | 1278 return false; |
| 1278 } | 1279 } |
| 1279 | 1280 |
| 1280 ClientInfo info; | 1281 ClientInfo info; |
| 1281 info.id = resource_id; | 1282 info.id = resource_id; |
| 1282 info.client = client; | 1283 info.client = client; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 client_index = clients_.erase(client_index); | 1514 client_index = clients_.erase(client_index); |
| 1514 } | 1515 } |
| 1515 | 1516 |
| 1516 // This needs to be called now and not in the destructor since the | 1517 // This needs to be called now and not in the destructor since the |
| 1517 // webframe_ might not be valid anymore. | 1518 // webframe_ might not be valid anymore. |
| 1518 webframe_ = NULL; | 1519 webframe_ = NULL; |
| 1519 weak_factory_.InvalidateWeakPtrs(); | 1520 weak_factory_.InvalidateWeakPtrs(); |
| 1520 } | 1521 } |
| 1521 | 1522 |
| 1522 void WebPluginImpl::SetReferrer(blink::WebURLRequest* request, | 1523 void WebPluginImpl::SetReferrer(blink::WebURLRequest* request, |
| 1523 Referrer referrer_flag) { | 1524 ReferrerValue referrer_flag) { |
| 1524 switch (referrer_flag) { | 1525 switch (referrer_flag) { |
| 1525 case DOCUMENT_URL: | 1526 case DOCUMENT_URL: |
| 1526 webframe_->setReferrerForRequest(*request, GURL()); | 1527 webframe_->setReferrerForRequest(*request, GURL()); |
| 1527 break; | 1528 break; |
| 1528 | 1529 |
| 1529 case PLUGIN_SRC: | 1530 case PLUGIN_SRC: |
| 1530 webframe_->setReferrerForRequest(*request, plugin_url_); | 1531 webframe_->setReferrerForRequest(*request, plugin_url_); |
| 1531 break; | 1532 break; |
| 1532 | 1533 |
| 1533 default: | 1534 default: |
| 1534 break; | 1535 break; |
| 1535 } | 1536 } |
| 1536 } | 1537 } |
| 1537 | 1538 |
| 1538 } // namespace content | 1539 } // namespace content |
| OLD | NEW |