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