use of android.net.WebAddress in project android_frameworks_base by ParanoidAndroid.
the class BrowserFrame method maybeSavePassword.
/**
* If this looks like a POST request (form submission) containing a username
* and password, give the user the option of saving them. Will either do
* nothing, or block until the UI interaction is complete.
*
* Called directly by WebKit.
*
* @param postData The data about to be sent as the body of a POST request.
* @param username The username entered by the user (sniffed from the DOM).
* @param password The password entered by the user (sniffed from the DOM).
*/
private void maybeSavePassword(byte[] postData, String username, String password) {
if (postData == null || username == null || username.isEmpty() || password == null || password.isEmpty()) {
// No password to save.
return;
}
if (!mSettings.getSavePassword()) {
// User doesn't want to save passwords.
return;
}
try {
if (DebugFlags.BROWSER_FRAME) {
Assert.assertNotNull(mCallbackProxy.getBackForwardList().getCurrentItem());
}
WebAddress uri = new WebAddress(mCallbackProxy.getBackForwardList().getCurrentItem().getUrl());
String schemePlusHost = uri.getScheme() + uri.getHost();
// Check to see if the username & password appear in
// the post data (there could be another form on the
// page and that was posted instead.
String postString = new String(postData);
if (postString.contains(URLEncoder.encode(username)) && postString.contains(URLEncoder.encode(password))) {
String[] saved = mDatabase.getUsernamePassword(schemePlusHost);
if (saved != null) {
// save password
if (saved[0] != null) {
// non-null username implies that user has
// chosen to save password, so update the
// recorded password
mDatabase.setUsernamePassword(schemePlusHost, username, password);
}
} else {
// CallbackProxy will handle creating the resume
// message
mCallbackProxy.onSavePassword(schemePlusHost, username, password, null);
}
}
} catch (ParseException ex) {
// if it is bad uri, don't save its password
}
}
use of android.net.WebAddress in project android_frameworks_base by ParanoidAndroid.
the class WebAddressTest method testPathWithoutLeadingSlash.
// http://b/1011602
@SmallTest
public void testPathWithoutLeadingSlash() {
WebAddress webAddress = new WebAddress("http://www.myspace.com?si=1");
assertEquals("www.myspace.com", webAddress.getHost());
assertEquals("/?si=1", webAddress.getPath());
}
use of android.net.WebAddress in project android_frameworks_base by ParanoidAndroid.
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());
}
use of android.net.WebAddress in project platform_frameworks_base by android.
the class WebAddressTest method testPathWithoutLeadingSlash.
// http://b/1011602
@SmallTest
public void testPathWithoutLeadingSlash() {
WebAddress webAddress = new WebAddress("http://www.myspace.com?si=1");
assertEquals("www.myspace.com", webAddress.getHost());
assertEquals("/?si=1", webAddress.getPath());
}
use of android.net.WebAddress in project XobotOS by xamarin.
the class BrowserFrame method maybeSavePassword.
/**
* If this looks like a POST request (form submission) containing a username
* and password, give the user the option of saving them. Will either do
* nothing, or block until the UI interaction is complete.
*
* Called by startLoadingResource when using the Apache HTTP stack.
* Called directly by WebKit when using the Chrome HTTP stack.
*
* @param postData The data about to be sent as the body of a POST request.
* @param username The username entered by the user (sniffed from the DOM).
* @param password The password entered by the user (sniffed from the DOM).
*/
private void maybeSavePassword(byte[] postData, String username, String password) {
if (postData == null || username == null || username.isEmpty() || password == null || password.isEmpty()) {
// No password to save.
return;
}
if (!mSettings.getSavePassword()) {
// User doesn't want to save passwords.
return;
}
try {
if (DebugFlags.BROWSER_FRAME) {
Assert.assertNotNull(mCallbackProxy.getBackForwardList().getCurrentItem());
}
WebAddress uri = new WebAddress(mCallbackProxy.getBackForwardList().getCurrentItem().getUrl());
String schemePlusHost = uri.getScheme() + uri.getHost();
// Check to see if the username & password appear in
// the post data (there could be another form on the
// page and that was posted instead.
String postString = new String(postData);
if (postString.contains(URLEncoder.encode(username)) && postString.contains(URLEncoder.encode(password))) {
String[] saved = mDatabase.getUsernamePassword(schemePlusHost);
if (saved != null) {
// save password
if (saved[0] != null) {
// non-null username implies that user has
// chosen to save password, so update the
// recorded password
mDatabase.setUsernamePassword(schemePlusHost, username, password);
}
} else {
// CallbackProxy will handle creating the resume
// message
mCallbackProxy.onSavePassword(schemePlusHost, username, password, null);
}
}
} catch (ParseException ex) {
// if it is bad uri, don't save its password
}
}
Aggregations