Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AndroidProtocolHandler.java

Issue 663573002: Fix Java indentation issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.AssetManager; 8 import android.content.res.AssetManager;
9 import android.net.Uri; 9 import android.net.Uri;
10 import android.util.Log; 10 import android.util.Log;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 } catch (Exception ex) { 57 } catch (Exception ex) {
58 Log.e(TAG, "Error opening inputstream: " + url); 58 Log.e(TAG, "Error opening inputstream: " + url);
59 } 59 }
60 return null; 60 return null;
61 } 61 }
62 62
63 private static int getFieldId(Context context, String assetType, String asse tName) 63 private static int getFieldId(Context context, String assetType, String asse tName)
64 throws ClassNotFoundException, NoSuchFieldException, IllegalAccessExcept ion { 64 throws ClassNotFoundException, NoSuchFieldException, IllegalAccessExcept ion {
65 Class<?> d = context.getClassLoader() 65 Class<?> d = context.getClassLoader()
66 .loadClass(context.getPackageName() + ".R$" + assetType); 66 .loadClass(context.getPackageName() + ".R$" + assetType);
67 java.lang.reflect.Field field = d.getField(assetName); 67 java.lang.reflect.Field field = d.getField(assetName);
68 int id = field.getInt(null); 68 int id = field.getInt(null);
69 return id; 69 return id;
70 } 70 }
71 71
72 private static int getValueType(Context context, int fieldId) { 72 private static int getValueType(Context context, int fieldId) {
73 TypedValue value = new TypedValue(); 73 TypedValue value = new TypedValue();
74 context.getResources().getValue(fieldId, value, true); 74 context.getResources().getValue(fieldId, value, true);
75 return value.type; 75 return value.type;
76 } 76 }
77 77
78 private static InputStream openResource(Context context, Uri uri) { 78 private static InputStream openResource(Context context, Uri uri) {
79 assert uri.getScheme().equals(FILE_SCHEME); 79 assert uri.getScheme().equals(FILE_SCHEME);
80 assert uri.getPath() != null; 80 assert uri.getPath() != null;
81 assert uri.getPath().startsWith(nativeGetAndroidResourcePath()); 81 assert uri.getPath().startsWith(nativeGetAndroidResourcePath());
82 // The path must be of the form "/android_res/asset_type/asset_name.ext" . 82 // The path must be of the form "/android_res/asset_type/asset_name.ext" .
83 List<String> pathSegments = uri.getPathSegments(); 83 List<String> pathSegments = uri.getPathSegments();
84 if (pathSegments.size() != 3) { 84 if (pathSegments.size() != 3) {
85 Log.e(TAG, "Incorrect resource path: " + uri); 85 Log.e(TAG, "Incorrect resource path: " + uri);
86 return null; 86 return null;
87 } 87 }
88 String assetPath = pathSegments.get(0); 88 String assetPath = pathSegments.get(0);
89 String assetType = pathSegments.get(1); 89 String assetType = pathSegments.get(1);
90 String assetName = pathSegments.get(2); 90 String assetName = pathSegments.get(2);
91 if (!("/" + assetPath + "/").equals(nativeGetAndroidResourcePath())) { 91 if (!("/" + assetPath + "/").equals(nativeGetAndroidResourcePath())) {
92 Log.e(TAG, "Resource path does not start with " + nativeGetAndroidRe sourcePath() + 92 Log.e(TAG, "Resource path does not start with " + nativeGetAndroidRe sourcePath() +
93 ": " + uri); 93 ": " + uri);
94 return null; 94 return null;
95 } 95 }
96 // Drop the file extension. 96 // Drop the file extension.
97 assetName = assetName.split("\\.")[0]; 97 assetName = assetName.split("\\.")[0];
98 try { 98 try {
99 // Use the application context for resolving the resource package na me so that we do 99 // Use the application context for resolving the resource package na me so that we do
100 // not use the browser's own resources. Note that if 'context' here belongs to the 100 // not use the browser's own resources. Note that if 'context' here belongs to the
101 // test suite, it does not have a separate application context. In t hat case we use 101 // test suite, it does not have a separate application context. In t hat case we use
102 // the original context object directly. 102 // the original context object directly.
103 if (context.getApplicationContext() != null) { 103 if (context.getApplicationContext() != null) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 * context. 212 * context.
213 */ 213 */
214 public static void setResourceContextForTesting(Context context) { 214 public static void setResourceContextForTesting(Context context) {
215 nativeSetResourceContextForTesting(context); 215 nativeSetResourceContextForTesting(context);
216 } 216 }
217 217
218 private static native void nativeSetResourceContextForTesting(Context contex t); 218 private static native void nativeSetResourceContextForTesting(Context contex t);
219 private static native String nativeGetAndroidAssetPath(); 219 private static native String nativeGetAndroidAssetPath();
220 private static native String nativeGetAndroidResourcePath(); 220 private static native String nativeGetAndroidResourcePath();
221 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698