Index: content/renderer/npapi/webplugin_impl.cc |
=================================================================== |
--- content/renderer/npapi/webplugin_impl.cc (revision 222265) |
+++ content/renderer/npapi/webplugin_impl.cc (working copy) |
@@ -5,6 +5,7 @@ |
#include "content/renderer/npapi/webplugin_impl.h" |
#include "base/bind.h" |
+#include "base/command_line.h" |
#include "base/debug/crash_logging.h" |
#include "base/logging.h" |
#include "base/memory/linked_ptr.h" |
@@ -20,6 +21,7 @@ |
#include "content/child/npapi/webplugin_resource_client.h" |
#include "content/common/view_messages.h" |
#include "content/public/common/content_constants.h" |
+#include "content/public/common/content_switches.h" |
#include "content/public/renderer/content_renderer_client.h" |
#include "content/renderer/npapi/webplugin_delegate_proxy.h" |
#include "content/renderer/render_process.h" |
@@ -256,7 +258,7 @@ |
SetContainer(container); |
bool ok = plugin_delegate->Initialize( |
- plugin_url_, arg_names_, arg_values_, this, load_manually_); |
+ plugin_url_, arg_names_, arg_values_, load_manually_); |
if (!ok) { |
LOG(ERROR) << "Couldn't initialize plug-in"; |
plugin_delegate->PluginDestroyed(); |
@@ -625,10 +627,6 @@ |
return rv; |
} |
-WebPluginDelegate* WebPluginImpl::delegate() { |
- return delegate_; |
-} |
- |
bool WebPluginImpl::IsValidUrl(const GURL& url, Referrer referrer_flag) { |
if (referrer_flag == PLUGIN_SRC && |
mime_type_ == kFlashPluginSwfMimeType && |
@@ -656,7 +654,7 @@ |
bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); |
if (in_process_plugin) { |
#if defined(OS_WIN) && !defined(USE_AURA) |
- return WebPluginDelegateImpl::Create(file_path_, mime_type_); |
+ return WebPluginDelegateImpl::Create(this, file_path_, mime_type_); |
#else |
// In-proc plugins aren't supported on non-Windows. |
NOTIMPLEMENTED(); |
@@ -664,7 +662,7 @@ |
#endif |
} |
- return new WebPluginDelegateProxy(mime_type_, render_view_); |
+ return new WebPluginDelegateProxy(this, mime_type_, render_view_); |
} |
WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( |
@@ -895,6 +893,8 @@ |
void WebPluginImpl::willSendRequest(WebURLLoader* loader, |
WebURLRequest& request, |
const WebURLResponse& response) { |
+ // TODO(jam): THIS LOGIC IS COPIED IN PluginURLFetcher::OnReceivedRedirect |
+ // until kDirectNPAPIRequests is the default and we can remove this old path. |
WebPluginImpl::ClientInfo* client_info = GetClientInfoFromLoader(loader); |
if (client_info) { |
// Currently this check is just to catch an https -> http redirect when |
@@ -1184,16 +1184,14 @@ |
if (!WebPluginImpl::IsValidUrl(complete_url, referrer_flag)) |
return; |
- WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( |
- resource_id, complete_url, notify_id); |
- if (!resource_client) |
- return; |
- |
// If the RouteToFrame call returned a failure then inform the result |
// back to the plugin asynchronously. |
if ((routing_status == INVALID_URL) || |
(routing_status == GENERAL_FAILURE)) { |
- resource_client->DidFail(resource_id); |
+ WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( |
+ resource_id, complete_url, notify_id); |
+ if (resource_client) |
+ resource_client->DidFail(resource_id); |
return; |
} |
@@ -1203,9 +1201,29 @@ |
if (!delegate_) |
return; |
- InitiateHTTPRequest(resource_id, resource_client, complete_url, method, buf, |
- len, NULL, referrer_flag, notify_redirects, |
- is_plugin_src_load); |
+ if (CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kDirectNPAPIRequests)) { |
+ // TODO(jam): any better way of getting this? Can't find a way to get |
+ // frame()->loader()->outgoingReferrer() which |
+ // WebFrameImpl::setReferrerForRequest does. |
+ WebURLRequest request(complete_url); |
+ SetReferrer(&request, referrer_flag); |
+ GURL referrer( |
+ request.httpHeaderField(WebString::fromUTF8("Referer")).utf8()); |
+ |
+ GURL first_party_for_cookies = webframe_->document().firstPartyForCookies(); |
+ delegate_->FetchURL(resource_id, notify_id, complete_url, |
+ first_party_for_cookies, method, std::string(buf, len), |
+ referrer, notify_redirects, is_plugin_src_load); |
+ } else { |
+ WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( |
+ resource_id, complete_url, notify_id); |
+ if (!resource_client) |
+ return; |
+ InitiateHTTPRequest(resource_id, resource_client, complete_url, method, buf, |
+ len, NULL, referrer_flag, notify_redirects, |
+ is_plugin_src_load); |
+ } |
} |
unsigned long WebPluginImpl::GetNextResourceId() { |
@@ -1382,7 +1400,7 @@ |
container_->allowScriptObjects(); |
bool ok = plugin_delegate && plugin_delegate->Initialize( |
- plugin_url_, arg_names_, arg_values_, this, load_manually_); |
+ plugin_url_, arg_names_, arg_values_, load_manually_); |
if (!ok) { |
container_->clearScriptObjects(); |