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

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

Issue 731133002: Upstream 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
7
8 #include "base/android/jni_android.h"
9 #include "base/id_map.h"
10 #include "cc/resources/ui_resource_client.h"
11 #include "ui/android/ui_android_export.h"
12 #include "ui/gfx/geometry/rect.h"
13
14 namespace content {
15 class UIResourceProvider;
16 }
17
18 namespace ui {
19 namespace android {
Ted C 2014/11/24 19:09:55 Do any of the other top level folders add a namesp
Jaekyun Seok (inactive) 2014/11/24 23:36:56 I will remove it.
20
21 class UIResourceAndroid;
22
23 // A Java counterpart will be generated for this enum.
24 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources
25 enum AndroidResourceType {
26 ANDROID_RESOURCE_TYPE_STATIC = 0,
27 ANDROID_RESOURCE_TYPE_DYNAMIC,
28 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP,
29 ANDROID_RESOURCE_TYPE_SYSTEM,
30
31 ANDROID_RESOURCE_TYPE_COUNT,
32 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC,
33 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_SYSTEM,
34 };
35
36 class UI_ANDROID_EXPORT ResourceManager {
37 public:
38 struct Resource {
39 public:
40 Resource();
41 ~Resource();
42 gfx::Rect Border(const gfx::Size& bounds);
43 gfx::Rect Border(const gfx::Size& bounds, const gfx::InsetsF& scale);
44
45 scoped_ptr<UIResourceAndroid> ui_resource;
46 gfx::Size size;
47 gfx::Rect padding;
48 gfx::Rect aperture;
49 };
50
51 static ResourceManager* FromJavaObject(jobject jobj);
52
53 explicit ResourceManager(content::UIResourceProvider* ui_resource_provider);
54 virtual ~ResourceManager();
55
56 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env);
57
58 ResourceManager::Resource* GetResource(AndroidResourceType res_type,
59 int res_id);
60 void PreloadResource(AndroidResourceType res_type, int res_id);
61
62 // Called from Java ----------------------------------------------------------
63 void OnResourceReady(JNIEnv* env,
64 jobject jobj,
65 jint res_type,
66 jint res_id,
67 jobject bitmap,
68 jint padding_left,
69 jint padding_top,
70 jint padding_right,
71 jint padding_bottom,
72 jint aperture_left,
73 jint aperture_top,
74 jint aperture_right,
75 jint aperture_bottom);
76
77 static bool RegisterResourceManager(JNIEnv* env);
78
79 private:
80 typedef IDMap<Resource, IDMapOwnPointer> ResourceMap;
81
82 content::UIResourceProvider* ui_resource_provider_;
83 ResourceMap resources_[ANDROID_RESOURCE_TYPE_COUNT];
84
85 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
86
87 DISALLOW_COPY_AND_ASSIGN(ResourceManager);
88 };
89
90 } // namespace android
91 } // namespace ui
92
93 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698