diff options
author | Andreas Sandblad <andreas.sandblad@sonymobile.com> | 2012-06-11 11:02:49 +0200 |
---|---|---|
committer | Johan Redestig <johan.redestig@sonymobile.com> | 2012-09-03 10:23:51 +0200 |
commit | 8e4ce660cd8576237b4ff30c40b21570af3af4f3 (patch) | |
tree | d95901741e97de0350a600e56760e259b7c521df /src | |
parent | 3d2e213ce176cb320ac52c71b00cb591beae8e04 (diff) | |
download | packages_apps_Browser-8e4ce660cd8576237b4ff30c40b21570af3af4f3.zip packages_apps_Browser-8e4ce660cd8576237b4ff30c40b21570af3af4f3.tar.gz packages_apps_Browser-8e4ce660cd8576237b4ff30c40b21570af3af4f3.tar.bz2 |
Pass webview's useragent when downloading via context menu
Currently null is passed as useragent to the Download Manager when
downloading via Browser context menu (causes the Download
Provider to use an empty useragent HTTP header).
This commit simply passes the webview's useragent instead.
This applies to the usecase when choosing save image/link
via the context menu (long press).
Change-Id: Ie9cc5e81630d0dcefe4708980146cc5ed867e4ad
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/Controller.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index ebfd56f..4b28eb6 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -512,8 +512,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, - view.isPrivateBrowsingEnabled()); + mActivity, url, view.getSettings().getUserAgentString(), + null, null, view.isPrivateBrowsingEnabled()); break; } break; @@ -1433,9 +1433,9 @@ public class Controller return false; } }); - menu.findItem(R.id.download_context_menu_id). - setOnMenuItemClickListener( - new Download(mActivity, extra, webview.isPrivateBrowsingEnabled())); + menu.findItem(R.id.download_context_menu_id).setOnMenuItemClickListener( + new Download(mActivity, extra, webview.isPrivateBrowsingEnabled(), + webview.getSettings().getUserAgentString())); menu.findItem(R.id.set_wallpaper_context_menu_id). setOnMenuItemClickListener(new WallpaperHandler(mActivity, extra)); @@ -2165,6 +2165,7 @@ public class Controller private Activity mActivity; private String mText; private boolean mPrivateBrowsing; + private String mUserAgent; private static final String FALLBACK_EXTENSION = "dat"; private static final String IMAGE_BASE_FORMAT = "yyyy-MM-dd-HH-mm-ss-"; @@ -2173,16 +2174,18 @@ public class Controller if (DataUri.isDataUri(mText)) { saveDataUri(); } else { - DownloadHandler.onDownloadStartNoStream(mActivity, mText, null, + DownloadHandler.onDownloadStartNoStream(mActivity, mText, mUserAgent, null, null, mPrivateBrowsing); } return true; } - public Download(Activity activity, String toDownload, boolean privateBrowsing) { + public Download(Activity activity, String toDownload, boolean privateBrowsing, + String userAgent) { mActivity = activity; mText = toDownload; mPrivateBrowsing = privateBrowsing; + mUserAgent = userAgent; } /** |