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

Commit 7df1985e authored by Ben Murdoch's avatar Ben Murdoch
Browse files

Merges p9 CLs 144856 and 145055 to GIT to enable the Database API in the browser.

parent 4ed7c18f
Loading
Loading
Loading
Loading
+124 −0
Original line number Diff line number Diff line
@@ -151989,6 +151989,25 @@
<parameter name="contentLength" type="long">
</parameter>
</method>
<method name="onExceededDatabaseQuota"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="url" type="java.lang.String">
</parameter>
<parameter name="databaseIdentifier" type="java.lang.String">
</parameter>
<parameter name="currentQuota" type="long">
</parameter>
<parameter name="quotaUpdater" type="android.webkit.WebStorage.QuotaUpdater">
</parameter>
</method>
<method name="onFormResubmission"
 return="void"
 abstract="false"
@@ -153630,6 +153649,25 @@
<parameter name="resultMsg" type="android.os.Message">
</parameter>
</method>
<method name="onExceededDatabaseQuota"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="url" type="java.lang.String">
</parameter>
<parameter name="databaseIdentifier" type="java.lang.String">
</parameter>
<parameter name="currentQuota" type="long">
</parameter>
<parameter name="quotaUpdater" type="android.webkit.WebStorage.QuotaUpdater">
</parameter>
</method>
<method name="onJsAlert"
 return="boolean"
 abstract="false"
@@ -154015,6 +154053,28 @@
 visibility="public"
>
</method>
<method name="getDatabaseEnabled"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getDatabasePath"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getDefaultFixedFontSize"
 return="int"
 abstract="false"
@@ -154355,6 +154415,32 @@
<parameter name="font" type="java.lang.String">
</parameter>
</method>
<method name="setDatabaseEnabled"
 return="void"
 abstract="false"
 native="false"
 synchronized="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="flag" type="boolean">
</parameter>
</method>
<method name="setDatabasePath"
 return="void"
 abstract="false"
 native="false"
 synchronized="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="databasePath" type="java.lang.String">
</parameter>
</method>
<method name="setDefaultFixedFontSize"
 return="void"
 abstract="false"
@@ -154909,6 +154995,44 @@
>
</method>
</class>
<class name="WebStorage"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="WebStorage"
 type="android.webkit.WebStorage"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
</class>
<interface name="WebStorage.QuotaUpdater"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="updateQuota"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="newQuota" type="long">
</parameter>
</method>
</interface>
<class name="WebSyncManager"
 extends="java.lang.Object"
 abstract="true"
