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 #include "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "base/file_util.h" | |
12 #include "base/files/file_path.h" | |
13 #include "base/logging.h" | 11 #include "base/logging.h" |
14 #include "base/path_service.h" | |
15 #include "base/strings/stringprintf.h" | |
16 #include "jni/ResourceBundle_jni.h" | 12 #include "jni/ResourceBundle_jni.h" |
17 #include "ui/base/resource/resource_handle.h" | 13 #include "ui/base/resource/resource_handle.h" |
18 #include "ui/base/ui_base_paths.h" | |
19 | 14 |
20 namespace ui { | 15 namespace ui { |
21 | 16 |
22 void ResourceBundle::LoadCommonResources() { | |
23 base::FilePath path; | |
24 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &path); | |
25 AddDataPackFromPath(path.AppendASCII("chrome_100_percent.pak"), | |
26 SCALE_FACTOR_100P); | |
27 } | |
28 | |
29 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | 17 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { |
30 // Flipped image is not used on Android. | 18 // Flipped image is not used on Android. |
31 DCHECK_EQ(rtl, RTL_DISABLED); | 19 DCHECK_EQ(rtl, RTL_DISABLED); |
32 return GetImageNamed(resource_id); | 20 return GetImageNamed(resource_id); |
33 } | 21 } |
34 | 22 |
35 bool AssetContainedInApk(const std::string& filename) { | 23 bool AssetContainedInApk(const std::string& filename) { |
36 JNIEnv* env = base::android::AttachCurrentThread(); | 24 JNIEnv* env = base::android::AttachCurrentThread(); |
37 return Java_ResourceBundle_assetContainedInApk( | 25 return Java_ResourceBundle_assetContainedInApk( |
38 env, | 26 env, |
39 base::android::GetApplicationContext(), | 27 base::android::GetApplicationContext(), |
40 base::android::ConvertUTF8ToJavaString(env, filename).obj()); | 28 base::android::ConvertUTF8ToJavaString(env, filename).obj()); |
41 } | 29 } |
42 | 30 |
43 bool RegisterResourceBundleAndroid(JNIEnv* env) { | 31 bool RegisterResourceBundleAndroid(JNIEnv* env) { |
44 return RegisterNativesImpl(env); | 32 return RegisterNativesImpl(env); |
45 } | 33 } |
46 | 34 |
47 } | 35 } // namespace ui |
OLD | NEW |