Add Send Intent handler
This commit is contained in:
@@ -8,6 +8,9 @@ package org.chromium.chrome.browser;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.chromium.base.IntentUtils;
|
||||
|
||||
public class BraveIntentHandler extends IntentHandler {
|
||||
private static final String CONNECTION_INFO_HELP_URL =
|
||||
@@ -28,4 +31,44 @@ public class BraveIntentHandler extends IntentHandler {
|
||||
}
|
||||
return super.onNewIntent(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to extract the raw URL from the intent, without further processing.
|
||||
* The URL may be in multiple locations.
|
||||
* @param intent Intent to examine.
|
||||
* @return Raw URL from the intent, or null if raw URL could't be found.
|
||||
*/
|
||||
protected static String extractUrlFromIntent(Intent intent) {
|
||||
if (intent == null) return null;
|
||||
String url = getUrlFromVoiceSearchResult(intent);
|
||||
if (url == null) url = getUrlForCustomTab(intent);
|
||||
if (url == null) url = getUrlForWebapp(intent);
|
||||
if (url == null) url = intent.getDataString();
|
||||
if (url == null) url = getUrlFromText(intent);
|
||||
if (url == null) return null;
|
||||
url = url.trim();
|
||||
return TextUtils.isEmpty(url) ? null : url;
|
||||
}
|
||||
|
||||
protected static String getUrlFromText(Intent intent) {
|
||||
if (intent == null) return null;
|
||||
String text = IntentUtils.safeGetStringExtra(intent, Intent.EXTRA_TEXT);
|
||||
return (text == null || isJavascriptSchemeOrInvalidUrl(text)) ?
|
||||
null : text;
|
||||
}
|
||||
|
||||
private static String getUrlForCustomTab(Intent intent) {
|
||||
assert(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getUrlForWebapp(Intent intent) {
|
||||
assert(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isJavascriptSchemeOrInvalidUrl(String url) {
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user