Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f21d2e30 authored by Elliott Slaughter's avatar Elliott Slaughter
Browse files

Initial work on browser incognito mode history feature.

Change-Id: I050edf263d5c4ee0c0373692e267d7e19f47ba1b
parent 23018270
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -212151,6 +212151,22 @@
<parameter name="defStyle" type="int">
</parameter>
</constructor>
<constructor name="WebView"
 type="android.webkit.WebView"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<parameter name="defStyle" type="int">
</parameter>
<parameter name="privateBrowsing" type="boolean">
</parameter>
</constructor>
<method name="addJavascriptInterface"
 return="void"
 abstract="false"
@@ -212639,6 +212655,17 @@
 visibility="public"
>
</method>
<method name="isPrivateBrowsingEnabled"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="loadData"
 return="void"
 abstract="false"
+19 −0
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ public class WebSettings {
    private boolean         mSupportMultipleWindows = false;
    private boolean         mShrinksStandaloneImagesToFit = false;
    private long            mMaximumDecodedImageSize = 0; // 0 means default
    private boolean         mPrivateBrowsingEnabled = false;
    // HTML5 API flags
    private boolean         mAppCacheEnabled = false;
    private boolean         mDatabaseEnabled = false;
@@ -1468,6 +1469,24 @@ public class WebSettings {
        }
    }

    /**
     * Returns whether private browsing is enabled.
     */
    /* package */ boolean isPrivateBrowsingEnabled() {
        return mPrivateBrowsingEnabled;
    }

    /**
     * Sets whether private browsing is enabled.
     * @param flag Whether private browsing should be enabled.
     */
    /* package */ synchronized void setPrivateBrowsingEnabled(boolean flag) {
        if (mPrivateBrowsingEnabled != flag) {
            mPrivateBrowsingEnabled = flag;
            postSync();
        }
    }

    int getDoubleTapToastCount() {
        return mDoubleTapToastCount;
    }
+47 −2
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
@@ -825,7 +827,18 @@ public class WebView extends AbsoluteLayout
     * @param defStyle The default style resource ID.
     */
    public WebView(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs, defStyle, null);
        this(context, attrs, defStyle, false);
    }

    /**
     * Construct a new WebView with layout parameters and a default style.
     * @param context A Context object used to access application assets.
     * @param attrs An AttributeSet passed to our parent.
     * @param defStyle The default style resource ID.
     */
    public WebView(Context context, AttributeSet attrs, int defStyle,
            boolean privateBrowsing) {
        this(context, attrs, defStyle, null, privateBrowsing);
    }

    /**
@@ -841,7 +854,7 @@ public class WebView extends AbsoluteLayout
     * @hide pending API council approval.
     */
    protected WebView(Context context, AttributeSet attrs, int defStyle,
            Map<String, Object> javascriptInterfaces) {
            Map<String, Object> javascriptInterfaces, boolean privateBrowsing) {
        super(context, attrs, defStyle);

        if (AccessibilityManager.getInstance(context).isEnabled()) {
@@ -863,6 +876,10 @@ public class WebView extends AbsoluteLayout
         */
        init();
        updateMultiTouchSupport(context);

        if (privateBrowsing) {
            startPrivateBrowsing();
        }
    }

    void updateMultiTouchSupport(Context context) {
@@ -1668,6 +1685,34 @@ public class WebView extends AbsoluteLayout
        }
    }

    /**
     * Returns true if private browsing is enabled in this WebView.
     */
    public boolean isPrivateBrowsingEnabled () {
        return getSettings().isPrivateBrowsingEnabled();
    }

    private void startPrivateBrowsing () {
        boolean wasPrivateBrowsingEnabled = isPrivateBrowsingEnabled();

        getSettings().setPrivateBrowsingEnabled(true);

        if (!wasPrivateBrowsingEnabled) {
            StringBuilder data = new StringBuilder(1024);
            try {
                InputStreamReader file = new InputStreamReader(mContext.getResources().openRawResource(com.android.internal.R.raw.incognito_mode_start_page));
                int size;
                char[] buffer = new char[1024];
                while ((size = file.read(buffer)) != -1) {
                    data.append(buffer, 0, size);
                }
            } catch (IOException e) {
                // This should never happen since this is a static resource.
            }
            loadDataWithBaseURL(null, data.toString(), "text/html", "utf-8", null);
        }
    }

    private boolean extendScroll(int y) {
        int finalY = mScroller.getFinalY();
        int newY = pinLocY(finalY + y);
+24 −0
Original line number Diff line number Diff line
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
    <title>New incognito window</title>
  </head>
  <body>
    <p><strong>You've gone incognito</strong>. Pages you view in this window
      won't appear in your browser history or search history, and they won't
      leave other traces, like cookies, on your computer after you close the
      incognito window. Any files you download or bookmarks you create will be
      preserved, however.</p>

    <p><strong>Going incognito doesn't affect the behavior of other people,
	servers, or software. Be wary of:</strong></p>

    <ul>
      <li>Websites that collect or share information about you</li>
      <li>Internet service providers or employers that track the pages you visit</li>
      <li>Malicious software that tracks your keystrokes in exchange for free smileys</li>
      <li>Surveillance by secret agents</li>
      <li>People standing behind you</li>
    </ul>
  </body>
</html>
+1 −1
Original line number Diff line number Diff line
@@ -754,7 +754,7 @@ public class TestShellActivity extends Activity implements LayoutTestController

    private static class NewWindowWebView extends WebView {
        public NewWindowWebView(Context context, Map<String, Object> jsIfaces) {
            super(context, null, 0, jsIfaces);
            super(context, null, 0, jsIfaces, false);
        }
    }