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

Side by Side Diff: ui/android/resources/resource_manager.h

Issue 755643004: Replace SystemUIResourceManager with ResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply Jared's comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ 5 #ifndef UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ 6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
7 7
8 #include <string>
9
8 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
9 #include "base/id_map.h" 11 #include "base/id_map.h"
10 #include "cc/resources/ui_resource_client.h" 12 #include "cc/resources/ui_resource_client.h"
11 #include "ui/android/ui_android_export.h" 13 #include "ui/android/ui_android_export.h"
14 #include "ui/base/android/system_ui_resource_type.h"
12 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
13 16
14 namespace content {
15 class UIResourceProvider;
16 }
17
18 namespace ui { 17 namespace ui {
19 18
20 class UIResourceAndroid; 19 class UIResourceAndroid;
20 class UIResourceProvider;
21 21
22 // A Java counterpart will be generated for this enum. 22 // A Java counterpart will be generated for this enum.
23 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources 23 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources
24 enum AndroidResourceType { 24 enum AndroidResourceType {
25 ANDROID_RESOURCE_TYPE_STATIC = 0, 25 ANDROID_RESOURCE_TYPE_STATIC = 0,
26 ANDROID_RESOURCE_TYPE_DYNAMIC, 26 ANDROID_RESOURCE_TYPE_DYNAMIC,
27 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, 27 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP,
28 ANDROID_RESOURCE_TYPE_SYSTEM, 28 ANDROID_RESOURCE_TYPE_SYSTEM,
29 29
30 ANDROID_RESOURCE_TYPE_COUNT, 30 ANDROID_RESOURCE_TYPE_COUNT,
31 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC, 31 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC,
32 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_SYSTEM, 32 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_SYSTEM,
33 }; 33 };
34 34
35 class UI_ANDROID_EXPORT ResourceManager { 35 class UI_ANDROID_EXPORT ResourceManager {
jdduke (slow) 2014/12/10 22:33:26 Per discussion offline, this change is already qui
Jaekyun Seok (inactive) 2014/12/10 22:49:12 Done.
36 public: 36 public:
37 struct Resource { 37 struct Resource {
38 public: 38 public:
39 Resource(); 39 Resource();
40 ~Resource(); 40 ~Resource();
41 gfx::Rect Border(const gfx::Size& bounds); 41 gfx::Rect Border(const gfx::Size& bounds);
42 gfx::Rect Border(const gfx::Size& bounds, const gfx::InsetsF& scale); 42 gfx::Rect Border(const gfx::Size& bounds, const gfx::InsetsF& scale);
43 43
44 scoped_ptr<UIResourceAndroid> ui_resource; 44 scoped_ptr<UIResourceAndroid> ui_resource;
45 gfx::Size size; 45 gfx::Size size;
46 gfx::Rect padding; 46 gfx::Rect padding;
47 gfx::Rect aperture; 47 gfx::Rect aperture;
48 }; 48 };
49 49
50 static ResourceManager* FromJavaObject(jobject jobj); 50 static ResourceManager* FromJavaObject(jobject jobj);
51 51
52 explicit ResourceManager(content::UIResourceProvider* ui_resource_provider); 52 explicit ResourceManager(ui::UIResourceProvider* ui_resource_provider);
53 virtual ~ResourceManager(); 53 virtual ~ResourceManager();
54 54
55 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env); 55 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env);
56 56
57 virtual cc::UIResourceId GetUIResourceId(AndroidResourceType res_type,
58 int res_id);
57 ResourceManager::Resource* GetResource(AndroidResourceType res_type, 59 ResourceManager::Resource* GetResource(AndroidResourceType res_type,
58 int res_id); 60 int res_id);
59 void PreloadResource(AndroidResourceType res_type, int res_id); 61 virtual void PreloadResource(AndroidResourceType res_type, int res_id);
60 62
61 // Called from Java ---------------------------------------------------------- 63 // Called from Java ----------------------------------------------------------
62 void OnResourceReady(JNIEnv* env, 64 void OnResourceReady(JNIEnv* env,
63 jobject jobj, 65 jobject jobj,
64 jint res_type, 66 jint res_type,
65 jint res_id, 67 jint res_id,
66 jobject bitmap, 68 jobject bitmap,
67 jint padding_left, 69 jint padding_left,
68 jint padding_top, 70 jint padding_top,
69 jint padding_right, 71 jint padding_right,
70 jint padding_bottom, 72 jint padding_bottom,
71 jint aperture_left, 73 jint aperture_left,
72 jint aperture_top, 74 jint aperture_top,
73 jint aperture_right, 75 jint aperture_right,
74 jint aperture_bottom); 76 jint aperture_bottom);
75 77
76 static bool RegisterResourceManager(JNIEnv* env); 78 static bool RegisterResourceManager(JNIEnv* env);
77 79
78 private: 80 private:
81 friend class TestResourceManager;
82
83 // Start loading the resource. virtual for testing.
84 virtual void PreloadResourceFromJava(AndroidResourceType res_type,
85 int res_id);
86 virtual void RequestResourceFromJava(AndroidResourceType res_type,
87 int res_id);
88
79 typedef IDMap<Resource, IDMapOwnPointer> ResourceMap; 89 typedef IDMap<Resource, IDMapOwnPointer> ResourceMap;
80 90
81 content::UIResourceProvider* ui_resource_provider_; 91 ui::UIResourceProvider* ui_resource_provider_;
82 ResourceMap resources_[ANDROID_RESOURCE_TYPE_COUNT]; 92 ResourceMap resources_[ANDROID_RESOURCE_TYPE_COUNT];
83 93
84 base::android::ScopedJavaGlobalRef<jobject> java_obj_; 94 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
85 95
86 DISALLOW_COPY_AND_ASSIGN(ResourceManager); 96 DISALLOW_COPY_AND_ASSIGN(ResourceManager);
87 }; 97 };
88 98
89 } // namespace ui 99 } // namespace ui
90 100
91 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ 101 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698