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 CONTENT_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_IMPL_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/containers/scoped_ptr_hash_map.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/observer_list.h" |
| 12 #include "content/browser/android/system_ui_resource.h" |
| 13 #include "ui/base/android/system_ui_resource_manager.h" |
| 14 |
| 15 class SkBitmap; |
| 16 |
| 17 namespace cc { |
| 18 class UIResourceBitmap; |
| 19 } |
| 20 |
| 21 namespace ui { |
| 22 class UIResourceProvider; |
| 23 } |
| 24 |
| 25 namespace content { |
| 26 |
| 27 class SystemUIResource; |
| 28 |
| 29 class SystemUIResourceManagerImpl : public ui::SystemUIResourceManager { |
| 30 public: |
| 31 SystemUIResourceManagerImpl(UIResourceProvider* ui_resource_provider); |
| 32 virtual ~SystemUIResourceManagerImpl() {} |
| 33 |
| 34 virtual void Subscribe(ui::SystemUIResourceManager::Type type, |
| 35 ui::SystemUIResourceLayer* layer) OVERRIDE; |
| 36 virtual void Unsubscribe(ui::SystemUIResourceManager::Type type, |
| 37 ui::SystemUIResourceLayer* layer) OVERRIDE; |
| 38 void RefreshResources(); |
| 39 |
| 40 private: |
| 41 class Data : public SystemUIResourceClient { |
| 42 public: |
| 43 Data(); |
| 44 virtual ~Data(); |
| 45 void Subscribe(ui::SystemUIResourceLayer* layer); |
| 46 void Unsubscribe(ui::SystemUIResourceLayer* layer); |
| 47 void SetResource(scoped_ptr<SystemUIResource> resource); |
| 48 void RefreshResource(); |
| 49 bool HasResource(); |
| 50 |
| 51 // Implements SystemUIResourceClient. |
| 52 virtual void OnUIResourceIdChanged() OVERRIDE; |
| 53 |
| 54 private: |
| 55 typedef ObserverList<ui::SystemUIResourceLayer> Subscribers; |
| 56 scoped_ptr<SystemUIResource> resource_; |
| 57 Subscribers subscribers_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(Data); |
| 60 }; |
| 61 |
| 62 void BuildResource(ui::SystemUIResourceManager::Type type); |
| 63 Data* GetData(ui::SystemUIResourceManager::Type type); |
| 64 static void LoadBitmap(ui::SystemUIResourceManager::Type, |
| 65 SkBitmap* bitmap_holder); |
| 66 void OnFinishedLoadBitmap(ui::SystemUIResourceManager::Type, |
| 67 SkBitmap* bitmap_holder); |
| 68 |
| 69 typedef base::ScopedPtrHashMap<int, Data> SystemUIResourceMap; |
| 70 SystemUIResourceMap resource_map_; |
| 71 UIResourceProvider* ui_resource_provider_; |
| 72 |
| 73 base::WeakPtrFactory<SystemUIResourceManagerImpl> weak_factory_; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(SystemUIResourceManagerImpl); |
| 76 }; |
| 77 |
| 78 } // namespace content |
| 79 |
| 80 #endif // CONTENT_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_IMPL_H_ |
OLD | NEW |