2010-10-03 23:04:50 +02:00
|
|
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "cefclient/resource_util.h"
|
2011-12-23 18:36:30 +01:00
|
|
|
#include "include/cef_stream.h"
|
|
|
|
#include "include/wrapper/cef_byte_read_handler.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-05-20 16:42:25 +02:00
|
|
|
#if defined(OS_WIN)
|
2010-10-28 22:38:27 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) {
|
2010-10-03 23:04:50 +02:00
|
|
|
extern HINSTANCE hInst;
|
2012-01-10 00:46:23 +01:00
|
|
|
HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(binaryId),
|
2010-10-03 23:04:50 +02:00
|
|
|
MAKEINTRESOURCE(256));
|
2012-01-10 00:46:23 +01:00
|
|
|
if (hRes) {
|
|
|
|
HGLOBAL hGlob = LoadResource(hInst, hRes);
|
|
|
|
if (hGlob) {
|
|
|
|
dwSize = SizeofResource(hInst, hRes);
|
|
|
|
pBytes = (LPBYTE)LockResource(hGlob);
|
|
|
|
if (dwSize > 0 && pBytes)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
2010-10-28 22:38:27 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefRefPtr<CefStreamReader> GetBinaryResourceReader(int binaryId) {
|
2011-03-04 03:14:04 +01:00
|
|
|
DWORD dwSize;
|
|
|
|
LPBYTE pBytes;
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
if (LoadBinaryResource(binaryId, dwSize, pBytes)) {
|
2011-03-04 03:14:04 +01:00
|
|
|
return CefStreamReader::CreateForHandler(
|
|
|
|
new CefByteReadHandler(pBytes, dwSize, NULL));
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#endif // OS_WIN
|