| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_RESOURCE_RESOURCE_HANDLE_H_ | 5 #ifndef UI_BASE_RESOURCE_RESOURCE_HANDLE_H_ |
| 6 #define UI_BASE_RESOURCE_RESOURCE_HANDLE_H_ | 6 #define UI_BASE_RESOURCE_RESOURCE_HANDLE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| 11 #include "ui/base/layout.h" |
| 11 #include "ui/base/ui_export.h" | 12 #include "ui/base/ui_export.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 class RefCountedStaticMemory; | 15 class RefCountedStaticMemory; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 | 19 |
| 19 class UI_EXPORT ResourceHandle { | 20 class UI_EXPORT ResourceHandle { |
| 20 public: | 21 public: |
| 21 // What type of encoding the text resources use. | 22 // What type of encoding the text resources use. |
| 22 enum TextEncodingType { | 23 enum TextEncodingType { |
| 23 BINARY, | 24 BINARY, |
| 24 UTF8, | 25 UTF8, |
| 25 UTF16 | 26 UTF16 |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 // The scale factors for image resources. | 29 virtual ~ResourceHandle() {} |
| 29 static const float kScaleFactor100x; | |
| 30 static const float kScaleFactor200x; | |
| 31 | 30 |
| 32 virtual ~ResourceHandle() {} | 31 // Returns true if the DataPack contains a resource with id |resource_id|. |
| 32 virtual bool HasResource(uint16 resource_id) const = 0; |
| 33 | 33 |
| 34 // Get resource by id |resource_id|, filling in |data|. | 34 // Get resource by id |resource_id|, filling in |data|. |
| 35 // The data is owned by the DataPack object and should not be modified. | 35 // The data is owned by the DataPack object and should not be modified. |
| 36 // Returns false if the resource id isn't found. | 36 // Returns false if the resource id isn't found. |
| 37 virtual bool GetStringPiece(uint16 resource_id, | 37 virtual bool GetStringPiece(uint16 resource_id, |
| 38 base::StringPiece* data) const = 0; | 38 base::StringPiece* data) const = 0; |
| 39 | 39 |
| 40 // Like GetStringPiece(), but returns a reference to memory. | 40 // Like GetStringPiece(), but returns a reference to memory. |
| 41 // Caller owns the returned object. | 41 // Caller owns the returned object. |
| 42 virtual base::RefCountedStaticMemory* GetStaticMemory( | 42 virtual base::RefCountedStaticMemory* GetStaticMemory( |
| 43 uint16 resource_id) const = 0; | 43 uint16 resource_id) const = 0; |
| 44 | 44 |
| 45 // Get the encoding type of text resources. | 45 // Get the encoding type of text resources. |
| 46 virtual TextEncodingType GetTextEncodingType() const = 0; | 46 virtual TextEncodingType GetTextEncodingType() const = 0; |
| 47 | 47 |
| 48 // The scale of images in this resource pack relative to images in the 1x | 48 // The scale of images in this resource pack relative to images in the 1x |
| 49 // resource pak. | 49 // resource pak. |
| 50 virtual float GetScaleFactor() const = 0; | 50 virtual ScaleFactor GetScaleFactor() const = 0; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 } // namespace ui | 53 } // namespace ui |
| 54 | 54 |
| 55 #endif // UI_BASE_RESOURCE_RESOURCE_HANDLE_H_ | 55 #endif // UI_BASE_RESOURCE_RESOURCE_HANDLE_H_ |
| OLD | NEW |