+78 −27
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ class CallbackProxy extends Handler {
    private static final int SCALE_CHANGED             = 123;
    private static final int RECEIVED_CERTIFICATE      = 124;
    private static final int SWITCH_OUT_HISTORY        = 125;
    private static final int EXCEEDED_DATABASE_QUOTA   = 126;

    // Message triggered by the client to resume execution
    private static final int NOTIFY                    = 200;
@@ -388,6 +389,23 @@ class CallbackProxy extends Handler {
                }
                break;

            case EXCEEDED_DATABASE_QUOTA:
                if (mWebChromeClient != null) {
                    HashMap<String, Object> map =
                            (HashMap<String, Object>) msg.obj;
                    String databaseIdentifier =
                            (String) map.get("databaseIdentifier");
                    String url = (String) map.get("url");
                    long currentQuota =
                            ((Long) map.get("currentQuota")).longValue();
                    WebStorage.QuotaUpdater quotaUpdater =
                        (WebStorage.QuotaUpdater) map.get("quotaUpdater");

                    mWebChromeClient.onExceededDatabaseQuota(url,
                            databaseIdentifier, currentQuota, quotaUpdater);
                }
                break;

            case JS_ALERT:
                if (mWebChromeClient != null) {
                    final JsResult res = (JsResult) msg.obj;
@@ -1022,4 +1040,37 @@ class CallbackProxy extends Handler {
        }
        return result.getResult();
    }

    /**
     * Called by WebViewCore to inform the Java side that the current origin
     * has overflowed it's database quota. Called in the WebCore thread so
     * posts a message to the UI thread that will prompt the WebChromeClient
     * for what to do. On return back to C++ side, the WebCore thread will
     * sleep pending a new quota value.
     * @param url The URL that caused the quota overflow.
     * @param databaseIdentifier The identifier of the database that the
     *     transaction that caused the overflow was running on.
     * @param currentQuota The current quota the origin is allowed.
     * @param quotaUpdater An instance of a class encapsulating a callback
     *     to WebViewCore to run when the decision to allow or deny more
     *     quota has been made.
     */
    public void onExceededDatabaseQuota(
            String url, String databaseIdentifier, long currentQuota,
            WebStorage.QuotaUpdater quotaUpdater) {
        if (mWebChromeClient == null) {
            quotaUpdater.updateQuota(currentQuota);
            return;
        }

        Message exceededQuota = obtainMessage(EXCEEDED_DATABASE_QUOTA);
        HashMap<String, Object> map = new HashMap();
        map.put("databaseIdentifier", databaseIdentifier);
        map.put("url", url);
        map.put("currentQuota", currentQuota);
        map.put("quotaUpdater", quotaUpdater);
        exceededQuota.obj = map;
        sendMessage(exceededQuota);
    }

}
+17 −0
Original line number Diff line number Diff line
@@ -157,4 +157,21 @@ public class WebChromeClient {
            JsResult result) {
        return false;
    }

   /**
    * Tell the client that the database quota for the origin has been exceeded.
    * @param url The URL that triggered the notification
    * @param databaseIdentifier The identifier of the database that caused the
    *     quota overflow.
    * @param currentQuota The current quota for the origin.
    * @param quotaUpdater A callback to inform the WebCore thread that a new
    *     quota is available. This callback must always be executed at some
    *     point to ensure that the sleeping WebCore thread is woken up.
    */
    public void onExceededDatabaseQuota(String url, String databaseIdentifier,
        long currentQuota, WebStorage.QuotaUpdater quotaUpdater) {
        // This default implementation passes the current quota back to WebCore.
        // WebCore will interpret this that new quota was declined.
        quotaUpdater.updateQuota(currentQuota);
    }
}
+44 −0
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ public class WebSettings {
    private boolean         mSupportZoom = true;
    private boolean         mBuiltInZoomControls = false;
    private boolean         mAllowFileAccess = true;
    private String          mDatabasePath = "";
    private boolean         mDatabaseEnabled = false;
    private String          mAppCachePath = "";
    private boolean         mAppCacheEnabled = false;

@@ -900,6 +902,19 @@ public class WebSettings {
        }
    }

    /**
     * Set the path to where database storage API databases should be saved.
     * This will update WebCore when the Sync runs in the C++ side.
     * @param databasePath String path to the directory where databases should
     *     be saved. May be the empty string but should never be null.
     */
    public synchronized void setDatabasePath(String databasePath) {
        if (databasePath != null && !databasePath.equals(mDatabasePath)) {
            mDatabasePath = databasePath;
            postSync();
        }
    }

    /**
     * Tell the WebView to enable Application Caches API.
     * @param flag True if the WebView should enable Application Caches.
@@ -927,6 +942,35 @@ public class WebSettings {
        }
    }

    /**
     * Set whether the database storage API is enabled.
     * @param flag boolean True if the WebView should use the database storage
     *     API.
     */
    public synchronized void setDatabaseEnabled(boolean flag) {
       if (mDatabaseEnabled != flag) {
           mDatabaseEnabled = flag;
           postSync();
       }
    }

    /**
     * Return the path to where database storage API databases are saved for
     * the current WebView.
     * @return the String path to the database storage API databases.
     */
    public synchronized String getDatabasePath() {
        return mDatabasePath;
    }

    /**
     * Returns true if database storage API is enabled.
     * @return True if the database storage API is enabled.
     */
    public synchronized boolean getDatabaseEnabled() {
        return mDatabaseEnabled;
    }

    /**
     * Return true if javascript is enabled. <b>Note: The default is false.</b>
     * @return True if javascript is enabled.
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.webkit;

/**
 * Functionality for manipulating the webstorage databases.
 */
public final class WebStorage {

    /**
     * Encapsulates a callback function to be executed when a new quota is made
     * available. We primarily want this to allow us to call back the sleeping
     * WebCore thread from outside the WebViewCore class (as the native call
     * is private). It is imperative that this the setDatabaseQuota method is
     * executed once a decision to either allow or deny new quota is made,
     * otherwise the WebCore thread will remain asleep.
     */
    public interface QuotaUpdater {
        public void updateQuota(long newQuota);
    };
}
Loading