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

Unified Diff: ui/android/resources/resource_manager.cc

Issue 755643004: Replace SystemUIResourceManager with ResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix clang build failure Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/android/resources/resource_manager.h ('k') | ui/android/resources/resource_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/resources/resource_manager.cc
diff --git a/ui/android/resources/resource_manager.cc b/ui/android/resources/resource_manager.cc
index 557661f74307b0de6229bf45fb387ef622a68769..a27ea6eb067980648d6b19a1ccd355e44b34dbd4 100644
--- a/ui/android/resources/resource_manager.cc
+++ b/ui/android/resources/resource_manager.cc
@@ -4,9 +4,10 @@
#include "ui/android/resources/resource_manager.h"
-#include "content/public/browser/android/ui_resource_provider.h"
+#include "base/android/jni_string.h"
#include "jni/ResourceManager_jni.h"
#include "ui/android/resources/ui_resource_android.h"
+#include "ui/android/resources/ui_resource_provider.h"
#include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/geometry/insets_f.h"
@@ -45,8 +46,7 @@ ResourceManager* ResourceManager::FromJavaObject(jobject jobj) {
base::android::AttachCurrentThread(), jobj));
}
-ResourceManager::ResourceManager(
- content::UIResourceProvider* ui_resource_provider)
+ResourceManager::ResourceManager(ui::UIResourceProvider* ui_resource_provider)
: ui_resource_provider_(ui_resource_provider) {
JNIEnv* env = base::android::AttachCurrentThread();
java_obj_.Reset(env, Java_ResourceManager_create(
@@ -65,6 +65,14 @@ base::android::ScopedJavaLocalRef<jobject> ResourceManager::GetJavaObject(
return base::android::ScopedJavaLocalRef<jobject>(java_obj_);
}
+cc::UIResourceId ResourceManager::GetUIResourceId(AndroidResourceType res_type,
+ int res_id) {
+ ui::ResourceManager::Resource* resource = GetResource(res_type, res_id);
+ if (!resource->ui_resource)
+ return 0;
+ return resource->ui_resource->id();
+}
+
ResourceManager::Resource* ResourceManager::GetResource(
AndroidResourceType res_type,
int res_id) {
@@ -75,8 +83,7 @@ ResourceManager::Resource* ResourceManager::GetResource(
if (!resource || res_type == ANDROID_RESOURCE_TYPE_DYNAMIC ||
res_type == ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP) {
- Java_ResourceManager_resourceRequested(base::android::AttachCurrentThread(),
- java_obj_.obj(), res_type, res_id);
+ RequestResourceFromJava(res_type, res_id);
resource = resources_[res_type].Lookup(res_id);
}
@@ -92,8 +99,7 @@ void ResourceManager::PreloadResource(AndroidResourceType res_type,
if (resources_[res_type].Lookup(res_id))
return;
- Java_ResourceManager_preloadResource(base::android::AttachCurrentThread(),
- java_obj_.obj(), res_type, res_id);
+ PreloadResourceFromJava(res_type, res_id);
}
void ResourceManager::OnResourceReady(JNIEnv* env,
@@ -135,4 +141,16 @@ bool ResourceManager::RegisterResourceManager(JNIEnv* env) {
return RegisterNativesImpl(env);
}
+void ResourceManager::PreloadResourceFromJava(AndroidResourceType res_type,
+ int res_id) {
+ Java_ResourceManager_preloadResource(base::android::AttachCurrentThread(),
+ java_obj_.obj(), res_type, res_id);
+}
+
+void ResourceManager::RequestResourceFromJava(AndroidResourceType res_type,
+ int res_id) {
+ Java_ResourceManager_resourceRequested(base::android::AttachCurrentThread(),
+ java_obj_.obj(), res_type, res_id);
+}
+
} // namespace ui
« no previous file with comments | « ui/android/resources/resource_manager.h ('k') | ui/android/resources/resource_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698