Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / android / resources / resource_manager_impl.h
blob9f3388d520ea3415237e0b61010b03def2797dc3
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_ANDROID_RESOURCES_RESOURCE_MANAGER_IMPL_H_
6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_IMPL_H_
8 #include "base/id_map.h"
9 #include "ui/android/resources/resource_manager.h"
10 #include "ui/android/ui_android_export.h"
11 #include "ui/gfx/geometry/rect.h"
13 namespace ui {
15 class UI_ANDROID_EXPORT ResourceManagerImpl : public ResourceManager {
16 public:
17 static ResourceManagerImpl* FromJavaObject(jobject jobj);
19 explicit ResourceManagerImpl(ui::UIResourceProvider* ui_resource_provider);
20 ~ResourceManagerImpl() override;
22 // ResourceManager implementation.
23 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override;
24 Resource* GetResource(AndroidResourceType res_type, int res_id) override;
25 void PreloadResource(AndroidResourceType res_type, int res_id) override;
27 // Called from Java
28 // ----------------------------------------------------------
29 void OnResourceReady(JNIEnv* env,
30 jobject jobj,
31 jint res_type,
32 jint res_id,
33 jobject bitmap,
34 jint padding_left,
35 jint padding_top,
36 jint padding_right,
37 jint padding_bottom,
38 jint aperture_left,
39 jint aperture_top,
40 jint aperture_right,
41 jint aperture_bottom);
43 static bool RegisterResourceManager(JNIEnv* env);
45 private:
46 friend class TestResourceManagerImpl;
48 // Start loading the resource. virtual for testing.
49 virtual void PreloadResourceFromJava(AndroidResourceType res_type,
50 int res_id);
51 virtual void RequestResourceFromJava(AndroidResourceType res_type,
52 int res_id);
54 typedef IDMap<Resource, IDMapOwnPointer> ResourceMap;
56 ui::UIResourceProvider* const ui_resource_provider_;
57 ResourceMap resources_[ANDROID_RESOURCE_TYPE_COUNT];
59 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
61 DISALLOW_COPY_AND_ASSIGN(ResourceManagerImpl);
64 } // namespace ui
66 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_IMPL_H_