From f0a13734e2dc6caa9b22fa71d1ed57ae1075b710 Mon Sep 17 00:00:00 2001 From: "mpcomplete@google.com" Date: Mon, 17 Nov 2008 19:55:14 +0000 Subject: Fix a potential race with cookie requests between renderer and gears. BUG=1487502 Review URL: http://codereview.chromium.org/10960 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5565 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/plugin/chrome_plugin_host.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'chrome/plugin/chrome_plugin_host.cc') diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index 9512c43..677404f 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -257,8 +257,24 @@ CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext context, const char* url, char** cookies) { CHECK(ChromePluginLib::IsPluginThread()); std::string cookies_str; - PluginThread::GetPluginThread()->Send( - new PluginProcessHostMsg_GetCookies(context, GURL(url), &cookies_str)); + + WebPluginProxy* webplugin = WebPluginProxy::FromCPBrowsingContext(context); + // There are two contexts in which we can be asked for cookies: + // 1. From a script context. webplugin will be non-NULL. + // 2. From a global browser context (think: Gears UpdateTask). webplugin will + // be NULL and context will (loosely) represent a browser Profile. + // In case 1, we *must* route through the renderer process, otherwise we race + // with renderer script that may have set cookies. In case 2, we are running + // out-of-band with script, so we don't need to stay in sync with any + // particular renderer. + // See http://b/issue?id=1487502. + if (webplugin) { + cookies_str = webplugin->GetCookies(GURL(url), GURL(url)); + } else { + PluginThread::GetPluginThread()->Send( + new PluginProcessHostMsg_GetCookies(context, GURL(url), &cookies_str)); + } + *cookies = CPB_StringDup(CPB_Alloc, cookies_str); return CPERR_SUCCESS; } -- cgit v1.1