mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Expose zip archive reading support (issue #30).
Move ClientReadHandler to CefByteReadHandler in cef_wrapper.h. Add support for the time_t data type to cef_parser.py. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@125 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "include/cef.h"
|
||||
#include "include/cef_wrapper.h"
|
||||
#include "cefclient.h"
|
||||
#include "binding_test.h"
|
||||
#include "download_handler.h"
|
||||
@@ -408,21 +409,21 @@ public:
|
||||
// Show the uiapp contents
|
||||
if(LoadBinaryResource(IDS_UIPLUGIN, dwSize, pBytes)) {
|
||||
resourceStream = CefStreamReader::CreateForHandler(
|
||||
new ClientReadHandler(pBytes, dwSize));
|
||||
new CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"text/html";
|
||||
}
|
||||
} else if(wcsstr(url.c_str(), L"/ps_logo2.png") != NULL) {
|
||||
// Any time we find "ps_logo2.png" in the URL substitute in our own image
|
||||
if(LoadBinaryResource(IDS_LOGO, dwSize, pBytes)) {
|
||||
resourceStream = CefStreamReader::CreateForHandler(
|
||||
new ClientReadHandler(pBytes, dwSize));
|
||||
new CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"image/png";
|
||||
}
|
||||
} else if(wcsstr(url.c_str(), L"/logoball.png") != NULL) {
|
||||
// Load the "logoball.png" image resource.
|
||||
if(LoadBinaryResource(IDS_LOGOBALL, dwSize, pBytes)) {
|
||||
resourceStream = CefStreamReader::CreateForHandler(
|
||||
new ClientReadHandler(pBytes, dwSize));
|
||||
new CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"image/png";
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "resource_util.h"
|
||||
|
||||
|
||||
bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes)
|
||||
{
|
||||
extern HINSTANCE hInst;
|
||||
@@ -24,67 +23,3 @@ bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ClientReadHandler implementation
|
||||
|
||||
ClientReadHandler::ClientReadHandler(LPBYTE pBytes, DWORD dwSize)
|
||||
: bytes_(pBytes), size_(dwSize), offset_(0) {}
|
||||
|
||||
size_t ClientReadHandler::Read(void* ptr, size_t size, size_t n)
|
||||
{
|
||||
Lock();
|
||||
size_t s = (size_ - offset_) / size;
|
||||
size_t ret = min(n, s);
|
||||
memcpy(ptr, bytes_ + offset_, ret * size);
|
||||
offset_ += ret * size;
|
||||
Unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ClientReadHandler::Seek(long offset, int whence)
|
||||
{
|
||||
int rv = -1L;
|
||||
Lock();
|
||||
switch(whence) {
|
||||
case SEEK_CUR:
|
||||
if(offset_ + offset > size_) {
|
||||
break;
|
||||
}
|
||||
offset_ += offset;
|
||||
rv = offset_;
|
||||
break;
|
||||
case SEEK_END:
|
||||
if(offset > (int)size_) {
|
||||
break;
|
||||
}
|
||||
offset_ = size_ - offset;
|
||||
rv = offset_;
|
||||
case SEEK_SET:
|
||||
if(offset > (int)size_) {
|
||||
break;
|
||||
}
|
||||
offset_ = offset;
|
||||
rv = offset_;
|
||||
break;
|
||||
}
|
||||
Unlock();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
long ClientReadHandler::Tell()
|
||||
{
|
||||
Lock();
|
||||
long rv = offset_;
|
||||
Unlock();
|
||||
return rv;
|
||||
}
|
||||
|
||||
int ClientReadHandler::Eof()
|
||||
{
|
||||
Lock();
|
||||
int rv = (offset_ >= size_);
|
||||
Unlock();
|
||||
return rv;
|
||||
}
|
||||
|
@@ -6,34 +6,5 @@
|
||||
|
||||
#include "include/cef.h"
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
// Load a resource of type BINARY
|
||||
bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes);
|
||||
|
||||
|
||||
// Implementation of the stream read handler for reading in-memory data.
|
||||
class ClientReadHandler : public CefThreadSafeBase<CefReadHandler>
|
||||
{
|
||||
public:
|
||||
ClientReadHandler(LPBYTE pBytes, DWORD dwSize);
|
||||
|
||||
// Read raw binary data.
|
||||
virtual size_t Read(void* ptr, size_t size, size_t n);
|
||||
|
||||
// Seek to the specified offset position. |whence| may be any one of
|
||||
// SEEK_CUR, SEEK_END or SEEK_SET.
|
||||
virtual int Seek(long offset, int whence);
|
||||
|
||||
// Return the current offset position.
|
||||
virtual long Tell();
|
||||
|
||||
// Return non-zero if at end of file.
|
||||
virtual int Eof();
|
||||
|
||||
private:
|
||||
LPBYTE bytes_;
|
||||
DWORD size_, offset_;
|
||||
};
|
||||
|
@@ -2,6 +2,7 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "include/cef_wrapper.h"
|
||||
#include "scheme_test.h"
|
||||
#include "string_util.h"
|
||||
#include "resource_util.h"
|
||||
|
Reference in New Issue
Block a user