OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 org.chromium.base.CalledByNative; | 7 import org.chromium.base.CalledByNative; |
8 import org.chromium.base.JNINamespace; | 8 import org.chromium.base.JNINamespace; |
9 | 9 |
10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
(...skipping 15 matching lines...) Expand all Loading... | |
26 // a specific load error. | 26 // a specific load error. |
27 public static int RAW_LOAD_ERROR; | 27 public static int RAW_LOAD_ERROR; |
28 | 28 |
29 // Raw resource ID for an HTML page to be displayed in the case of | 29 // Raw resource ID for an HTML page to be displayed in the case of |
30 // a generic load error. (It's called NO_DOMAIN for legacy reasons). | 30 // a generic load error. (It's called NO_DOMAIN for legacy reasons). |
31 public static int RAW_NO_DOMAIN; | 31 public static int RAW_NO_DOMAIN; |
32 | 32 |
33 // String resource ID for the default text encoding to use. | 33 // String resource ID for the default text encoding to use. |
34 public static int STRING_DEFAULT_TEXT_ENCODING; | 34 public static int STRING_DEFAULT_TEXT_ENCODING; |
35 | 35 |
36 // String for full screen video. | |
37 public static int STRING_VIDEO_INVALID_PLAYBACK; | |
benm (inactive)
2012/12/10 10:54:35
As these are resources defined in content/, you sh
acleung
2013/01/07 23:40:03
I don't fully follow. I am getting these resource
benm (inactive)
2013/01/08 12:31:51
You're right to get them from the android framewor
| |
38 public static int STRING_VIDEO_ERROR_UNKNOWN; | |
39 public static int STRING_VIDEO_ERROR_BUTTON; | |
40 public static int STRING_VIDEO_ERROR_TITLE; | |
41 public static int STRING_VIDEO_LOADING; | |
42 | |
36 // The embedder should inject a Resources object that will be used | 43 // The embedder should inject a Resources object that will be used |
37 // to resolve Resource IDs into the actual resources. | 44 // to resolve Resource IDs into the actual resources. |
38 private static Resources sResources; | 45 private static Resources sResources; |
39 | 46 |
40 // Loading some resources is expensive, so cache the results. | 47 // Loading some resources is expensive, so cache the results. |
41 private static Map<Integer, SoftReference<String> > sResourceCache; | 48 private static Map<Integer, SoftReference<String> > sResourceCache; |
42 | 49 |
43 private static final int TYPE_STRING = 0; | 50 private static final int TYPE_STRING = 0; |
44 private static final int TYPE_RAW = 1; | 51 private static final int TYPE_RAW = 1; |
45 | 52 |
46 public static void setResources(Resources resources) { | 53 public static void setResources(Resources resources) { |
47 sResources = resources; | 54 sResources = resources; |
48 sResourceCache = new HashMap<Integer, SoftReference<String> >(); | 55 sResourceCache = new HashMap<Integer, SoftReference<String> >(); |
49 } | 56 } |
50 | 57 |
58 public static String getVideoInvalidPlayback() { | |
59 return getResource(STRING_VIDEO_INVALID_PLAYBACK, TYPE_STRING); | |
60 } | |
61 | |
62 public static String getVideoErrorUnknown() { | |
63 return getResource(STRING_VIDEO_ERROR_UNKNOWN, TYPE_STRING); | |
64 } | |
65 | |
66 public static String getVideoErrorButton() { | |
67 return getResource(STRING_VIDEO_ERROR_BUTTON, TYPE_STRING); | |
68 } | |
69 | |
70 public static String getVideoErrorTitle() { | |
71 return getResource(STRING_VIDEO_ERROR_TITLE, TYPE_STRING); | |
72 } | |
73 | |
74 public static String getVideoLoading() { | |
75 return getResource(STRING_VIDEO_LOADING, TYPE_STRING); | |
76 } | |
77 | |
51 @CalledByNative | 78 @CalledByNative |
52 public static String getDefaultTextEncoding() { | 79 public static String getDefaultTextEncoding() { |
53 return getResource(STRING_DEFAULT_TEXT_ENCODING, TYPE_STRING); | 80 return getResource(STRING_DEFAULT_TEXT_ENCODING, TYPE_STRING); |
54 } | 81 } |
55 | 82 |
56 @CalledByNative | 83 @CalledByNative |
57 public static String getNoDomainPageContent() { | 84 public static String getNoDomainPageContent() { |
58 return getResource(RAW_NO_DOMAIN, TYPE_RAW); | 85 return getResource(RAW_NO_DOMAIN, TYPE_RAW); |
59 } | 86 } |
60 | 87 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 try { | 136 try { |
110 if (isr != null) { | 137 if (isr != null) { |
111 isr.close(); | 138 isr.close(); |
112 } | 139 } |
113 } catch(IOException e) { | 140 } catch(IOException e) { |
114 } | 141 } |
115 } | 142 } |
116 return result; | 143 return result; |
117 } | 144 } |
118 } | 145 } |
OLD | NEW |