diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/BaseUi.java | 1 | ||||
-rw-r--r-- | src/com/android/browser/BrowserActivity.java | 1 | ||||
-rw-r--r-- | src/com/android/browser/Controller.java | 12 | ||||
-rw-r--r-- | src/com/android/browser/DownloadHandler.java | 11 | ||||
-rw-r--r-- | src/com/android/browser/IntentHandler.java | 8 | ||||
-rw-r--r-- | src/com/android/browser/NavigationBarPhone.java | 7 | ||||
-rw-r--r-- | src/com/android/browser/NavigationBarTablet.java | 8 | ||||
-rw-r--r-- | src/com/android/browser/PreloadController.java | 2 | ||||
-rw-r--r-- | src/com/android/browser/Tab.java | 33 | ||||
-rw-r--r-- | src/com/android/browser/TitleBar.java | 8 | ||||
-rw-r--r-- | src/com/android/browser/UrlHandler.java | 1 | ||||
-rw-r--r-- | src/com/android/browser/WebViewController.java | 2 |
12 files changed, 63 insertions, 31 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java index c749465..b766fb9 100644 --- a/src/com/android/browser/BaseUi.java +++ b/src/com/android/browser/BaseUi.java @@ -171,6 +171,7 @@ public abstract class BaseUi implements UI { if (ct != null) { setActiveTab(ct); } + mTitleBar.onResume(); } protected boolean isActivityPaused() { diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 8511778..4166b11 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -43,6 +43,7 @@ public class BrowserActivity extends Activity { public static final String ACTION_SHOW_BROWSER = "show_browser"; public static final String ACTION_RESTART = "--restart--"; private static final String EXTRA_STATE = "state"; + public static final String EXTRA_DISABLE_URL_OVERRIDE = "disable_url_override"; private final static String LOGTAG = "browser"; diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 7f40aea..e84e397 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -513,7 +513,7 @@ public class Controller case R.id.download_context_menu_id: DownloadHandler.onDownloadStartNoStream( mActivity, url, view.getSettings().getUserAgentString(), - null, null, view.isPrivateBrowsingEnabled()); + null, null, null, view.isPrivateBrowsingEnabled()); break; } break; @@ -1031,10 +1031,11 @@ public class Controller @Override public void onDownloadStart(Tab tab, String url, String userAgent, - String contentDisposition, String mimetype, long contentLength) { + String contentDisposition, String mimetype, String referer, + long contentLength) { WebView w = tab.getWebView(); DownloadHandler.onDownloadStart(mActivity, url, userAgent, - contentDisposition, mimetype, w.isPrivateBrowsingEnabled()); + contentDisposition, mimetype, referer, w.isPrivateBrowsingEnabled()); if (w.copyBackForwardList().getSize() == 0) { // This Tab was opened for the sole purpose of downloading a // file. Remove it. @@ -2174,7 +2175,7 @@ public class Controller saveDataUri(); } else { DownloadHandler.onDownloadStartNoStream(mActivity, mText, mUserAgent, - null, null, mPrivateBrowsing); + null, null, null, mPrivateBrowsing); } return true; } @@ -2576,6 +2577,9 @@ public class Controller if (data.isPreloaded()) { // this isn't called for preloaded tabs } else { + if (t != null && data.mDisableUrlOverride) { + t.disableUrlOverridingForLoad(); + } loadUrl(t, data.mUrl, data.mHeaders); } } diff --git a/src/com/android/browser/DownloadHandler.java b/src/com/android/browser/DownloadHandler.java index 6d0b1e6..dee10ae 100644 --- a/src/com/android/browser/DownloadHandler.java +++ b/src/com/android/browser/DownloadHandler.java @@ -21,7 +21,6 @@ import android.app.AlertDialog; import android.app.DownloadManager; import android.content.ActivityNotFoundException; import android.content.ComponentName; -import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -53,11 +52,12 @@ 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 referer The referer associated with the downloaded url * @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, - boolean privateBrowsing) { + String referer, 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 @@ -67,7 +67,6 @@ public class DownloadHandler { // that matches. Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url), mimetype); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ResolveInfo info = activity.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (info != null) { @@ -96,7 +95,7 @@ public class DownloadHandler { } } onDownloadStartNoStream(activity, url, userAgent, contentDisposition, - mimetype, privateBrowsing); + mimetype, referer, privateBrowsing); } // This is to work around the fact that java.net.URI throws Exceptions @@ -137,11 +136,12 @@ 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 referer The referer associated with the downloaded url * @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, boolean privateBrowsing) { + String mimetype, String referer, boolean privateBrowsing) { String filename = URLUtil.guessFileName(url, contentDisposition, mimetype); @@ -205,6 +205,7 @@ public class DownloadHandler { String cookies = CookieManager.getInstance().getCookie(url, privateBrowsing); request.addRequestHeader("cookie", cookies); request.addRequestHeader("User-Agent", userAgent); + request.addRequestHeader("Referer", referer); request.setNotificationVisibility( DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); if (mimetype == null) { diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java index e22c5dc..f0998a4 100644 --- a/src/com/android/browser/IntentHandler.java +++ b/src/com/android/browser/IntentHandler.java @@ -335,12 +335,14 @@ public class IntentHandler { final Map<String, String> mHeaders; final PreloadedTabControl mPreloadedTab; final String mSearchBoxQueryToSubmit; + final boolean mDisableUrlOverride; UrlData(String url) { this.mUrl = url; this.mHeaders = null; this.mPreloadedTab = null; this.mSearchBoxQueryToSubmit = null; + this.mDisableUrlOverride = false; } UrlData(String url, Map<String, String> headers, Intent intent) { @@ -353,6 +355,12 @@ public class IntentHandler { this.mHeaders = headers; this.mPreloadedTab = preloaded; this.mSearchBoxQueryToSubmit = searchBoxQueryToSubmit; + if (intent != null) { + mDisableUrlOverride = intent.getBooleanExtra( + BrowserActivity.EXTRA_DISABLE_URL_OVERRIDE, false); + } else { + mDisableUrlOverride = false; + } } boolean isEmpty() { diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java index c3930d3..f3eaa2a 100644 --- a/src/com/android/browser/NavigationBarPhone.java +++ b/src/com/android/browser/NavigationBarPhone.java @@ -215,12 +215,12 @@ public class NavigationBarPhone extends NavigationBarBase implements @Override public void onStateChanged(int state) { + mVoiceButton.setVisibility(View.GONE); switch(state) { case StateListener.STATE_NORMAL: mComboIcon.setVisibility(View.VISIBLE); mStopButton.setVisibility(View.GONE); mClearButton.setVisibility(View.GONE); - mVoiceButton.setVisibility(View.GONE); mMagnify.setVisibility(View.GONE); mTabSwitcher.setVisibility(View.VISIBLE); mTitleContainer.setBackgroundDrawable(null); @@ -230,7 +230,9 @@ public class NavigationBarPhone extends NavigationBarBase implements mComboIcon.setVisibility(View.GONE); mStopButton.setVisibility(View.VISIBLE); mClearButton.setVisibility(View.GONE); - mVoiceButton.setVisibility(View.VISIBLE); + if ((mUiController != null) && mUiController.supportsVoice()) { + mVoiceButton.setVisibility(View.VISIBLE); + } mMagnify.setVisibility(View.GONE); mTabSwitcher.setVisibility(View.GONE); mMore.setVisibility(View.GONE); @@ -240,7 +242,6 @@ public class NavigationBarPhone extends NavigationBarBase implements mComboIcon.setVisibility(View.GONE); mStopButton.setVisibility(View.GONE); mClearButton.setVisibility(View.VISIBLE); - mVoiceButton.setVisibility(View.GONE); mMagnify.setVisibility(View.VISIBLE); mTabSwitcher.setVisibility(View.GONE); mMore.setVisibility(View.GONE); diff --git a/src/com/android/browser/NavigationBarTablet.java b/src/com/android/browser/NavigationBarTablet.java index 79c8de6..adfd5e7 100644 --- a/src/com/android/browser/NavigationBarTablet.java +++ b/src/com/android/browser/NavigationBarTablet.java @@ -322,19 +322,19 @@ public class NavigationBarTablet extends NavigationBarBase implements StateListe @Override public void onStateChanged(int state) { + mVoiceButton.setVisibility(View.GONE); switch(state) { case STATE_NORMAL: mClearButton.setVisibility(View.GONE); - mVoiceButton.setVisibility(View.GONE); - break; case STATE_HIGHLIGHTED: mClearButton.setVisibility(View.GONE); - mVoiceButton.setVisibility(View.VISIBLE); + if ((mUiController != null) && mUiController.supportsVoice()) { + mVoiceButton.setVisibility(View.VISIBLE); + } break; case STATE_EDITED: mClearButton.setVisibility(View.VISIBLE); - mVoiceButton.setVisibility(View.GONE); break; } } diff --git a/src/com/android/browser/PreloadController.java b/src/com/android/browser/PreloadController.java index a7feaee..881f19e 100644 --- a/src/com/android/browser/PreloadController.java +++ b/src/com/android/browser/PreloadController.java @@ -153,7 +153,7 @@ public class PreloadController implements WebViewController { @Override public void onDownloadStart(Tab tab, String url, String useragent, String contentDisposition, String mimeType, - long contentLength) { + String referer, long contentLength) { if (LOGD_ENABLED) Log.d(LOGTAG, "onDownloadStart()"); } diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 6200286..b5000c2 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -46,9 +46,9 @@ import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewStub; +import android.webkit.BrowserDownloadListener; import android.webkit.ClientCertRequestHandler; import android.webkit.ConsoleMessage; -import android.webkit.DownloadListener; import android.webkit.GeolocationPermissions; import android.webkit.HttpAuthHandler; import android.webkit.SslErrorHandler; @@ -64,6 +64,7 @@ import android.webkit.WebView; import android.webkit.WebView.PictureListener; import android.webkit.WebViewClassic; import android.webkit.WebViewClient; +import android.webkit.WebViewClientClassicExt; import android.widget.CheckBox; import android.widget.Toast; @@ -155,6 +156,7 @@ class Tab implements PictureListener { // If true, the tab is in page loading state (after onPageStarted, // before onPageFinsihed) private boolean mInPageLoad; + private boolean mDisableOverrideUrlLoading; // The last reported progress of the current page private int mPageLoadProgress; // The time the load started, used to find load page time @@ -170,7 +172,7 @@ class Tab implements PictureListener { private ErrorConsoleView mErrorConsole; // The listener that gets invoked when a download is started from the // mMainView - private final DownloadListener mDownloadListener; + private final BrowserDownloadListener mDownloadListener; // Listener used to know when we move forward or back in the history list. private final WebBackForwardListClient mWebBackForwardListClient; private DataController mDataController; @@ -322,7 +324,7 @@ class Tab implements PictureListener { // WebViewClient implementation for the main WebView // ------------------------------------------------------------------------- - private final WebViewClient mWebViewClient = new WebViewClient() { + private final WebViewClientClassicExt mWebViewClient = new WebViewClientClassicExt() { private Message mDontResend; private Message mResend; @@ -372,6 +374,7 @@ class Tab implements PictureListener { @Override public void onPageFinished(WebView view, String url) { + mDisableOverrideUrlLoading = false; if (!isPrivateBrowsingEnabled()) { LogTag.logPageFinishedLoading( url, SystemClock.uptimeMillis() - mLoadStartTime); @@ -383,7 +386,7 @@ class Tab implements PictureListener { // return true if want to hijack the url to let another app to handle it @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if (mInForeground) { + if (!mDisableOverrideUrlLoading && mInForeground) { return mWebViewController.shouldOverrideUrlLoading(Tab.this, view, url); } else { @@ -1045,12 +1048,12 @@ class Tab implements PictureListener { // Subclass of WebViewClient used in subwindows to notify the main // WebViewClient of certain WebView activities. - private static class SubWindowClient extends WebViewClient { + private static class SubWindowClient extends WebViewClientClassicExt { // The main WebViewClient. - private final WebViewClient mClient; + private final WebViewClientClassicExt mClient; private final WebViewController mController; - SubWindowClient(WebViewClient client, WebViewController controller) { + SubWindowClient(WebViewClientClassicExt client, WebViewController controller) { mClient = client; mController = controller; } @@ -1157,12 +1160,12 @@ class Tab implements PictureListener { mInPageLoad = false; mInForeground = false; - mDownloadListener = new DownloadListener() { + mDownloadListener = new BrowserDownloadListener() { public void onDownloadStart(String url, String userAgent, - String contentDisposition, String mimetype, + String contentDisposition, String mimetype, String referer, long contentLength) { mWebViewController.onDownloadStart(Tab.this, url, userAgent, contentDisposition, - mimetype, contentLength); + mimetype, referer, contentLength); } }; mWebBackForwardListClient = new WebBackForwardListClient() { @@ -1351,12 +1354,12 @@ class Tab implements PictureListener { mWebChromeClient)); // Set a different DownloadListener for the mSubView, since it will // just need to dismiss the mSubView, rather than close the Tab - mSubView.setDownloadListener(new DownloadListener() { + mSubView.setDownloadListener(new BrowserDownloadListener() { public void onDownloadStart(String url, String userAgent, - String contentDisposition, String mimetype, + String contentDisposition, String mimetype, String referer, long contentLength) { mWebViewController.onDownloadStart(Tab.this, url, userAgent, - contentDisposition, mimetype, contentLength); + contentDisposition, mimetype, referer, contentLength); if (mSubView.copyBackForwardList().getSize() == 0) { // This subwindow was opened for the sole purpose of // downloading a file. Remove it. @@ -1894,6 +1897,10 @@ class Tab implements PictureListener { } } + public void disableUrlOverridingForLoad() { + mDisableOverrideUrlLoading = true; + } + protected void capture() { if (mMainView == null || mCapture == null) return; if (mMainView.getContentWidth() <= 0 || mMainView.getContentHeight() <= 0) { diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java index f5be5d3..874296a 100644 --- a/src/com/android/browser/TitleBar.java +++ b/src/com/android/browser/TitleBar.java @@ -26,6 +26,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; +import android.view.accessibility.AccessibilityManager; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; @@ -47,6 +48,7 @@ public class TitleBar extends RelativeLayout { private BaseUi mBaseUi; private FrameLayout mContentView; private PageProgressView mProgress; + private AccessibilityManager mAccessibilityManager; private AutologinBar mAutoLogin; private NavigationBarBase mNavBar; @@ -66,6 +68,7 @@ public class TitleBar extends RelativeLayout { mUiController = controller; mBaseUi = ui; mContentView = contentView; + mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); initLayout(context); setFixedTitleBar(); } @@ -118,6 +121,7 @@ public class TitleBar extends RelativeLayout { private void setFixedTitleBar() { boolean isFixed = !mUseQuickControls && !mContext.getResources().getBoolean(R.bool.hide_title); + isFixed |= mAccessibilityManager.isEnabled(); // If getParent() returns null, we are initializing ViewGroup parent = (ViewGroup)getParent(); if (mIsFixedTitleBar == isFixed && parent != null) return; @@ -436,4 +440,8 @@ public class TitleBar extends RelativeLayout { } } + public void onResume() { + setFixedTitleBar(); + } + } diff --git a/src/com/android/browser/UrlHandler.java b/src/com/android/browser/UrlHandler.java index ac4b880..167d410 100644 --- a/src/com/android/browser/UrlHandler.java +++ b/src/com/android/browser/UrlHandler.java @@ -175,6 +175,7 @@ public class UrlHandler { return false; } try { + intent.putExtra(BrowserActivity.EXTRA_DISABLE_URL_OVERRIDE, true); if (mActivity.startActivityIfNeeded(intent, -1)) { // before leaving BrowserActivity, close the empty child tab. // If a new tab is created through JavaScript open to load this diff --git a/src/com/android/browser/WebViewController.java b/src/com/android/browser/WebViewController.java index fef6964..e814ff9 100644 --- a/src/com/android/browser/WebViewController.java +++ b/src/com/android/browser/WebViewController.java @@ -73,7 +73,7 @@ public interface WebViewController { final String host, final String realm); void onDownloadStart(Tab tab, String url, String useragent, String contentDisposition, - String mimeType, long contentLength); + String mimeType, String referer, long contentLength); void showCustomView(Tab tab, View view, int requestedOrientation, WebChromeClient.CustomViewCallback callback); |