| OLD | NEW |
| (Empty) |
| 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 #include "ui/base/resource/resource_data_dll_win.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/memory/ref_counted_memory.h" | |
| 9 #include "base/win/resource_util.h" | |
| 10 | |
| 11 namespace ui { | |
| 12 | |
| 13 ResourceDataDLL::ResourceDataDLL(HINSTANCE module) : module_(module) { | |
| 14 DCHECK(module_); | |
| 15 } | |
| 16 | |
| 17 ResourceDataDLL::~ResourceDataDLL() { | |
| 18 } | |
| 19 | |
| 20 bool ResourceDataDLL::HasResource(uint16 resource_id) const { | |
| 21 void* data_ptr; | |
| 22 size_t data_size; | |
| 23 return base::win::GetDataResourceFromModule(module_, | |
| 24 resource_id, | |
| 25 &data_ptr, | |
| 26 &data_size); | |
| 27 } | |
| 28 | |
| 29 bool ResourceDataDLL::GetStringPiece(uint16 resource_id, | |
| 30 base::StringPiece* data) const { | |
| 31 DCHECK(data); | |
| 32 void* data_ptr; | |
| 33 size_t data_size; | |
| 34 if (base::win::GetDataResourceFromModule(module_, | |
| 35 resource_id, | |
| 36 &data_ptr, | |
| 37 &data_size)) { | |
| 38 data->set(static_cast<const char*>(data_ptr), data_size); | |
| 39 return true; | |
| 40 } | |
| 41 return false; | |
| 42 } | |
| 43 | |
| 44 base::RefCountedStaticMemory* ResourceDataDLL::GetStaticMemory( | |
| 45 uint16 resource_id) const { | |
| 46 void* data_ptr; | |
| 47 size_t data_size; | |
| 48 if (base::win::GetDataResourceFromModule(module_, resource_id, &data_ptr, | |
| 49 &data_size)) { | |
| 50 return new base::RefCountedStaticMemory(data_ptr, data_size); | |
| 51 } | |
| 52 return NULL; | |
| 53 } | |
| 54 | |
| 55 ResourceHandle::TextEncodingType ResourceDataDLL::GetTextEncodingType() const { | |
| 56 return BINARY; | |
| 57 } | |
| 58 | |
| 59 ScaleFactor ResourceDataDLL::GetScaleFactor() const { | |
| 60 return ui::SCALE_FACTOR_NONE; | |
| 61 } | |
| 62 | |
| 63 } // namespace ui | |
| OLD | NEW |