Search in sources :

Example 6 with WebAddress

use of android.net.WebAddress in project XobotOS by xamarin.

the class CookieManager method setCookie.

/**
     * Set cookie for a given url. The old cookie with same host/path/name will
     * be removed. The new cookie will be added if it is not expired or it does
     * not have expiration which implies it is session cookie.
     * @param url The url which cookie is set for
     * @param value The value for set-cookie: in http response header
     * @param privateBrowsing cookie jar to use
     * @hide hiding private browsing
     */
public void setCookie(String url, String value, boolean privateBrowsing) {
    if (!JniUtil.useChromiumHttpStack()) {
        setCookie(url, value);
        return;
    }
    WebAddress uri;
    try {
        uri = new WebAddress(url);
    } catch (ParseException ex) {
        Log.e(LOGTAG, "Bad address: " + url);
        return;
    }
    nativeSetCookie(uri.toString(), value, privateBrowsing);
}
Also used : WebAddress(android.net.WebAddress) ParseException(android.net.ParseException)

Example 7 with WebAddress

use of android.net.WebAddress in project XobotOS by xamarin.

the class URLUtil method guessUrl.

/**
     * Cleans up (if possible) user-entered web addresses
     */
public static String guessUrl(String inUrl) {
    String retVal = inUrl;
    WebAddress webAddress;
    if (DebugFlags.URL_UTIL)
        Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
    if (inUrl.length() == 0)
        return inUrl;
    if (inUrl.startsWith("about:"))
        return inUrl;
    // Do not try to interpret data scheme URLs
    if (inUrl.startsWith("data:"))
        return inUrl;
    // Do not try to interpret file scheme URLs
    if (inUrl.startsWith("file:"))
        return inUrl;
    // Do not try to interpret javascript scheme URLs
    if (inUrl.startsWith("javascript:"))
        return inUrl;
    // bug 762454: strip period off end of url
    if (inUrl.endsWith(".") == true) {
        inUrl = inUrl.substring(0, inUrl.length() - 1);
    }
    try {
        webAddress = new WebAddress(inUrl);
    } catch (ParseException ex) {
        if (DebugFlags.URL_UTIL) {
            Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
        }
        return retVal;
    }
    // Check host
    if (webAddress.getHost().indexOf('.') == -1) {
        // no dot: user probably entered a bare domain.  try .com
        webAddress.setHost("www." + webAddress.getHost() + ".com");
    }
    return webAddress.toString();
}
Also used : WebAddress(android.net.WebAddress) ParseException(android.net.ParseException)

Example 8 with WebAddress

use of android.net.WebAddress in project android_frameworks_base by DirtyUnicorns.

the class URLUtil method guessUrl.

/**
     * Cleans up (if possible) user-entered web addresses
     */
public static String guessUrl(String inUrl) {
    String retVal = inUrl;
    WebAddress webAddress;
    if (TRACE)
        Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
    if (inUrl.length() == 0)
        return inUrl;
    if (inUrl.startsWith("about:"))
        return inUrl;
    // Do not try to interpret data scheme URLs
    if (inUrl.startsWith("data:"))
        return inUrl;
    // Do not try to interpret file scheme URLs
    if (inUrl.startsWith("file:"))
        return inUrl;
    // Do not try to interpret javascript scheme URLs
    if (inUrl.startsWith("javascript:"))
        return inUrl;
    // bug 762454: strip period off end of url
    if (inUrl.endsWith(".") == true) {
        inUrl = inUrl.substring(0, inUrl.length() - 1);
    }
    try {
        webAddress = new WebAddress(inUrl);
    } catch (ParseException ex) {
        if (TRACE) {
            Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
        }
        return retVal;
    }
    // Check host
    if (webAddress.getHost().indexOf('.') == -1) {
        // no dot: user probably entered a bare domain.  try .com
        webAddress.setHost("www." + webAddress.getHost() + ".com");
    }
    return webAddress.toString();
}
Also used : WebAddress(android.net.WebAddress) ParseException(android.net.ParseException)

Example 9 with WebAddress

use of android.net.WebAddress in project android_frameworks_base by AOSPA.

the class WebAddressTest method testHostWithTrailingDot.

// http://b/2337042
@SmallTest
public void testHostWithTrailingDot() {
    WebAddress webAddress = new WebAddress("http://google.com./b/c/g");
    assertEquals("google.com.", webAddress.getHost());
    assertEquals("/b/c/g", webAddress.getPath());
}
Also used : WebAddress(android.net.WebAddress) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 10 with WebAddress

use of android.net.WebAddress in project android_frameworks_base by crdroidandroid.

the class URLUtil method guessUrl.

/**
     * Cleans up (if possible) user-entered web addresses
     */
public static String guessUrl(String inUrl) {
    String retVal = inUrl;
    WebAddress webAddress;
    if (TRACE)
        Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
    if (inUrl.length() == 0)
        return inUrl;
    if (inUrl.startsWith("about:"))
        return inUrl;
    // Do not try to interpret data scheme URLs
    if (inUrl.startsWith("data:"))
        return inUrl;
    // Do not try to interpret file scheme URLs
    if (inUrl.startsWith("file:"))
        return inUrl;
    // Do not try to interpret javascript scheme URLs
    if (inUrl.startsWith("javascript:"))
        return inUrl;
    // bug 762454: strip period off end of url
    if (inUrl.endsWith(".") == true) {
        inUrl = inUrl.substring(0, inUrl.length() - 1);
    }
    try {
        webAddress = new WebAddress(inUrl);
    } catch (ParseException ex) {
        if (TRACE) {
            Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
        }
        return retVal;
    }
    // Check host
    if (webAddress.getHost().indexOf('.') == -1) {
        // no dot: user probably entered a bare domain.  try .com
        webAddress.setHost("www." + webAddress.getHost() + ".com");
    }
    return webAddress.toString();
}
Also used : WebAddress(android.net.WebAddress) ParseException(android.net.ParseException)

Aggregations

WebAddress (android.net.WebAddress)26 ParseException (android.net.ParseException)14 SmallTest (android.test.suitebuilder.annotation.SmallTest)12