summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2011-03-02 13:14:03 +0000
committerKristian Monsen <kristianm@google.com>2011-03-02 15:36:34 +0000
commitbc5cc75c302eb49d15258155fc6f672fcbd62842 (patch)
treef6ca3650fdafa3900110d78c13eef3c79fd8527b /src
parent15c5087dba00b22a1a29b8e9074e3029a4a3dca1 (diff)
downloadpackages_apps_browser-bc5cc75c302eb49d15258155fc6f672fcbd62842.zip
packages_apps_browser-bc5cc75c302eb49d15258155fc6f672fcbd62842.tar.gz
packages_apps_browser-bc5cc75c302eb49d15258155fc6f672fcbd62842.tar.bz2
Downloads from incognito tabs need to use the correct cookie
Change-Id: Iee012fe4a32dd51b8a59763b9ceab1e7dbde5246
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/Controller.java21
-rw-r--r--src/com/android/browser/DownloadHandler.java11
2 files changed, 20 insertions, 12 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index e72d7b3..ae91f11 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -488,7 +488,8 @@ public class Controller
case R.id.save_link_context_menu_id:
case R.id.download_context_menu_id:
DownloadHandler.onDownloadStartNoStream(
- mActivity, url, null, null, null);
+ mActivity, url, null, null, null,
+ view.isPrivateBrowsingEnabled());
break;
}
break;
@@ -962,9 +963,10 @@ public class Controller
@Override
public void onDownloadStart(Tab tab, String url, String userAgent,
String contentDisposition, String mimetype, long contentLength) {
+ WebView w = tab.getWebView();
DownloadHandler.onDownloadStart(mActivity, url, userAgent,
- contentDisposition, mimetype);
- if (tab.getWebView().copyBackForwardList().getSize() == 0) {
+ contentDisposition, mimetype, w.isPrivateBrowsingEnabled());
+ if (w.copyBackForwardList().getSize() == 0) {
// This Tab was opened for the sole purpose of downloading a
// file. Remove it.
if (tab == mTabControl.getCurrentTab()) {
@@ -1371,7 +1373,8 @@ public class Controller
menu.findItem(R.id.view_image_context_menu_id).setIntent(
new Intent(Intent.ACTION_VIEW, Uri.parse(extra)));
menu.findItem(R.id.download_context_menu_id).
- setOnMenuItemClickListener(new Download(mActivity, extra));
+ setOnMenuItemClickListener(
+ new Download(mActivity, extra, webview.isPrivateBrowsingEnabled()));
menu.findItem(R.id.set_wallpaper_context_menu_id).
setOnMenuItemClickListener(new WallpaperHandler(mActivity,
extra));
@@ -1591,7 +1594,7 @@ public class Controller
Toast.LENGTH_SHORT).show();
break;
}
- WebView topWebView = getCurrentTopWebView();
+ final WebView topWebView = getCurrentTopWebView();
final String title = topWebView.getTitle();
final String url = topWebView.getUrl();
topWebView.saveWebArchive(directory, true,
@@ -1618,7 +1621,7 @@ public class Controller
}
}
DownloadHandler.onDownloadStartNoStream(mActivity,
- url, null, null, null);
+ url, null, null, null, topWebView.isPrivateBrowsingEnabled());
}
});
break;
@@ -2046,16 +2049,18 @@ public class Controller
private static class Download implements OnMenuItemClickListener {
private Activity mActivity;
private String mText;
+ private boolean mPrivateBrowsing;
public boolean onMenuItemClick(MenuItem item) {
DownloadHandler.onDownloadStartNoStream(mActivity, mText, null,
- null, null);
+ null, null, mPrivateBrowsing);
return true;
}
- public Download(Activity activity, String toDownload) {
+ public Download(Activity activity, String toDownload, boolean privateBrowsing) {
mActivity = activity;
mText = toDownload;
+ mPrivateBrowsing = privateBrowsing;
}
}
diff --git a/src/com/android/browser/DownloadHandler.java b/src/com/android/browser/DownloadHandler.java
index 4903a41..17ad320 100644
--- a/src/com/android/browser/DownloadHandler.java
+++ b/src/com/android/browser/DownloadHandler.java
@@ -53,9 +53,11 @@ public class DownloadHandler {
* @param userAgent User agent of the downloading application.
* @param contentDisposition Content-disposition http header, if present.
* @param mimetype The mimetype of the content reported by the server
+ * @param privateBrowsing If the request is coming from a private browsing tab.
*/
public static void onDownloadStart(Activity activity, String url,
- String userAgent, String contentDisposition, String mimetype) {
+ String userAgent, String contentDisposition, String mimetype,
+ boolean privateBrowsing) {
// if we're dealing wih A/V content that's not explicitly marked
// for download, check if it's streamable.
if (contentDisposition == null
@@ -93,7 +95,7 @@ public class DownloadHandler {
}
}
onDownloadStartNoStream(activity, url, userAgent, contentDisposition,
- mimetype);
+ mimetype, privateBrowsing);
}
// This is to work around the fact that java.net.URI throws Exceptions
@@ -134,10 +136,11 @@ public class DownloadHandler {
* @param userAgent User agent of the downloading application.
* @param contentDisposition Content-disposition http header, if present.
* @param mimetype The mimetype of the content reported by the server
+ * @param privateBrowsing If the request is coming from a private browsing tab.
*/
/*package */ static void onDownloadStartNoStream(Activity activity,
String url, String userAgent, String contentDisposition,
- String mimetype) {
+ String mimetype, boolean privateBrowsing) {
String filename = URLUtil.guessFileName(url,
contentDisposition, mimetype);
@@ -198,7 +201,7 @@ public class DownloadHandler {
request.setDescription(webAddress.getHost());
// XXX: Have to use the old url since the cookies were stored using the
// old percent-encoded url.
- String cookies = CookieManager.getInstance().getCookie(url);
+ String cookies = CookieManager.getInstance().getCookie(url, privateBrowsing);
request.addRequestHeader("cookie", cookies);
request.setNotificationVisibility(
DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);