diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-29 23:03:57 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-29 23:03:57 +0000 |
commit | 2dd868ff64f453c0da93c072986e1389836e8728 (patch) | |
tree | 89b767170d28968ffcdc7cf2b0770cfa2516da74 | |
parent | e8981b7eda49d88b74239c6c5dad5d0dd093a142 (diff) | |
download | chromium_src-2dd868ff64f453c0da93c072986e1389836e8728.zip chromium_src-2dd868ff64f453c0da93c072986e1389836e8728.tar.gz chromium_src-2dd868ff64f453c0da93c072986e1389836e8728.tar.bz2 |
Stop using the default profile's proxy service for plugin proxy requests, and instead use the associated profile's proxy service. I proxy the IPC through the renderer first, as that makes it easy to get to the associated profile.
BUG=92361,64339
Review URL: http://codereview.chromium.org/7791005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98728 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 90 insertions, 137 deletions
diff --git a/chrome_frame/renderer_glue.cc b/chrome_frame/renderer_glue.cc index 64890ef..d904506 100644 --- a/chrome_frame/renderer_glue.cc +++ b/chrome_frame/renderer_glue.cc @@ -15,10 +15,6 @@ bool IsPluginProcess() { namespace webkit_glue { -bool FindProxyForUrl(const GURL& url, std::string* proxy_list) { - return false; -} - std::string BuildUserAgent(bool mimic_windows) { chrome::VersionInfo version_info; std::string product("Chrome/"); diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc index c8fa8a4..19e9634 100644 --- a/content/browser/plugin_process_host.cc +++ b/content/browser/plugin_process_host.cc @@ -22,7 +22,6 @@ #include "base/utf_string_conversions.h" #include "content/browser/browser_thread.h" #include "content/browser/content_browser_client.h" -#include "content/browser/resolve_proxy_msg_helper.h" #include "content/browser/plugin_service.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_message_filter.h" @@ -265,7 +264,6 @@ bool PluginProcessHost::Init(const webkit::WebPluginInfo& info, SetTerminateChildOnShutdown(false); content::GetContentClient()->browser()->PluginProcessHostCreated(this); - AddFilter(new ResolveProxyMsgHelper(NULL)); return true; } diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc index 8ebefbd..ea762b9 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/browser_render_process_host.cc @@ -414,7 +414,8 @@ void BrowserRenderProcessHost::CreateMessageFilters() { #endif channel_->AddFilter(new TraceMessageFilter()); - channel_->AddFilter(new ResolveProxyMsgHelper(NULL)); + channel_->AddFilter(new ResolveProxyMsgHelper( + browser_context()->GetRequestContextForRenderProcess(id()))); channel_->AddFilter(new QuotaDispatcherHost( id(), browser_context()->GetQuotaManager(), content::GetContentClient()->browser()->CreateQuotaPermissionContext())); diff --git a/content/browser/resolve_proxy_msg_helper.cc b/content/browser/resolve_proxy_msg_helper.cc index b539b57..9d984d7 100644 --- a/content/browser/resolve_proxy_msg_helper.cc +++ b/content/browser/resolve_proxy_msg_helper.cc @@ -5,26 +5,30 @@ #include "content/browser/resolve_proxy_msg_helper.h" #include "base/compiler_specific.h" -#include "content/browser/content_browser_client.h" -#include "content/common/child_process_messages.h" -#include "content/common/content_client.h" +#include "content/common/view_messages.h" #include "net/base/net_errors.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" +ResolveProxyMsgHelper::ResolveProxyMsgHelper( + net::URLRequestContextGetter* getter) + : ALLOW_THIS_IN_INITIALIZER_LIST(callback_( + this, &ResolveProxyMsgHelper::OnResolveProxyCompleted)), + context_getter_(getter), + proxy_service_(NULL) { +} + ResolveProxyMsgHelper::ResolveProxyMsgHelper(net::ProxyService* proxy_service) - : proxy_service_(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(callback_( + : ALLOW_THIS_IN_INITIALIZER_LIST(callback_( this, &ResolveProxyMsgHelper::OnResolveProxyCompleted)), - proxy_service_override_(proxy_service) { + proxy_service_(proxy_service) { } bool ResolveProxyMsgHelper::OnMessageReceived(const IPC::Message& message, bool* message_was_ok) { bool handled = true; IPC_BEGIN_MESSAGE_MAP_EX(ResolveProxyMsgHelper, message, *message_was_ok) - IPC_MESSAGE_HANDLER_DELAY_REPLY(ChildProcessHostMsg_ResolveProxy, - OnResolveProxy) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ResolveProxy, OnResolveProxy) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -44,13 +48,12 @@ void ResolveProxyMsgHelper::OnResolveProxyCompleted(int result) { CHECK(!pending_requests_.empty()); const PendingRequest& completed_req = pending_requests_.front(); - ChildProcessHostMsg_ResolveProxy::WriteReplyParams( - completed_req.reply_msg, result, proxy_info_.ToPacString()); + ViewHostMsg_ResolveProxy::WriteReplyParams( + completed_req.reply_msg, result == net::OK, proxy_info_.ToPacString()); Send(completed_req.reply_msg); // Clear the current (completed) request. pending_requests_.pop_front(); - proxy_service_ = NULL; // Start the next request. if (!pending_requests_.empty()) @@ -62,19 +65,13 @@ void ResolveProxyMsgHelper::StartPendingRequest() { // Verify the request wasn't started yet. DCHECK(NULL == req.pac_req); - DCHECK(NULL == proxy_service_); - // Start the request. - bool ok = GetProxyService(&proxy_service_); - - if (!ok) { - // During shutdown, there may be no ProxyService to use, because the - // default ChromeURLRequestContext has already been NULL-ed out. - LOG(WARNING) << "Failed getting default URLRequestContext"; - OnResolveProxyCompleted(net::ERR_FAILED); - return; + if (context_getter_.get()) { + proxy_service_ = context_getter_->GetURLRequestContext()->proxy_service(); + context_getter_ = NULL; } + // Start the request. int result = proxy_service_->ResolveProxy( req.url, &proxy_info_, &callback_, &req.pac_req, net::BoundNetLog()); @@ -83,35 +80,10 @@ void ResolveProxyMsgHelper::StartPendingRequest() { OnResolveProxyCompleted(result); } -bool ResolveProxyMsgHelper::GetProxyService(net::ProxyService** out) const { - // Unit-tests specify their own proxy service to use. - if (proxy_service_override_) { - *out = proxy_service_override_; - return true; - } - - // If there is no default request context (say during shut down). - // Deprecated; see http://crbug.com/92361 - net::URLRequestContextGetter* context_getter = - content::GetContentClient()->browser()-> - GetDefaultRequestContextDeprecatedCrBug64339(); - if (!context_getter) - return false; - - // Otherwise use the browser's global proxy service. - *out = context_getter->GetURLRequestContext()->proxy_service(); - return true; -} - ResolveProxyMsgHelper::~ResolveProxyMsgHelper() { // Clear all pending requests if the ProxyService is still alive (if we have a // default request context or override). - // Deprecated; see http://crbug.com/92361 - net::URLRequestContextGetter* context_getter = - content::GetContentClient()->browser()-> - GetDefaultRequestContextDeprecatedCrBug64339(); - if (!pending_requests_.empty() && - (context_getter || proxy_service_override_)) { + if (!pending_requests_.empty()) { PendingRequest req = pending_requests_.front(); proxy_service_->CancelPacRequest(req.pac_req); } @@ -122,6 +94,5 @@ ResolveProxyMsgHelper::~ResolveProxyMsgHelper() { delete it->reply_msg; } - proxy_service_ = NULL; pending_requests_.clear(); } diff --git a/content/browser/resolve_proxy_msg_helper.h b/content/browser/resolve_proxy_msg_helper.h index d672a33..f728cf1 100644 --- a/content/browser/resolve_proxy_msg_helper.h +++ b/content/browser/resolve_proxy_msg_helper.h @@ -15,6 +15,10 @@ #include "net/base/completion_callback.h" #include "net/proxy/proxy_service.h" +namespace net { +class URLRequestContextGetter; +} + // Responds to ChildProcessHostMsg_ResolveProxy, kicking off a ProxyResolve // request on the IO thread using the specified proxy service. Completion is // notified through the delegate. If multiple requests are started at the same @@ -27,8 +31,8 @@ // This object is expected to live on the IO thread. class ResolveProxyMsgHelper : public BrowserMessageFilter { public: - // If |proxy_service| is NULL, then the main browser context's proxy service - // will be used. + explicit ResolveProxyMsgHelper(net::URLRequestContextGetter* getter); + // Constructor used by unittests. explicit ResolveProxyMsgHelper(net::ProxyService* proxy_service); // Destruction cancels the current outstanding request, and clears the @@ -48,10 +52,6 @@ class ResolveProxyMsgHelper : public BrowserMessageFilter { // Starts the first pending request. void StartPendingRequest(); - // Get the proxy service instance to use. On success returns true and - // sets |*out|. Otherwise returns false. - bool GetProxyService(net::ProxyService** out) const; - // A PendingRequest is a resolve request that is in progress, or queued. struct PendingRequest { public: @@ -69,7 +69,6 @@ class ResolveProxyMsgHelper : public BrowserMessageFilter { }; // Members for the current outstanding proxy request. - net::ProxyService* proxy_service_; net::CompletionCallbackImpl<ResolveProxyMsgHelper> callback_; net::ProxyInfo proxy_info_; @@ -77,9 +76,8 @@ class ResolveProxyMsgHelper : public BrowserMessageFilter { typedef std::deque<PendingRequest> PendingRequestList; PendingRequestList pending_requests_; - // Specified by unit-tests, to use this proxy service in place of the - // global one. - net::ProxyService* proxy_service_override_; + scoped_refptr<net::URLRequestContextGetter> context_getter_; + net::ProxyService* proxy_service_; }; #endif // CONTENT_BROWSER_RESOLVE_PROXY_MSG_HELPER_H_ diff --git a/content/browser/resolve_proxy_msg_helper_unittest.cc b/content/browser/resolve_proxy_msg_helper_unittest.cc index 346796c..91f35c1 100644 --- a/content/browser/resolve_proxy_msg_helper_unittest.cc +++ b/content/browser/resolve_proxy_msg_helper_unittest.cc @@ -4,7 +4,7 @@ #include "content/browser/resolve_proxy_msg_helper.h" -#include "content/common/child_process_messages.h" +#include "content/common/view_messages.h" #include "ipc/ipc_test_sink.h" #include "net/base/net_errors.h" #include "net/proxy/mock_proxy_resolver.h" @@ -27,12 +27,12 @@ class ResolveProxyMsgHelperTest : public testing::Test, public IPC::Channel::Listener { public: struct PendingResult { - PendingResult(int error_code, + PendingResult(bool result, const std::string& proxy_list) - : error_code(error_code), proxy_list(proxy_list) { + : result(result), proxy_list(proxy_list) { } - int error_code; + bool result; std::string proxy_list; }; @@ -55,9 +55,9 @@ class ResolveProxyMsgHelperTest : public testing::Test, } IPC::Message* GenerateReply() { - int temp_int; + bool temp_bool; std::string temp_string; - ChildProcessHostMsg_ResolveProxy message(GURL(), &temp_int, &temp_string); + ViewHostMsg_ResolveProxy message(GURL(), &temp_bool, &temp_string); return IPC::SyncMessage::GenerateReply(&message); } @@ -68,10 +68,8 @@ class ResolveProxyMsgHelperTest : public testing::Test, private: virtual bool OnMessageReceived(const IPC::Message& msg) { - TupleTypes<ChildProcessHostMsg_ResolveProxy::ReplyParam>::ValueTuple - reply_data; - EXPECT_TRUE( - ChildProcessHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data)); + TupleTypes<ViewHostMsg_ResolveProxy::ReplyParam>::ValueTuple reply_data; + EXPECT_TRUE(ViewHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data)); DCHECK(!pending_result_.get()); pending_result_.reset(new PendingResult(reply_data.a, reply_data.b)); test_sink_.ClearMessages(); @@ -108,7 +106,7 @@ TEST_F(ResolveProxyMsgHelperTest, Sequential) { resolver_->pending_requests()[0]->CompleteNow(net::OK); // Check result. - EXPECT_EQ(net::OK, pending_result()->error_code); + EXPECT_EQ(true, pending_result()->result); EXPECT_EQ("PROXY result1:80", pending_result()->proxy_list); clear_pending_result(); @@ -120,7 +118,7 @@ TEST_F(ResolveProxyMsgHelperTest, Sequential) { resolver_->pending_requests()[0]->CompleteNow(net::OK); // Check result. - EXPECT_EQ(net::OK, pending_result()->error_code); + EXPECT_EQ(true, pending_result()->result); EXPECT_EQ("PROXY result2:80", pending_result()->proxy_list); clear_pending_result(); @@ -132,7 +130,7 @@ TEST_F(ResolveProxyMsgHelperTest, Sequential) { resolver_->pending_requests()[0]->CompleteNow(net::OK); // Check result. - EXPECT_EQ(net::OK, pending_result()->error_code); + EXPECT_EQ(true, pending_result()->result); EXPECT_EQ("PROXY result3:80", pending_result()->proxy_list); clear_pending_result(); } @@ -167,7 +165,7 @@ TEST_F(ResolveProxyMsgHelperTest, QueueRequests) { resolver_->pending_requests()[0]->CompleteNow(net::OK); // Check result. - EXPECT_EQ(net::OK, pending_result()->error_code); + EXPECT_EQ(true, pending_result()->result); EXPECT_EQ("PROXY result1:80", pending_result()->proxy_list); clear_pending_result(); @@ -178,7 +176,7 @@ TEST_F(ResolveProxyMsgHelperTest, QueueRequests) { resolver_->pending_requests()[0]->CompleteNow(net::OK); // Check result. - EXPECT_EQ(net::OK, pending_result()->error_code); + EXPECT_EQ(true, pending_result()->result); EXPECT_EQ("PROXY result2:80", pending_result()->proxy_list); clear_pending_result(); @@ -189,7 +187,7 @@ TEST_F(ResolveProxyMsgHelperTest, QueueRequests) { resolver_->pending_requests()[0]->CompleteNow(net::OK); // Check result. - EXPECT_EQ(net::OK, pending_result()->error_code); + EXPECT_EQ(true, pending_result()->result); EXPECT_EQ("PROXY result3:80", pending_result()->proxy_list); clear_pending_result(); } diff --git a/content/common/child_process_messages.h b/content/common/child_process_messages.h index 1d64bf6..6c7b7fd 100644 --- a/content/common/child_process_messages.h +++ b/content/common/child_process_messages.h @@ -52,14 +52,3 @@ IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TraceDataCollected, // Reply to ChildProcessMsg_GetTraceBufferPercentFull. IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TraceBufferPercentFullReply, float /*trace buffer percent full*/) - -// NaCl's 64 bit Windows build only links with a bare-minimum number of -// libraries, and GURL isn't one of them. -#if !defined(NACL_WIN64) -// Get the list of proxies to use for |url|, as a semicolon delimited list -// of "<TYPE> <HOST>:<PORT>" | "DIRECT". -IPC_SYNC_MESSAGE_CONTROL1_2(ChildProcessHostMsg_ResolveProxy, - GURL /* url */, - int /* network error */, - std::string /* proxy list */) -#endif diff --git a/content/common/plugin_messages.h b/content/common/plugin_messages.h index 4909bc2..dd65ce9 100644 --- a/content/common/plugin_messages.h +++ b/content/common/plugin_messages.h @@ -329,6 +329,11 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetPluginElement, int /* route id */, bool /* success */) +IPC_SYNC_MESSAGE_ROUTED1_2(PluginHostMsg_ResolveProxy, + GURL /* url */, + bool /* result */, + std::string /* proxy list */) + IPC_MESSAGE_ROUTED3(PluginHostMsg_SetCookie, GURL /* url */, GURL /* first_party_for_cookies */, diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 2798a26..a91a857 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1596,6 +1596,13 @@ IPC_SYNC_MESSAGE_CONTROL3_2(ViewHostMsg_OpenChannelToPlugin, IPC::ChannelHandle /* channel_handle */, webkit::WebPluginInfo /* info */) +// Get the list of proxies to use for |url|, as a semicolon delimited list +// of "<TYPE> <HOST>:<PORT>" | "DIRECT". +IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_ResolveProxy, + GURL /* url */, + bool /* result */, + std::string /* proxy list */) + // A renderer sends this to the browser process when it wants to create a // worker. The browser will create the worker process if necessary, and // will return the route id on success. On error returns MSG_ROUTING_NONE. diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc index c5d2953..9b27515 100644 --- a/content/plugin/plugin_thread.cc +++ b/content/plugin/plugin_thread.cc @@ -21,12 +21,10 @@ #include "base/threading/thread_local.h" #include "content/common/child_process.h" #include "content/common/content_switches.h" -#include "content/common/child_process_messages.h" #include "content/common/plugin_messages.h" #include "content/plugin/content_plugin_client.h" #include "content/plugin/npobject_util.h" #include "ipc/ipc_channel_handle.h" -#include "net/base/net_errors.h" #include "webkit/glue/webkit_glue.h" #include "webkit/plugins/npapi/plugin_lib.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h" @@ -170,19 +168,3 @@ void PluginThread::OnCreateChannel(int renderer_id, void PluginThread::OnNotifyRenderersOfPendingShutdown() { PluginChannel::NotifyRenderersOfPendingShutdown(); } - -namespace webkit_glue { -bool FindProxyForUrl(const GURL& url, std::string* proxy_list) { - int net_error; - std::string proxy_result; - - bool result = ChildThread::current()->Send( - new ChildProcessHostMsg_ResolveProxy(url, &net_error, &proxy_result)); - if (!result || net_error != net::OK) - return false; - - *proxy_list = proxy_result; - return true; -} - -} // namespace webkit_glue diff --git a/content/plugin/webplugin_proxy.cc b/content/plugin/webplugin_proxy.cc index 809f12a..df76e8e 100644 --- a/content/plugin/webplugin_proxy.cc +++ b/content/plugin/webplugin_proxy.cc @@ -238,6 +238,12 @@ NPObject* WebPluginProxy::GetPluginElement() { return plugin_element_; } +bool WebPluginProxy::FindProxyForUrl(const GURL& url, std::string* proxy_list) { + bool result = false; + Send(new PluginHostMsg_ResolveProxy(route_id_, url, &result, proxy_list)); + return result; +} + void WebPluginProxy::SetCookie(const GURL& url, const GURL& first_party_for_cookies, const std::string& cookie) { diff --git a/content/plugin/webplugin_proxy.h b/content/plugin/webplugin_proxy.h index 757802a..df1b880 100644 --- a/content/plugin/webplugin_proxy.h +++ b/content/plugin/webplugin_proxy.h @@ -73,6 +73,7 @@ class WebPluginProxy : public webkit::npapi::WebPlugin { virtual void InvalidateRect(const gfx::Rect& rect); virtual NPObject* GetWindowScriptNPObject(); virtual NPObject* GetPluginElement(); + virtual bool FindProxyForUrl(const GURL& url, std::string* proxy_list); virtual void SetCookie(const GURL& url, const GURL& first_party_for_cookies, const std::string& cookie); diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc index ca358b28..1bb13ee 100644 --- a/content/renderer/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper_plugin_delegate_impl.cc @@ -18,7 +18,6 @@ #include "base/sync_socket.h" #include "base/task.h" #include "base/time.h" -#include "content/common/child_process_messages.h" #include "content/common/child_process.h" #include "content/common/child_thread.h" #include "content/common/content_switches.h" @@ -1404,10 +1403,10 @@ void PepperPluginDelegateImpl::SubscribeToPolicyUpdates( } std::string PepperPluginDelegateImpl::ResolveProxy(const GURL& url) { - int net_error; + bool result; std::string proxy_result; RenderThread::current()->Send( - new ChildProcessHostMsg_ResolveProxy(url, &net_error, &proxy_result)); + new ViewHostMsg_ResolveProxy(url, &result, &proxy_result)); return proxy_result; } diff --git a/content/renderer/webplugin_delegate_proxy.cc b/content/renderer/webplugin_delegate_proxy.cc index 71166b4..9e49726 100644 --- a/content/renderer/webplugin_delegate_proxy.cc +++ b/content/renderer/webplugin_delegate_proxy.cc @@ -433,6 +433,7 @@ bool WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { OnGetWindowScriptNPObject) IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement, OnGetPluginElement) + IPC_MESSAGE_HANDLER(PluginHostMsg_ResolveProxy, OnResolveProxy) IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus, @@ -1099,6 +1100,14 @@ void WebPluginDelegateProxy::OnGetWindowScriptNPObject( *success = true; } +void WebPluginDelegateProxy::OnResolveProxy(const GURL& url, + bool* result, + std::string* proxy_list) { + *result = false; + RenderThread::current()->Send( + new ViewHostMsg_ResolveProxy(url, result, proxy_list)); +} + void WebPluginDelegateProxy::OnGetPluginElement(int route_id, bool* success) { *success = false; NPObject* npobject = NULL; diff --git a/content/renderer/webplugin_delegate_proxy.h b/content/renderer/webplugin_delegate_proxy.h index de353b5..5482335 100644 --- a/content/renderer/webplugin_delegate_proxy.h +++ b/content/renderer/webplugin_delegate_proxy.h @@ -147,6 +147,7 @@ class WebPluginDelegateProxy void OnCancelResource(int id); void OnInvalidateRect(const gfx::Rect& rect, bool allow_buffer_flipping); void OnGetWindowScriptNPObject(int route_id, bool* success); + void OnResolveProxy(const GURL& url, bool* result, std::string* proxy_list); void OnGetPluginElement(int route_id, bool* success); void OnSetCookie(const GURL& url, const GURL& first_party_for_cookies, diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index bc68662..aa94599 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -214,9 +214,6 @@ void GetPlugins(bool refresh, // required by the media engine. bool IsProtocolSupportedForMedia(const GURL& url); -// Resolves the proxies for the url, returns true on success. -bool FindProxyForUrl(const GURL& url, std::string* proxy_list); - // Returns the locale that this instance of webkit is running as. This is of // the form language-country (e.g., en-US or pt-BR). std::string GetWebKitLocale(); diff --git a/webkit/plugins/npapi/plugin_host.cc b/webkit/plugins/npapi/plugin_host.cc index 7c41c1b..ec5b6c7 100644 --- a/webkit/plugins/npapi/plugin_host.cc +++ b/webkit/plugins/npapi/plugin_host.cc @@ -1006,9 +1006,15 @@ NPError NPN_GetValueForURL(NPP id, switch (variable) { case NPNURLVProxy: { result = "DIRECT"; - if (!webkit_glue::FindProxyForUrl(GURL((std::string(url))), &result)) + scoped_refptr<PluginInstance> plugin(FindInstance(id)); + if (!plugin) + return NPERR_GENERIC_ERROR; + + WebPlugin* webplugin = plugin->webplugin(); + if (!webplugin) return NPERR_GENERIC_ERROR; + result = webplugin->FindProxyForUrl(GURL(std::string(url)), &result); break; } case NPNURLVCookie: { diff --git a/webkit/plugins/npapi/webplugin.h b/webkit/plugins/npapi/webplugin.h index a7c3110..10229b9 100644 --- a/webkit/plugins/npapi/webplugin.h +++ b/webkit/plugins/npapi/webplugin.h @@ -101,6 +101,9 @@ class WebPlugin { // reference. virtual NPObject* GetPluginElement() = 0; + // Resolves the proxies for the url, returns true on success. + virtual bool FindProxyForUrl(const GURL& url, std::string* proxy_list) = 0; + // Cookies virtual void SetCookie(const GURL& url, const GURL& first_party_for_cookies, diff --git a/webkit/plugins/npapi/webplugin_impl.cc b/webkit/plugins/npapi/webplugin_impl.cc index 8ca2b7e..764a071 100644 --- a/webkit/plugins/npapi/webplugin_impl.cc +++ b/webkit/plugins/npapi/webplugin_impl.cc @@ -702,6 +702,11 @@ NPObject* WebPluginImpl::GetPluginElement() { return container_->scriptableObjectForElement(); } +bool WebPluginImpl::FindProxyForUrl(const GURL& url, std::string* proxy_list) { + // Proxy resolving doesn't work in single-process mode. + return false; +} + void WebPluginImpl::SetCookie(const GURL& url, const GURL& first_party_for_cookies, const std::string& cookie) { diff --git a/webkit/plugins/npapi/webplugin_impl.h b/webkit/plugins/npapi/webplugin_impl.h index 6963e42..61b7852 100644 --- a/webkit/plugins/npapi/webplugin_impl.h +++ b/webkit/plugins/npapi/webplugin_impl.h @@ -105,6 +105,7 @@ class WebPluginImpl : public WebPlugin, virtual void InvalidateRect(const gfx::Rect& rect); virtual NPObject* GetWindowScriptNPObject(); virtual NPObject* GetPluginElement(); + virtual bool FindProxyForUrl(const GURL& url, std::string* proxy_list); virtual void SetCookie(const GURL& url, const GURL& first_party_for_cookies, const std::string& cookie); diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index 9138fdd..babefc1 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -54,7 +54,6 @@ #include "net/http/http_cache.h" #include "net/http/http_request_headers.h" #include "net/http/http_response_headers.h" -#include "net/proxy/proxy_service.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_job.h" #include "webkit/appcache/appcache_interfaces.h" @@ -792,25 +791,6 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( return new ResourceLoaderBridgeImpl(request_info); } -// Issue the proxy resolve request on the io thread, and wait -// for the result. -bool FindProxyForUrl(const GURL& url, std::string* proxy_list) { - DCHECK(g_request_context); - - scoped_refptr<net::SyncProxyServiceHelper> sync_proxy_service( - new net::SyncProxyServiceHelper(g_io_thread->message_loop(), - g_request_context->proxy_service())); - - net::ProxyInfo proxy_info; - int rv = sync_proxy_service->ResolveProxy(url, &proxy_info, - net::BoundNetLog()); - if (rv == net::OK) { - *proxy_list = proxy_info.ToPacString(); - } - - return rv == net::OK; -} - } // namespace webkit_glue //----------------------------------------------------------------------------- |