本文整理汇总了C++中CefRefPtr::GetElements方法的典型用法代码示例。如果您正苦于以下问题:C++ CefRefPtr::GetElements方法的具体用法?C++ CefRefPtr::GetElements怎么用?C++ CefRefPtr::GetElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CefRefPtr
的用法示例。
在下文中一共展示了CefRefPtr::GetElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DumpRequestContents
void DumpRequestContents(CefRefPtr<CefRequest> request, std::string& str)
{
std::stringstream ss;
ss << "URL: " << std::string(request->GetURL());
ss << "\nMethod: " << std::string(request->GetMethod());
CefRequest::HeaderMap headerMap;
request->GetHeaderMap(headerMap);
if(headerMap.size() > 0) {
ss << "\nHeaders:";
CefRequest::HeaderMap::const_iterator it = headerMap.begin();
for(; it != headerMap.end(); ++it) {
ss << "\n\t" << std::string((*it).first) << ": " <<
std::string((*it).second);
}
}
CefRefPtr<CefPostData> postData = request->GetPostData();
if(postData.get()) {
CefPostData::ElementVector elements;
postData->GetElements(elements);
if(elements.size() > 0) {
ss << "\nPost Data:";
CefRefPtr<CefPostDataElement> element;
CefPostData::ElementVector::const_iterator it = elements.begin();
for(; it != elements.end(); ++it) {
element = (*it);
if(element->GetType() == PDE_TYPE_BYTES) {
// the element is composed of bytes
ss << "\n\tBytes: ";
if(element->GetBytesCount() == 0)
ss << "(empty)";
else {
// retrieve the data.
size_t size = element->GetBytesCount();
char* bytes = new char[size];
element->GetBytes(size, bytes);
ss << std::string(bytes, size);
delete [] bytes;
}
} else if(element->GetType() == PDE_TYPE_FILE) {
ss << "\n\tFile: " << std::string(element->GetFile());
}
}
}
}
str = ss.str();
}
示例2: Execute
// Implementation of the schema handler for appjs:// requests.
void AppjsSchemeHandler::Execute(CefThreadId threadId) {
REQUIRE_UI_THREAD();
HandleScope scope;
Local<Object> global = Context::GetCurrent()->Global();
Local<Object> emitter = global->Get(String::NewSymbol("process"))->ToObject();
const int argc = 3;
Handle<Value> self = WrapObject(this);
Local<Function> cb = FunctionTemplate::New(NodeCallback,self)->GetFunction();
Local<Object> req = Object::New();
Local<String> post = String::New("");
Local<Object> headers = Object::New();
Local<String> files = String::New("");
CefRequest::HeaderMap headerMap;
request_->GetHeaderMap(headerMap);
if (headerMap.size() > 0) {
CefRequest::HeaderMap::const_iterator it = headerMap.begin();
for ( ; it != headerMap.end(); ++it) {
headers->Set(String::New((uint16_t*)(*it).first.c_str()),String::New((uint16_t*)(*it).second.c_str()));
}
}
CefRefPtr<CefPostData> postData = request_->GetPostData();
if(postData.get()){
CefPostData::ElementVector elements;
postData->GetElements(elements);
if (elements.size() > 0) {
CefRefPtr<CefPostDataElement> element;
CefPostData::ElementVector::const_iterator it = elements.begin();
for ( ; it != elements.end(); ++it) {
element = (*it);
if (element->GetType() == PDE_TYPE_BYTES && element->GetBytesCount()) {
// retrieve the data.
size_t size = element->GetBytesCount();
char* bytes = new char[size];
element->GetBytes(size, bytes);
post = String::New(bytes,size);
delete [] bytes;
} else if (element->GetType() == PDE_TYPE_FILE) {
//TODO Needs testing
files = String::New((uint16_t*)element->GetFile().c_str());
}
}
}
}
Handle<Value> method = String::New((uint16_t*)request_->GetMethod().c_str());
Handle<Value> url = String::New((uint16_t*)request_->GetURL().c_str());
req->Set(String::NewSymbol("method"),method);
req->Set(String::NewSymbol("url"),url);
req->Set(String::NewSymbol("post"),post);
req->Set(String::NewSymbol("headers"),headers);
req->Set(String::NewSymbol("files"),files);
Handle<Value> argv[argc] = {String::New("appjs-request"),req,cb};
node::MakeCallback(emitter,"emit",argc,argv);
}