Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_BASE_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_H_ | |
| 6 #define UI_BASE_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_H_ | |
| 7 | |
| 8 #include "base/containers/scoped_ptr_hash_map.h" | |
| 9 #include "base/observer_list.h" | |
| 10 #include "cc/resources/ui_resource_client.h" | |
| 11 #include "ui/base/android/system_ui_resource.h" | |
| 12 #include "ui/base/ui_base_export.h" | |
| 13 | |
| 14 namespace cc { | |
| 15 class UIResourceBitmap; | |
| 16 } | |
| 17 | |
| 18 namespace ui { | |
| 19 | |
| 20 class SystemUIResourceLayer; | |
| 21 class UIResourceProvider; | |
| 22 | |
| 23 class UI_BASE_EXPORT SystemUIResourceManager { | |
| 24 public: | |
| 25 SystemUIResourceManager(); | |
| 26 | |
| 27 void SetUIResourceProvider(ui::UIResourceProvider* provider) { | |
|
jdduke (slow)
2014/07/12 01:01:09
Could we instead make this an argument to the cons
powei
2014/07/16 17:10:52
Done. SystemUIResource is now owned by UIResource
| |
| 28 ui_resource_provider_ = provider; | |
| 29 } | |
| 30 | |
| 31 void Subscribe(SystemUIResource::Type type, SystemUIResourceLayer* layer); | |
| 32 void Unsubscribe(SystemUIResource::Type type, SystemUIResourceLayer* layer); | |
| 33 void RefreshResourceOnSubscribers(SystemUIResource::Type type); | |
| 34 virtual ~SystemUIResourceManager() {} | |
|
jdduke (slow)
2014/07/12 01:01:09
Nit: Let's move the destructor up below the constr
powei
2014/07/16 17:10:52
Done.
| |
| 35 | |
| 36 protected: | |
| 37 virtual void BuildResource(ui::SystemUIResource::Type type) = 0; | |
|
jdduke (slow)
2014/07/12 01:01:09
Can you explain why this class needs to be abstrac
powei
2014/07/16 17:10:52
Acknowledged.
| |
| 38 | |
| 39 class Data : public SystemUIResourceClient { | |
| 40 public: | |
| 41 Data(); | |
| 42 virtual ~Data(); | |
| 43 void Subscribe(SystemUIResourceLayer* layer); | |
| 44 void Unsubscribe(SystemUIResourceLayer* layer); | |
| 45 void SetResource(scoped_ptr<SystemUIResource> resource); | |
| 46 void RefreshResource(); | |
| 47 bool HasResource() { return resource_; } | |
| 48 | |
| 49 // Implements SystemUIResourceClient. | |
| 50 virtual void OnUIResourceIdChanged() OVERRIDE; | |
| 51 | |
| 52 private: | |
| 53 typedef ObserverList<SystemUIResourceLayer> Subscribers; | |
| 54 | |
| 55 scoped_ptr<SystemUIResource> resource_; | |
| 56 Subscribers subscribers_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(Data); | |
| 59 }; | |
| 60 | |
| 61 Data* GetData(SystemUIResource::Type type); | |
| 62 | |
| 63 UIResourceProvider* GetUIResourceProvider(); | |
| 64 | |
| 65 private: | |
| 66 typedef base::ScopedPtrHashMap<int, Data> SystemUIResourceMap; | |
| 67 SystemUIResourceMap resource_map_; | |
| 68 UIResourceProvider* ui_resource_provider_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(SystemUIResourceManager); | |
| 71 }; | |
| 72 | |
| 73 } // namespace ui | |
| 74 | |
| 75 #endif // UI_BASE_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_H_ | |
| OLD | NEW |