diff options
| author | Jeff Hamilton <jham@android.com> | 2010-09-07 09:57:51 -0500 |
|---|---|---|
| committer | Jeff Hamilton <jham@android.com> | 2010-09-08 11:25:43 -0500 |
| commit | 47654f464e2ecd65fb049817201fb00a9f8fe29c (patch) | |
| tree | 03a0a1bde2ab38cc6f0cc25aaae0b7298def21e7 /src/com/android | |
| parent | 6e3faea951326f28bd9db6923d777281de1837d1 (diff) | |
| download | packages_apps_Browser-47654f464e2ecd65fb049817201fb00a9f8fe29c.tar.gz packages_apps_Browser-47654f464e2ecd65fb049817201fb00a9f8fe29c.tar.bz2 packages_apps_Browser-47654f464e2ecd65fb049817201fb00a9f8fe29c.zip | |
Quiet some logs in private browsing mode.
Also, always direct load URLs in the WebView
when in private browsing mode so external apps
can't intercept the URLs you visit and they
aren't logged by the ActivityManager.
Change-Id: I727a94220d35c242fa0a0cd7f52d483c1a935cd0
Diffstat (limited to 'src/com/android')
| -rw-r--r-- | src/com/android/browser/BrowserActivity.java | 6 | ||||
| -rw-r--r-- | src/com/android/browser/Tab.java | 84 |
2 files changed, 55 insertions, 35 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index d69140f54..78904854c 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -2676,6 +2676,12 @@ public class BrowserActivity extends Activity } boolean shouldOverrideUrlLoading(WebView view, String url) { + if (view.isPrivateBrowsingEnabled()) { + // Don't allow urls to leave the browser app when in private browsing mode + loadUrl(view, url); + return true; + } + if (url.startsWith(SCHEME_WTAI)) { // wtai://wp/mc;number // number=string(phone-number) diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 7c52bb662..11f85660a 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -590,8 +590,12 @@ class Tab { errorCode != WebViewClient.ERROR_FILE) { queueError(errorCode, description); } - Log.e(LOGTAG, "onReceivedError " + errorCode + " " + failingUrl - + " " + description); + + // Don't log URLs when in private browsing mode + if (!getWebView().isPrivateBrowsingEnabled()) { + Log.e(LOGTAG, "onReceivedError " + errorCode + " " + failingUrl + + " " + description); + } // We need to reset the title after an error if it is in foreground. if (mInForeground) { @@ -661,6 +665,9 @@ class Tab { @Override public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) { + // Don't save anything in private browsing mode + if (getWebView().isPrivateBrowsingEnabled()) return; + if (url.regionMatches(true, 0, "about:", 0, 6)) { return; } @@ -977,40 +984,44 @@ class Tab { >= SQLiteDatabase.SQLITE_MAX_LIKE_PATTERN_LENGTH) { return; } - new AsyncTask<Void, Void, Void>() { - @Override - protected Void doInBackground(Void... unused) { - // See if we can find the current url in our history - // database and add the new title to it. - String url = pageUrl; - if (url.startsWith("http://www.")) { - url = url.substring(11); - } else if (url.startsWith("http://")) { - url = url.substring(4); - } - // Escape wildcards for LIKE operator. - url = url.replace("\\", "\\\\").replace("%", "\\%") - .replace("_", "\\_"); - Cursor c = null; - try { - final ContentResolver cr = mActivity.getContentResolver(); - String selection = History.URL + " LIKE ? ESCAPE '\\'"; - String [] selectionArgs = new String[] { "%" + url }; - ContentValues values = new ContentValues(); - values.put(History.TITLE, title); - cr.update(History.CONTENT_URI, values, selection, selectionArgs); - } catch (IllegalStateException e) { - Log.e(LOGTAG, "Tab onReceived title", e); - } catch (SQLiteException ex) { - Log.e(LOGTAG, - "onReceivedTitle() caught SQLiteException: ", - ex); - } finally { - if (c != null) c.close(); + + // Update the title in the history database if not in private browsing mode + if (!getWebView().isPrivateBrowsingEnabled()) { + new AsyncTask<Void, Void, Void>() { + @Override + protected Void doInBackground(Void... unused) { + // See if we can find the current url in our history + // database and add the new title to it. + String url = pageUrl; + if (url.startsWith("http://www.")) { + url = url.substring(11); + } else if (url.startsWith("http://")) { + url = url.substring(4); + } + // Escape wildcards for LIKE operator. + url = url.replace("\\", "\\\\").replace("%", "\\%") + .replace("_", "\\_"); + Cursor c = null; + try { + final ContentResolver cr = mActivity.getContentResolver(); + String selection = History.URL + " LIKE ? ESCAPE '\\'"; + String [] selectionArgs = new String[] { "%" + url }; + ContentValues values = new ContentValues(); + values.put(History.TITLE, title); + cr.update(History.CONTENT_URI, values, selection, selectionArgs); + } catch (IllegalStateException e) { + Log.e(LOGTAG, "Tab onReceived title", e); + } catch (SQLiteException ex) { + Log.e(LOGTAG, + "onReceivedTitle() caught SQLiteException: ", + ex); + } finally { + if (c != null) c.close(); + } + return null; } - return null; - } - }.execute(); + }.execute(); + } } @Override @@ -1138,6 +1149,9 @@ class Tab { } } + // Don't log console messages in private browsing mode + if (getWebView().isPrivateBrowsingEnabled()) return true; + String message = "Console: " + consoleMessage.message() + " " + consoleMessage.sourceId() + ":" + consoleMessage.lineNumber(); |
