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

Side by Side Diff: content/renderer/npapi/webplugin_impl.cc

Issue 1426923007: Remove PluginLoadObserver and related logic, it was only used for NPAPI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
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/location.h" 10 #include "base/location.h"
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 456
457 void WebPluginImpl::didFinishLoading() { 457 void WebPluginImpl::didFinishLoading() {
458 delegate_->DidFinishManualLoading(); 458 delegate_->DidFinishManualLoading();
459 } 459 }
460 460
461 void WebPluginImpl::didFailLoading(const WebURLError& error) { 461 void WebPluginImpl::didFailLoading(const WebURLError& error) {
462 if (!ignore_response_error_) 462 if (!ignore_response_error_)
463 delegate_->DidManualLoadFail(); 463 delegate_->DidManualLoadFail();
464 } 464 }
465 465
466 void WebPluginImpl::didFinishLoadingFrameRequest(
467 const WebURL& url, void* notify_data) {
468 if (delegate_) {
469 // We're converting a void* into an arbitrary int id. Though
470 // these types are the same size on all the platforms we support,
471 // the compiler may complain as though they are different, so to
472 // make the casting gods happy go through an intptr_t (the union
473 // of void* and int) rather than converting straight across.
474 delegate_->DidFinishLoadWithReason(
475 url, NPRES_DONE, reinterpret_cast<intptr_t>(notify_data));
476 }
477 }
478
479 void WebPluginImpl::didFailLoadingFrameRequest(
480 const WebURL& url, void* notify_data, const WebURLError& error) {
481 if (!delegate_)
482 return;
483
484 NPReason reason =
485 error.reason == net::ERR_ABORTED ? NPRES_USER_BREAK : NPRES_NETWORK_ERR;
486 // See comment in didFinishLoadingFrameRequest about the cast here.
487 delegate_->DidFinishLoadWithReason(
488 url, reason, reinterpret_cast<intptr_t>(notify_data));
489 }
490
491 bool WebPluginImpl::isPlaceholder() { 466 bool WebPluginImpl::isPlaceholder() {
492 return false; 467 return false;
493 } 468 }
494 469
495 WebPluginImpl::LoaderClient::LoaderClient(WebPluginImpl* parent) 470 WebPluginImpl::LoaderClient::LoaderClient(WebPluginImpl* parent)
496 : parent_(parent) {} 471 : parent_(parent) {}
497 472
498 void WebPluginImpl::LoaderClient::willFollowRedirect( 473 void WebPluginImpl::LoaderClient::willFollowRedirect(
499 blink::WebURLLoader* loader, blink::WebURLRequest& new_request, 474 blink::WebURLLoader* loader, blink::WebURLRequest& new_request,
500 const blink::WebURLResponse& redirect_response) { 475 const blink::WebURLResponse& redirect_response) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 665 }
691 666
692 WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( 667 WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame(
693 const char* url, 668 const char* url,
694 bool is_javascript_url, 669 bool is_javascript_url,
695 bool popups_allowed, 670 bool popups_allowed,
696 const char* method, 671 const char* method,
697 const char* target, 672 const char* target,
698 const char* buf, 673 const char* buf,
699 unsigned int len, 674 unsigned int len,
700 int notify_id,
701 ReferrerValue referrer_flag) { 675 ReferrerValue referrer_flag) {
702 // If there is no target, there is nothing to do 676 // If there is no target, there is nothing to do
703 if (!target) 677 if (!target)
704 return NOT_ROUTED; 678 return NOT_ROUTED;
705 679
706 // This could happen if the WebPluginContainer was already deleted. 680 // This could happen if the WebPluginContainer was already deleted.
707 if (!webframe_) 681 if (!webframe_)
708 return NOT_ROUTED; 682 return NOT_ROUTED;
709 683
710 WebString target_str = WebString::fromUTF8(target); 684 WebString target_str = WebString::fromUTF8(target);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 request.setSkipServiceWorker(true); 728 request.setSkipServiceWorker(true);
755 if (len > 0) { 729 if (len > 0) {
756 if (!SetPostData(&request, buf, len)) { 730 if (!SetPostData(&request, buf, len)) {
757 // Uhoh - we're in trouble. There isn't a good way 731 // Uhoh - we're in trouble. There isn't a good way
758 // to recover at this point. Break out. 732 // to recover at this point. Break out.
759 NOTREACHED(); 733 NOTREACHED();
760 return ROUTED; 734 return ROUTED;
761 } 735 }
762 } 736 }
763 737
764 container_->loadFrameRequest( 738 container_->loadFrameRequest(request, target_str);
765 request, target_str, notify_id != 0, reinterpret_cast<void*>(notify_id));
766 return ROUTED; 739 return ROUTED;
767 } 740 }
768 741
769 NPObject* WebPluginImpl::GetWindowScriptNPObject() { 742 NPObject* WebPluginImpl::GetWindowScriptNPObject() {
770 if (!webframe_) { 743 if (!webframe_) {
771 NOTREACHED(); 744 NOTREACHED();
772 return NULL; 745 return NULL;
773 } 746 }
774 return webframe_->windowObject(); 747 return webframe_->windowObject();
775 } 748 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 container_->invalidate(); 868 container_->invalidate();
896 } 869 }
897 870
898 void WebPluginImpl::InvalidateRect(const gfx::Rect& rect) { 871 void WebPluginImpl::InvalidateRect(const gfx::Rect& rect) {
899 if (container_) 872 if (container_)
900 container_->invalidateRect(rect); 873 container_->invalidateRect(rect);
901 } 874 }
902 875
903 void WebPluginImpl::OnDownloadPluginSrcUrl() { 876 void WebPluginImpl::OnDownloadPluginSrcUrl() {
904 HandleURLRequestInternal( 877 HandleURLRequestInternal(
905 plugin_url_.spec().c_str(), "GET", NULL, NULL, 0, 0, false, DOCUMENT_URL, 878 plugin_url_.spec().c_str(), "GET", NULL, NULL, 0, false, DOCUMENT_URL,
906 false, true); 879 false, true);
907 } 880 }
908 881
909 WebPluginResourceClient* WebPluginImpl::GetClientFromLoader( 882 WebPluginResourceClient* WebPluginImpl::GetClientFromLoader(
910 WebURLLoader* loader) { 883 WebURLLoader* loader) {
911 ClientInfo* client_info = GetClientInfoFromLoader(loader); 884 ClientInfo* client_info = GetClientInfoFromLoader(loader);
912 if (client_info) 885 if (client_info)
913 return client_info->client; 886 return client_info->client;
914 return NULL; 887 return NULL;
915 } 888 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 // seekable streams. 1004 // seekable streams.
1032 request_is_seekable = false; 1005 request_is_seekable = false;
1033 1006
1034 delete client; 1007 delete client;
1035 client = NULL; 1008 client = NULL;
1036 1009
1037 // Create a new resource client for this request. 1010 // Create a new resource client for this request.
1038 for (size_t i = 0; i < clients_.size(); ++i) { 1011 for (size_t i = 0; i < clients_.size(); ++i) {
1039 if (clients_[i].loader.get() == loader) { 1012 if (clients_[i].loader.get() == loader) {
1040 WebPluginResourceClient* resource_client = 1013 WebPluginResourceClient* resource_client =
1041 delegate_->CreateResourceClient(clients_[i].id, plugin_url_, 0); 1014 delegate_->CreateResourceClient(clients_[i].id, plugin_url_);
1042 clients_[i].client = resource_client; 1015 clients_[i].client = resource_client;
1043 client = resource_client; 1016 client = resource_client;
1044 break; 1017 break;
1045 } 1018 }
1046 } 1019 }
1047 1020
1048 DCHECK(client != NULL); 1021 DCHECK(client != NULL);
1049 } 1022 }
1050 } 1023 }
1051 1024
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 container_ = container; 1129 container_ = container;
1157 if (container_) 1130 if (container_)
1158 container_->allowScriptObjects(); 1131 container_->allowScriptObjects();
1159 } 1132 }
1160 1133
1161 void WebPluginImpl::HandleURLRequest(const char* url, 1134 void WebPluginImpl::HandleURLRequest(const char* url,
1162 const char* method, 1135 const char* method,
1163 const char* target, 1136 const char* target,
1164 const char* buf, 1137 const char* buf,
1165 unsigned int len, 1138 unsigned int len,
1166 int notify_id,
1167 bool popups_allowed, 1139 bool popups_allowed,
1168 bool notify_redirects) { 1140 bool notify_redirects) {
1169 // GetURL/PostURL requests initiated explicitly by plugins should specify the 1141 // GetURL/PostURL requests initiated explicitly by plugins should specify the
1170 // plugin SRC url as the referrer if it is available. 1142 // plugin SRC url as the referrer if it is available.
1171 HandleURLRequestInternal( 1143 HandleURLRequestInternal(
1172 url, method, target, buf, len, notify_id, popups_allowed, PLUGIN_SRC, 1144 url, method, target, buf, len, popups_allowed, PLUGIN_SRC,
1173 notify_redirects, false); 1145 notify_redirects, false);
1174 } 1146 }
1175 1147
1176 void WebPluginImpl::HandleURLRequestInternal(const char* url, 1148 void WebPluginImpl::HandleURLRequestInternal(const char* url,
1177 const char* method, 1149 const char* method,
1178 const char* target, 1150 const char* target,
1179 const char* buf, 1151 const char* buf,
1180 unsigned int len, 1152 unsigned int len,
1181 int notify_id,
1182 bool popups_allowed, 1153 bool popups_allowed,
1183 ReferrerValue referrer_flag, 1154 ReferrerValue referrer_flag,
1184 bool notify_redirects, 1155 bool notify_redirects,
1185 bool is_plugin_src_load) { 1156 bool is_plugin_src_load) {
1186 // For this request, we either route the output to a frame 1157 // For this request, we either route the output to a frame
1187 // because a target has been specified, or we handle the request 1158 // because a target has been specified, or we handle the request
1188 // here, i.e. by executing the script if it is a javascript url 1159 // here, i.e. by executing the script if it is a javascript url
1189 // or by initiating a download on the URL, etc. There is one special 1160 // or by initiating a download on the URL, etc. There is one special
1190 // case in that the request is a javascript url and the target is "_self", 1161 // case in that the request is a javascript url and the target is "_self",
1191 // in which case we route the output to the plugin rather than routing it 1162 // in which case we route the output to the plugin rather than routing it
1192 // to the plugin's frame. 1163 // to the plugin's frame.
1193 bool is_javascript_url = 1164 bool is_javascript_url =
1194 url::FindAndCompareScheme(url, strlen(url), url::kJavaScriptScheme, NULL); 1165 url::FindAndCompareScheme(url, strlen(url), url::kJavaScriptScheme, NULL);
1195 RoutingStatus routing_status = RouteToFrame( 1166 RoutingStatus routing_status = RouteToFrame(
1196 url, is_javascript_url, popups_allowed, method, target, buf, len, 1167 url, is_javascript_url, popups_allowed, method, target, buf, len,
1197 notify_id, referrer_flag); 1168 referrer_flag);
1198 if (routing_status == ROUTED) 1169 if (routing_status == ROUTED)
1199 return; 1170 return;
1200 1171
1201 if (is_javascript_url) { 1172 if (is_javascript_url) {
1202 GURL gurl(url); 1173 GURL gurl(url);
1203 WebString result = container_->executeScriptURL(gurl, popups_allowed); 1174 WebString result = container_->executeScriptURL(gurl, popups_allowed);
1204 1175
1205 // delegate_ could be NULL because executeScript caused the container to 1176 // delegate_ could be NULL because executeScript caused the container to
1206 // be deleted. 1177 // be deleted.
1207 if (delegate_) { 1178 if (delegate_) {
1208 delegate_->SendJavaScriptStream( 1179 delegate_->SendJavaScriptStream(gurl, result.utf8(), !result.isNull());
1209 gurl, result.utf8(), !result.isNull(), notify_id);
1210 } 1180 }
1211 1181
1212 return; 1182 return;
1213 } 1183 }
1214 1184
1215 unsigned long resource_id = GetNextResourceId(); 1185 unsigned long resource_id = GetNextResourceId();
1216 if (!resource_id) 1186 if (!resource_id)
1217 return; 1187 return;
1218 1188
1219 GURL complete_url = CompleteURL(url); 1189 GURL complete_url = CompleteURL(url);
1220 // Remove when flash bug is fixed. http://crbug.com/40016. 1190 // Remove when flash bug is fixed. http://crbug.com/40016.
1221 if (!WebPluginImpl::IsValidUrl(complete_url, referrer_flag)) 1191 if (!WebPluginImpl::IsValidUrl(complete_url, referrer_flag))
1222 return; 1192 return;
1223 1193
1224 // If the RouteToFrame call returned a failure then inform the result 1194 // If the RouteToFrame call returned a failure then inform the result
1225 // back to the plugin asynchronously. 1195 // back to the plugin asynchronously.
1226 if ((routing_status == INVALID_URL) || 1196 if ((routing_status == INVALID_URL) ||
1227 (routing_status == GENERAL_FAILURE)) { 1197 (routing_status == GENERAL_FAILURE)) {
1228 WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( 1198 WebPluginResourceClient* resource_client = delegate_->CreateResourceClient(
1229 resource_id, complete_url, notify_id); 1199 resource_id, complete_url);
1230 if (resource_client) 1200 if (resource_client)
1231 resource_client->DidFail(resource_id); 1201 resource_client->DidFail(resource_id);
1232 return; 1202 return;
1233 } 1203 }
1234 1204
1235 // CreateResourceClient() sends a synchronous IPC message so it's possible 1205 // CreateResourceClient() sends a synchronous IPC message so it's possible
1236 // that TearDownPluginInstance() may have been called in the nested 1206 // that TearDownPluginInstance() may have been called in the nested
1237 // message loop. If so, don't start the request. 1207 // message loop. If so, don't start the request.
1238 if (!delegate_) 1208 if (!delegate_)
1239 return; 1209 return;
(...skipping 10 matching lines...) Expand all
1250 // TODO(jam): any better way of getting this? Can't find a way to get 1220 // TODO(jam): any better way of getting this? Can't find a way to get
1251 // frame()->loader()->outgoingReferrer() which 1221 // frame()->loader()->outgoingReferrer() which
1252 // WebFrameImpl::setReferrerForRequest does. 1222 // WebFrameImpl::setReferrerForRequest does.
1253 WebURLRequest request(complete_url); 1223 WebURLRequest request(complete_url);
1254 SetReferrer(&request, referrer_flag); 1224 SetReferrer(&request, referrer_flag);
1255 Referrer referrer( 1225 Referrer referrer(
1256 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), 1226 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
1257 request.referrerPolicy()); 1227 request.referrerPolicy());
1258 1228
1259 GURL first_party_for_cookies = webframe_->document().firstPartyForCookies(); 1229 GURL first_party_for_cookies = webframe_->document().firstPartyForCookies();
1260 delegate_->FetchURL(resource_id, notify_id, complete_url, 1230 delegate_->FetchURL(resource_id, complete_url,
1261 first_party_for_cookies, method, buf, len, referrer, 1231 first_party_for_cookies, method, buf, len, referrer,
1262 notify_redirects, is_plugin_src_load, 0, 1232 notify_redirects, is_plugin_src_load, 0,
1263 render_frame_->GetRoutingID(), 1233 render_frame_->GetRoutingID(),
1264 render_view_->GetRoutingID()); 1234 render_view_->GetRoutingID());
1265 } else { 1235 } else {
1266 WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( 1236 WebPluginResourceClient* resource_client = delegate_->CreateResourceClient(
1267 resource_id, complete_url, notify_id); 1237 resource_id, complete_url);
1268 if (!resource_client) 1238 if (!resource_client)
1269 return; 1239 return;
1270 InitiateHTTPRequest(resource_id, resource_client, complete_url, method, buf, 1240 InitiateHTTPRequest(resource_id, resource_client, complete_url, method, buf,
1271 len, NULL, referrer_flag, notify_redirects, 1241 len, NULL, referrer_flag, notify_redirects,
1272 is_plugin_src_load); 1242 is_plugin_src_load);
1273 } 1243 }
1274 } 1244 }
1275 1245
1276 unsigned long WebPluginImpl::GetNextResourceId() { 1246 unsigned long WebPluginImpl::GetNextResourceId() {
1277 if (!webframe_) 1247 if (!webframe_)
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 case PLUGIN_SRC: 1519 case PLUGIN_SRC:
1550 webframe_->setReferrerForRequest(*request, plugin_url_); 1520 webframe_->setReferrerForRequest(*request, plugin_url_);
1551 break; 1521 break;
1552 1522
1553 default: 1523 default:
1554 break; 1524 break;
1555 } 1525 }
1556 } 1526 }
1557 1527
1558 } // namespace content 1528 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698