diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2014-04-03 05:07:12 +0200 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 13:58:03 -0800 |
commit | 3bb5aa25ecf37825ae8202664fdc145c00f46e21 (patch) | |
tree | 6cac9564ef8beac1dfc2b11a466a94ada28f843a /src/com/android/browser/homepages | |
parent | 3bfc8a7a4e4465f8b7fc3003d556a0b4732b0d0a (diff) | |
download | packages_apps_Browser-3bb5aa25ecf37825ae8202664fdc145c00f46e21.zip packages_apps_Browser-3bb5aa25ecf37825ae8202664fdc145c00f46e21.tar.gz packages_apps_Browser-3bb5aa25ecf37825ae8202664fdc145c00f46e21.tar.bz2 |
browser: allow to load browser internal assets
The new webview classes avoid to load urls from local file schemes.
Just replace the load of internal browser assets (most_visited) from
loadUrl to loadData.
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Change-Id: Iee633a1a3599a7e752e15452fa04e15baac2e256
Cherry-Picked: http://review.cyanogenmod.org/#/c/62126/3
Diffstat (limited to 'src/com/android/browser/homepages')
-rw-r--r-- | src/com/android/browser/homepages/HomeProvider.java | 24 | ||||
-rw-r--r-- | src/com/android/browser/homepages/RequestHandler.java | 2 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/com/android/browser/homepages/HomeProvider.java b/src/com/android/browser/homepages/HomeProvider.java index dc55944..a1c1d85 100644 --- a/src/com/android/browser/homepages/HomeProvider.java +++ b/src/com/android/browser/homepages/HomeProvider.java @@ -41,6 +41,7 @@ public class HomeProvider extends ContentProvider { private static final String TAG = "HomeProvider";
public static final String AUTHORITY = "com.android.browser.home";
public static final String MOST_VISITED = "content://" + AUTHORITY + "/";
+ public static final String MOST_VISITED_URL = "about:most_visited";
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
@@ -88,17 +89,24 @@ public class HomeProvider extends ContentProvider { }
}
+ public static boolean isMostVisitedPage(String url) {
+ boolean useMostVisited = BrowserSettings.getInstance().useMostVisitedHomepage();
+ if (useMostVisited && url.startsWith("content://")) {
+ Uri uri = Uri.parse(url);
+ if (AUTHORITY.equals(uri.getAuthority())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public static WebResourceResponse shouldInterceptRequest(Context context,
String url) {
try {
- boolean useMostVisited = BrowserSettings.getInstance().useMostVisitedHomepage();
- if (useMostVisited && url.startsWith("content://")) {
- Uri uri = Uri.parse(url);
- if (AUTHORITY.equals(uri.getAuthority())) {
- InputStream ins = context.getContentResolver()
- .openInputStream(uri);
- return new WebResourceResponse("text/html", "utf-8", ins);
- }
+ if (isMostVisitedPage(url)) {
+ InputStream ins = context.getContentResolver()
+ .openInputStream(Uri.parse(url + "/home"));
+ return new WebResourceResponse("text/html", "utf-8", ins);
}
boolean listFiles = BrowserSettings.getInstance().isDebugEnabled();
if (listFiles && interceptFile(url)) {
diff --git a/src/com/android/browser/homepages/RequestHandler.java b/src/com/android/browser/homepages/RequestHandler.java index 823935e..c73ec9a 100644 --- a/src/com/android/browser/homepages/RequestHandler.java +++ b/src/com/android/browser/homepages/RequestHandler.java @@ -54,7 +54,7 @@ public class RequestHandler extends Thread { OutputStream mOutput;
static {
- sUriMatcher.addURI(HomeProvider.AUTHORITY, "/", INDEX);
+ sUriMatcher.addURI(HomeProvider.AUTHORITY, "home", INDEX);
sUriMatcher.addURI(HomeProvider.AUTHORITY, "res/*/*", RESOURCE);
}
|