summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_npapi.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 19:13:00 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 19:13:00 +0000
commit70daf0b18defd88e97f5f9ebcc9486c22898b66b (patch)
tree71e5c7cd9c7733ecafd589e8be81a67c67b2070a /chrome_frame/chrome_frame_npapi.cc
parent47b950579d39dc79127c1dc69f44c33c8ad269b0 (diff)
downloadchromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.zip
chromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.tar.gz
chromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.tar.bz2
ChromeFrame should honor the host browser's cookie policy. To achieve this we always read the cookies from
the host browser when the renderer requests them. This also cleans up the mess with the host network stack code parsing cookies from the host looking for persistent cookies. Fixes bug http://code.google.com/p/chromium/issues/detail?id=34151 Bug=34151 Test=Covered by existing host network stack tests and chrome frame cookie tests. Review URL: http://codereview.chromium.org/661290 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_npapi.cc')
-rw-r--r--chrome_frame/chrome_frame_npapi.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index fe734a8c..d147a40 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -529,6 +529,55 @@ void ChromeFrameNPAPI::OnSetCookieAsync(int tab_handle, const GURL& url,
}
}
+void ChromeFrameNPAPI::OnGetCookiesFromHost(int tab_handle, const GURL& url,
+ int cookie_id) {
+ std::string cookie_string;
+ bool success = true;
+
+ if (npapi::VersionMinor() >= NPVERS_HAS_URL_AND_AUTH_INFO) {
+ char* cookies = NULL;
+ unsigned int cookie_length = 0;
+ NPError ret = npapi::GetValueForURL(instance_, NPNURLVCookie,
+ url.spec().c_str(), &cookies,
+ &cookie_length);
+ if (ret == NPERR_NO_ERROR) {
+ DLOG(INFO) << "Obtained cookies:" << cookies << " from host";
+ cookie_string.append(cookies, cookie_length);
+ npapi::MemFree(cookies);
+ } else {
+ success = false;
+ }
+ } else {
+ DLOG(INFO) << "Host does not support NPVERS_HAS_URL_AND_AUTH_INFO.";
+ if (url == GURL(document_url_)) {
+ DLOG(INFO) << "Reading document.cookie";
+ NPVariant cookies = {};
+ ExecuteScript("javascript:document.cookie", &cookies);
+ if (cookies.type == NPVariantType_String) {
+ cookie_string.append(cookies.value.stringValue.UTF8Characters,
+ cookies.value.stringValue.UTF8Length);
+ DLOG(INFO) << "Obtained cookies:" << cookie_string.c_str()
+ << " from host";
+ npapi::ReleaseVariantValue(&cookies);
+ } else {
+ success = false;
+ }
+ } else {
+ success = false;
+ }
+ }
+
+ if (!success)
+ DLOG(INFO) << "Failed to return cookies for url:" << url.spec().c_str();
+
+ if (automation_client_->automation_server()) {
+ automation_client_->automation_server()->Send(
+ new AutomationMsg_GetCookiesHostResponse(0, tab_handle, success,
+ url, cookie_string,
+ cookie_id));
+ }
+}
+
bool ChromeFrameNPAPI::HasMethod(NPObject* obj, NPIdentifier name) {
for (int i = 0; i < arraysize(plugin_methods_); ++i) {
if (name == plugin_method_identifiers_[i])