mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Introduce CefString and cef_string_t implementations that support string type conversions and customization of the API string type (issue #146).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@145 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -16,30 +16,30 @@ public:
|
||||
|
||||
// Execute with the specified argument list and return value. Return true if
|
||||
// the method was handled.
|
||||
virtual bool Execute(const std::wstring& name,
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception)
|
||||
CefString& exception)
|
||||
{
|
||||
if(name == L"Dump")
|
||||
if(name == "Dump")
|
||||
{
|
||||
// The "Dump" function will return a human-readable dump of the input
|
||||
// arguments.
|
||||
std::wstringstream stream;
|
||||
std::stringstream stream;
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < arguments.size(); ++i)
|
||||
{
|
||||
stream << L"arg[" << i << L"] = ";
|
||||
stream << "arg[" << i << "] = ";
|
||||
PrintValue(arguments[i], stream, 0);
|
||||
stream << L"\n";
|
||||
stream << "\n";
|
||||
}
|
||||
|
||||
retval = CefV8Value::CreateString(stream.str());
|
||||
return true;
|
||||
}
|
||||
else if(name == L"Call")
|
||||
else if(name == "Call")
|
||||
{
|
||||
// The "Call" function will execute a function to get an object and then
|
||||
// return the result of calling a function belonging to that object. The
|
||||
@@ -80,46 +80,46 @@ public:
|
||||
}
|
||||
|
||||
// Simple function for formatted output of a V8 value.
|
||||
void PrintValue(CefRefPtr<CefV8Value> value, std::wstringstream &stream,
|
||||
void PrintValue(CefRefPtr<CefV8Value> value, std::stringstream &stream,
|
||||
int indent)
|
||||
{
|
||||
std::wstringstream indent_stream;
|
||||
std::stringstream indent_stream;
|
||||
for(int i = 0; i < indent; ++i)
|
||||
indent_stream << L" ";
|
||||
std::wstring indent_str = indent_stream.str();
|
||||
indent_stream << " ";
|
||||
std::string indent_str = indent_stream.str();
|
||||
|
||||
if(value->IsUndefined())
|
||||
stream << L"(undefined)";
|
||||
stream << "(undefined)";
|
||||
else if(value->IsNull())
|
||||
stream << L"(null)";
|
||||
stream << "(null)";
|
||||
else if(value->IsBool())
|
||||
stream << L"(bool) " << (value->GetBoolValue() ? L"true" : L"false");
|
||||
stream << "(bool) " << (value->GetBoolValue() ? "true" : "false");
|
||||
else if(value->IsInt())
|
||||
stream << L"(int) " << value->GetIntValue();
|
||||
stream << "(int) " << value->GetIntValue();
|
||||
else if(value->IsDouble())
|
||||
stream << L"(double) " << value->GetDoubleValue();
|
||||
stream << "(double) " << value->GetDoubleValue();
|
||||
else if(value->IsString())
|
||||
stream << L"(string) " << value->GetStringValue().c_str();
|
||||
stream << "(string) " << std::string(value->GetStringValue());
|
||||
else if(value->IsFunction())
|
||||
stream << L"(function) " << value->GetFunctionName().c_str();
|
||||
stream << "(function) " << std::string(value->GetFunctionName());
|
||||
else if(value->IsArray()) {
|
||||
stream << L"(array) [";
|
||||
stream << "(array) [";
|
||||
int len = value->GetArrayLength();
|
||||
for(int i = 0; i < len; ++i) {
|
||||
stream << L"\n " << indent_str.c_str() << i << L" = ";
|
||||
stream << "\n " << indent_str.c_str() << i << " = ";
|
||||
PrintValue(value->GetValue(i), stream, indent+1);
|
||||
}
|
||||
stream << L"\n" << indent_str.c_str() << L"]";
|
||||
stream << "\n" << indent_str.c_str() << "]";
|
||||
} else if(value->IsObject()) {
|
||||
stream << L"(object) [";
|
||||
std::vector<std::wstring> keys;
|
||||
stream << "(object) [";
|
||||
std::vector<CefString> keys;
|
||||
if(value->GetKeys(keys)) {
|
||||
for(size_t i = 0; i < keys.size(); ++i) {
|
||||
stream << L"\n " << indent_str.c_str() << keys[i].c_str() << L" = ";
|
||||
stream << "\n " << indent_str.c_str() << keys[i].c_str() << " = ";
|
||||
PrintValue(value->GetValue(keys[i]), stream, indent+1);
|
||||
}
|
||||
}
|
||||
stream << L"\n" << indent_str.c_str() << L"]";
|
||||
stream << "\n" << indent_str.c_str() << "]";
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -133,41 +133,41 @@ void InitBindingTest(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefV8Value> testObjPtr = CefV8Value::CreateObject(NULL);
|
||||
// Add the new V8 object to the global window object with the name
|
||||
// "cef_test".
|
||||
object->SetValue(L"cef_test", testObjPtr);
|
||||
object->SetValue("cef_test", testObjPtr);
|
||||
|
||||
// Create an instance of ClientV8FunctionHandler as the V8 handler.
|
||||
CefRefPtr<CefV8Handler> handlerPtr = new ClientV8FunctionHandler();
|
||||
|
||||
// Add a new V8 function to the cef_test object with the name "Dump".
|
||||
testObjPtr->SetValue(L"Dump",
|
||||
CefV8Value::CreateFunction(L"Dump", handlerPtr));
|
||||
testObjPtr->SetValue("Dump",
|
||||
CefV8Value::CreateFunction("Dump", handlerPtr));
|
||||
// Add a new V8 function to the cef_test object with the name "Call".
|
||||
testObjPtr->SetValue(L"Call",
|
||||
CefV8Value::CreateFunction(L"Call", handlerPtr));
|
||||
testObjPtr->SetValue("Call",
|
||||
CefV8Value::CreateFunction("Call", handlerPtr));
|
||||
}
|
||||
|
||||
void RunBindingTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
std::wstring html =
|
||||
L"<html><body>ClientV8FunctionHandler says:<br><pre>"
|
||||
L"<script language=\"JavaScript\">"
|
||||
L"document.writeln(window.cef_test.Dump(false, 1, 7.6654,'bar',"
|
||||
L" [false,true],[5, 7.654, 1, 'foo', [true, 'bar'], 8]));"
|
||||
L"document.writeln(window.cef_test.Dump(cef));"
|
||||
L"document.writeln("
|
||||
L" window.cef_test.Call(cef.test.test_object, 'GetMessage'));"
|
||||
L"function my_object() {"
|
||||
L" var obj = {};"
|
||||
L" (function() {"
|
||||
L" obj.GetMessage = function(a) {"
|
||||
L" return 'Calling a function with value '+a+' on a user object succeeded.';"
|
||||
L" };"
|
||||
L" })();"
|
||||
L" return obj;"
|
||||
L"};"
|
||||
L"document.writeln("
|
||||
L" window.cef_test.Call(my_object, 'GetMessage', 'foobar'));"
|
||||
L"</script>"
|
||||
L"</pre></body></html>";
|
||||
browser->GetMainFrame()->LoadString(html, L"about:blank");
|
||||
std::string html =
|
||||
"<html><body>ClientV8FunctionHandler says:<br><pre>"
|
||||
"<script language=\"JavaScript\">"
|
||||
"document.writeln(window.cef_test.Dump(false, 1, 7.6654,'bar',"
|
||||
" [false,true],[5, 7.654, 1, 'foo', [true, 'bar'], 8]));"
|
||||
"document.writeln(window.cef_test.Dump(cef));"
|
||||
"document.writeln("
|
||||
" window.cef_test.Call(cef.test.test_object, 'GetMessage'));"
|
||||
"function my_object() {"
|
||||
" var obj = {};"
|
||||
" (function() {"
|
||||
" obj.GetMessage = function(a) {"
|
||||
" return 'Calling a function with value '+a+' on a user object succeeded.';"
|
||||
" };"
|
||||
" })();"
|
||||
" return obj;"
|
||||
"};"
|
||||
"document.writeln("
|
||||
" window.cef_test.Call(my_object, 'GetMessage', 'foobar'));"
|
||||
"</script>"
|
||||
"</pre></body></html>";
|
||||
browser->GetMainFrame()->LoadString(html, "about:blank");
|
||||
}
|
||||
|
@@ -16,14 +16,14 @@
|
||||
// ClientHandler::ClientDownloadListener implementation
|
||||
|
||||
void ClientHandler::ClientDownloadListener::NotifyDownloadComplete(
|
||||
const std::wstring& fileName)
|
||||
const CefString& fileName)
|
||||
{
|
||||
handler_->SetLastDownloadFile(fileName);
|
||||
handler_->SendNotification(NOTIFY_DOWNLOAD_COMPLETE);
|
||||
}
|
||||
|
||||
void ClientHandler::ClientDownloadListener::NotifyDownloadError(
|
||||
const std::wstring& fileName)
|
||||
const CefString& fileName)
|
||||
{
|
||||
handler_->SetLastDownloadFile(fileName);
|
||||
handler_->SendNotification(NOTIFY_DOWNLOAD_ERROR);
|
||||
@@ -90,36 +90,36 @@ CefHandler::RetVal ClientHandler::HandleLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
|
||||
const std::wstring& failedUrl, std::wstring& errorText)
|
||||
const CefString& failedUrl, CefString& errorText)
|
||||
{
|
||||
if(errorCode == ERR_CACHE_MISS)
|
||||
{
|
||||
// Usually caused by navigating to a page with POST data via back or
|
||||
// forward buttons.
|
||||
errorText = L"<html><head><title>Expired Form Data</title></head>"
|
||||
L"<body><h1>Expired Form Data</h1>"
|
||||
L"<h2>Your form request has expired. "
|
||||
L"Click reload to re-submit the form data.</h2></body>"
|
||||
L"</html>";
|
||||
errorText = "<html><head><title>Expired Form Data</title></head>"
|
||||
"<body><h1>Expired Form Data</h1>"
|
||||
"<h2>Your form request has expired. "
|
||||
"Click reload to re-submit the form data.</h2></body>"
|
||||
"</html>";
|
||||
}
|
||||
else
|
||||
{
|
||||
// All other messages.
|
||||
std::wstringstream ss;
|
||||
ss << L"<html><head><title>Load Failed</title></head>"
|
||||
L"<body><h1>Load Failed</h1>"
|
||||
L"<h2>Load of URL " << failedUrl <<
|
||||
L" failed with error code " << static_cast<int>(errorCode) <<
|
||||
L".</h2></body>"
|
||||
L"</html>";
|
||||
std::stringstream ss;
|
||||
ss << "<html><head><title>Load Failed</title></head>"
|
||||
"<body><h1>Load Failed</h1>"
|
||||
"<h2>Load of URL " << std::string(failedUrl) <<
|
||||
" failed with error code " << static_cast<int>(errorCode) <<
|
||||
".</h2></body>"
|
||||
"</html>";
|
||||
errorText = ss.str();
|
||||
}
|
||||
return RV_HANDLED;
|
||||
}
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleDownloadResponse(
|
||||
CefRefPtr<CefBrowser> browser, const std::wstring& mimeType,
|
||||
const std::wstring& fileName, int64 contentLength,
|
||||
CefRefPtr<CefBrowser> browser, const CefString& mimeType,
|
||||
const CefString& fileName, int64 contentLength,
|
||||
CefRefPtr<CefDownloadHandler>& handler)
|
||||
{
|
||||
// Create the handler for the file download.
|
||||
@@ -129,10 +129,10 @@ CefHandler::RetVal ClientHandler::HandleDownloadResponse(
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefPrintInfo& printInfo, const std::wstring& url, const std::wstring& title,
|
||||
int currentPage, int maxPages, std::wstring& topLeft,
|
||||
std::wstring& topCenter, std::wstring& topRight, std::wstring& bottomLeft,
|
||||
std::wstring& bottomCenter, std::wstring& bottomRight)
|
||||
CefPrintInfo& printInfo, const CefString& url, const CefString& title,
|
||||
int currentPage, int maxPages, CefString& topLeft,
|
||||
CefString& topCenter, CefString& topRight, CefString& bottomLeft,
|
||||
CefString& bottomCenter, CefString& bottomRight)
|
||||
{
|
||||
// Place the page title at top left
|
||||
topLeft = title;
|
||||
@@ -140,8 +140,8 @@ CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter(
|
||||
topRight = url;
|
||||
|
||||
// Place "Page X of Y" at bottom center
|
||||
std::wstringstream strstream;
|
||||
strstream << L"Page " << currentPage << L" of " << maxPages;
|
||||
std::stringstream strstream;
|
||||
strstream << "Page " << currentPage << " of " << maxPages;
|
||||
bottomCenter = strstream.str();
|
||||
|
||||
return RV_CONTINUE;
|
||||
@@ -168,37 +168,32 @@ CefHandler::RetVal ClientHandler::HandleBeforeWindowClose(
|
||||
}
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleConsoleMessage(
|
||||
CefRefPtr<CefBrowser> browser, const std::wstring& message,
|
||||
const std::wstring& source, int line)
|
||||
CefRefPtr<CefBrowser> browser, const CefString& message,
|
||||
const CefString& source, int line)
|
||||
{
|
||||
Lock();
|
||||
bool first_message = m_LogFile.empty();
|
||||
if(first_message) {
|
||||
std::wstringstream ss;
|
||||
std::stringstream ss;
|
||||
ss << AppGetWorkingDirectory();
|
||||
#ifdef _WIN32
|
||||
ss << L"\\";
|
||||
ss << "\\";
|
||||
#else
|
||||
ss << L"/";
|
||||
ss << "/";
|
||||
#endif
|
||||
ss << L"console.log";
|
||||
ss << "console.log";
|
||||
m_LogFile = ss.str();
|
||||
}
|
||||
std::wstring logFile = m_LogFile;
|
||||
std::string logFile = m_LogFile;
|
||||
Unlock();
|
||||
|
||||
FILE* file = NULL;
|
||||
#ifdef _WIN32
|
||||
_wfopen_s(&file, logFile.c_str(), L"a, ccs=UTF-8");
|
||||
#else
|
||||
file = fopen(WStringToString(logFile).c_str(), "a");
|
||||
#endif
|
||||
|
||||
FILE* file = fopen(logFile.c_str(), "a");
|
||||
if(file) {
|
||||
std::wstringstream ss;
|
||||
ss << L"Message: " << message << L"\r\nSource: " << source <<
|
||||
L"\r\nLine: " << line << L"\r\n-----------------------\r\n";
|
||||
fputws(ss.str().c_str(), file);
|
||||
std::stringstream ss;
|
||||
ss << "Message: " << std::string(message) << "\r\nSource: " <<
|
||||
std::string(source) << "\r\nLine: " << line <<
|
||||
"\r\n-----------------------\r\n";
|
||||
fputs(ss.str().c_str(), file);
|
||||
fclose(file);
|
||||
|
||||
if(first_message)
|
||||
@@ -232,24 +227,24 @@ void ClientHandler::SetEditHwnd(CefWindowHandle hwnd)
|
||||
Unlock();
|
||||
}
|
||||
|
||||
std::wstring ClientHandler::GetLogFile()
|
||||
std::string ClientHandler::GetLogFile()
|
||||
{
|
||||
Lock();
|
||||
std::wstring str = m_LogFile;
|
||||
std::string str = m_LogFile;
|
||||
Unlock();
|
||||
return str;
|
||||
}
|
||||
|
||||
void ClientHandler::SetLastDownloadFile(const std::wstring& fileName)
|
||||
void ClientHandler::SetLastDownloadFile(const std::string& fileName)
|
||||
{
|
||||
Lock();
|
||||
m_LastDownloadFile = fileName;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
std::wstring ClientHandler::GetLastDownloadFile()
|
||||
std::string ClientHandler::GetLastDownloadFile()
|
||||
{
|
||||
std::wstring str;
|
||||
std::string str;
|
||||
Lock();
|
||||
str = m_LastDownloadFile;
|
||||
Unlock();
|
||||
@@ -278,25 +273,25 @@ CefWindowHandle AppGetMainHwnd()
|
||||
void RunGetSourceTest(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
// Retrieve the current page source and display.
|
||||
std::wstring source = frame->GetSource();
|
||||
source = StringReplace(source, L"<", L"<");
|
||||
source = StringReplace(source, L">", L">");
|
||||
std::wstringstream ss;
|
||||
ss << L"<html><body>Source:" << L"<pre>" << source
|
||||
<< L"</pre></body></html>";
|
||||
frame->LoadString(ss.str(), L"http://tests/getsource");
|
||||
std::string source = frame->GetSource();
|
||||
source = StringReplace(source, "<", "<");
|
||||
source = StringReplace(source, ">", ">");
|
||||
std::stringstream ss;
|
||||
ss << "<html><body>Source:" << "<pre>" << source
|
||||
<< "</pre></body></html>";
|
||||
frame->LoadString(ss.str(), "http://tests/getsource");
|
||||
}
|
||||
|
||||
void RunGetTextTest(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
// Retrieve the current page text and display.
|
||||
std::wstring text = frame->GetText();
|
||||
text = StringReplace(text, L"<", L"<");
|
||||
text = StringReplace(text, L">", L">");
|
||||
std::wstringstream ss;
|
||||
ss << L"<html><body>Text:" << L"<pre>" << text
|
||||
<< L"</pre></body></html>";
|
||||
frame->LoadString(ss.str(), L"http://tests/gettext");
|
||||
std::string text = frame->GetText();
|
||||
text = StringReplace(text, "<", "<");
|
||||
text = StringReplace(text, ">", ">");
|
||||
std::stringstream ss;
|
||||
ss << "<html><body>Text:" << "<pre>" << text
|
||||
<< "</pre></body></html>";
|
||||
frame->LoadString(ss.str(), "http://tests/gettext");
|
||||
}
|
||||
|
||||
void RunRequestTest(CefRefPtr<CefBrowser> browser)
|
||||
@@ -305,7 +300,7 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
|
||||
CefRefPtr<CefRequest> request(CefRequest::CreateRequest());
|
||||
|
||||
// Set the request URL
|
||||
request->SetURL(L"http://tests/request");
|
||||
request->SetURL("http://tests/request");
|
||||
|
||||
// Add post data to the request. The correct method and content-
|
||||
// type headers will be set by CEF.
|
||||
@@ -320,7 +315,7 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
|
||||
// Add a custom header
|
||||
CefRequest::HeaderMap headerMap;
|
||||
headerMap.insert(
|
||||
std::make_pair(L"X-My-Header", L"My Header Value"));
|
||||
std::make_pair("X-My-Header", "My Header Value"));
|
||||
request->SetHeaderMap(headerMap);
|
||||
|
||||
// Load the request
|
||||
@@ -330,16 +325,16 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
|
||||
void RunJavaScriptExecuteTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
browser->GetMainFrame()->ExecuteJavaScript(
|
||||
L"alert('JavaScript execute works!');", L"about:blank", 0);
|
||||
"alert('JavaScript execute works!');", "about:blank", 0);
|
||||
}
|
||||
|
||||
void RunPopupTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
browser->GetMainFrame()->ExecuteJavaScript(
|
||||
L"window.open('http://www.google.com');", L"about:blank", 0);
|
||||
"window.open('http://www.google.com');", "about:blank", 0);
|
||||
}
|
||||
|
||||
void RunLocalStorageTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
browser->GetMainFrame()->LoadURL(L"http://tests/localstorage");
|
||||
browser->GetMainFrame()->LoadURL("http://tests/localstorage");
|
||||
}
|
||||
|
@@ -20,10 +20,10 @@ public:
|
||||
ClientDownloadListener(ClientHandler* handler) : handler_(handler) {}
|
||||
|
||||
// Called when the download is complete.
|
||||
virtual void NotifyDownloadComplete(const std::wstring& fileName);
|
||||
virtual void NotifyDownloadComplete(const CefString& fileName);
|
||||
|
||||
// Called if the download fails.
|
||||
virtual void NotifyDownloadError(const std::wstring& fileName);
|
||||
virtual void NotifyDownloadError(const CefString& fileName);
|
||||
|
||||
private:
|
||||
ClientHandler* handler_;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
CefWindowInfo& createInfo, bool popup,
|
||||
const CefPopupFeatures& popupFeatures,
|
||||
CefRefPtr<CefHandler>& handler,
|
||||
std::wstring& url,
|
||||
CefString& url,
|
||||
CefBrowserSettings& settings)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
@@ -58,12 +58,12 @@ public:
|
||||
// ignored.
|
||||
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& url);
|
||||
const CefString& url);
|
||||
|
||||
// Event called when the page title changes. The return value is currently
|
||||
// ignored.
|
||||
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& title);
|
||||
const CefString& title);
|
||||
|
||||
// Event called before browser navigation. The client has an opportunity to
|
||||
// modify the |request| object if desired. Return RV_HANDLED to cancel
|
||||
@@ -97,8 +97,8 @@ public:
|
||||
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode,
|
||||
const std::wstring& failedUrl,
|
||||
std::wstring& errorText);
|
||||
const CefString& failedUrl,
|
||||
CefString& errorText);
|
||||
|
||||
// Event called before a resource is loaded. To allow the resource to load
|
||||
// normally return RV_CONTINUE. To redirect the resource to a new url
|
||||
@@ -108,9 +108,9 @@ public:
|
||||
// To cancel loading of the resource return RV_HANDLED.
|
||||
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefRequest> request,
|
||||
std::wstring& redirectUrl,
|
||||
CefString& redirectUrl,
|
||||
CefRefPtr<CefStreamReader>& resourceStream,
|
||||
std::wstring& mimeType,
|
||||
CefString& mimeType,
|
||||
int loadFlags);
|
||||
|
||||
// Called when a server indicates via the 'Content-Disposition' header that a
|
||||
@@ -122,8 +122,8 @@ public:
|
||||
// or RV_HANDLED to cancel the file download.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& mimeType,
|
||||
const std::wstring& fileName,
|
||||
const CefString& mimeType,
|
||||
const CefString& fileName,
|
||||
int64 contentLength,
|
||||
CefRefPtr<CefDownloadHandler>& handler);
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
// item. |label| contains the default text and may be modified to substitute
|
||||
// alternate text. The return value is currently ignored.
|
||||
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
|
||||
MenuId menuId, std::wstring& label)
|
||||
MenuId menuId, CefString& label)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
@@ -177,21 +177,21 @@ public:
|
||||
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefPrintInfo& printInfo,
|
||||
const std::wstring& url,
|
||||
const std::wstring& title,
|
||||
const CefString& url,
|
||||
const CefString& title,
|
||||
int currentPage, int maxPages,
|
||||
std::wstring& topLeft,
|
||||
std::wstring& topCenter,
|
||||
std::wstring& topRight,
|
||||
std::wstring& bottomLeft,
|
||||
std::wstring& bottomCenter,
|
||||
std::wstring& bottomRight);
|
||||
CefString& topLeft,
|
||||
CefString& topCenter,
|
||||
CefString& topRight,
|
||||
CefString& bottomLeft,
|
||||
CefString& bottomCenter,
|
||||
CefString& bottomRight);
|
||||
|
||||
// Run a JS alert message. Return RV_CONTINUE to display the default alert
|
||||
// or RV_HANDLED if you displayed a custom alert.
|
||||
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message)
|
||||
const CefString& message)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
// set |retval| to true if the user accepted the confirmation.
|
||||
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message, bool& retval)
|
||||
const CefString& message, bool& retval)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
@@ -212,10 +212,10 @@ public:
|
||||
// |result| to the resulting value.
|
||||
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message,
|
||||
const std::wstring& defaultValue,
|
||||
const CefString& message,
|
||||
const CefString& defaultValue,
|
||||
bool& retval,
|
||||
std::wstring& result)
|
||||
CefString& result)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
// you can optionally modify |text| and then return RV_CONTINUE to allow
|
||||
// the browser to display the tooltip.
|
||||
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser,
|
||||
std::wstring& text)
|
||||
CefString& text)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
@@ -279,8 +279,8 @@ public:
|
||||
// Called to display a console message. Return RV_HANDLED to stop the message
|
||||
// from being output to the console.
|
||||
RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
const std::wstring& message,
|
||||
const std::wstring& source, int line);
|
||||
const CefString& message,
|
||||
const CefString& source, int line);
|
||||
|
||||
// Called to report find results returned by CefBrowser::Find(). |identifer|
|
||||
// is the identifier passed to CefBrowser::Find(), |count| is the number of
|
||||
@@ -304,10 +304,10 @@ public:
|
||||
CefRefPtr<CefBrowser> GetBrowser() { return m_Browser; }
|
||||
CefWindowHandle GetBrowserHwnd() { return m_BrowserHwnd; }
|
||||
|
||||
std::wstring GetLogFile();
|
||||
std::string GetLogFile();
|
||||
|
||||
void SetLastDownloadFile(const std::wstring& fileName);
|
||||
std::wstring GetLastDownloadFile();
|
||||
void SetLastDownloadFile(const std::string& fileName);
|
||||
std::string GetLastDownloadFile();
|
||||
|
||||
// Send a notification to the application. Notifications should not block the
|
||||
// caller.
|
||||
@@ -339,11 +339,11 @@ protected:
|
||||
// True if the user can navigate forwards
|
||||
bool m_bCanGoForward;
|
||||
|
||||
std::wstring m_LogFile;
|
||||
std::string m_LogFile;
|
||||
|
||||
// Support for downloading files.
|
||||
CefRefPtr<DownloadListener> m_DownloadListener;
|
||||
std::wstring m_LastDownloadFile;
|
||||
std::string m_LastDownloadFile;
|
||||
};
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ CefRefPtr<CefBrowser> AppGetBrowser();
|
||||
CefWindowHandle AppGetMainHwnd();
|
||||
|
||||
// Returns the application working directory.
|
||||
std::wstring AppGetWorkingDirectory();
|
||||
std::string AppGetWorkingDirectory();
|
||||
|
||||
// Implementations for various tests.
|
||||
void RunGetSourceTest(CefRefPtr<CefFrame> frame);
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include "extension_test.h"
|
||||
#include "scheme_test.h"
|
||||
#include "string_util.h"
|
||||
#include "string_util_mac.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <sstream>
|
||||
|
||||
@@ -78,7 +77,7 @@ const int kWindowHeight = 600;
|
||||
if (tempUrl && ![tempUrl scheme])
|
||||
url = [@"http://" stringByAppendingString:url];
|
||||
|
||||
std::wstring urlStr = NSStringToWString(url);
|
||||
std::string urlStr = [url UTF8String];
|
||||
g_handler->GetBrowser()->GetMainFrame()->LoadURL(urlStr);
|
||||
}
|
||||
|
||||
@@ -92,27 +91,27 @@ const int kWindowHeight = 600;
|
||||
}
|
||||
|
||||
- (void)notifyConsoleMessage:(id)object {
|
||||
std::wstringstream ss;
|
||||
ss << L"Console messages will be written to " << g_handler->GetLogFile();
|
||||
NSString* str = WStringToNSString(ss.str());
|
||||
std::stringstream ss;
|
||||
ss << "Console messages will be written to " << g_handler->GetLogFile();
|
||||
NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())];
|
||||
[self alert:@"Console Messages" withMessage:str];
|
||||
[str release];
|
||||
}
|
||||
|
||||
- (void)notifyDownloadComplete:(id)object {
|
||||
std::wstringstream ss;
|
||||
ss << L"File \"" << g_handler->GetLastDownloadFile() <<
|
||||
L"\" downloaded successfully.";
|
||||
NSString* str = WStringToNSString(ss.str());
|
||||
std::stringstream ss;
|
||||
ss << "File \"" << g_handler->GetLastDownloadFile() <<
|
||||
"\" downloaded successfully.";
|
||||
NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())];
|
||||
[self alert:@"File Download" withMessage:str];
|
||||
[str release];
|
||||
}
|
||||
|
||||
- (void)notifyDownloadError:(id)object {
|
||||
std::wstringstream ss;
|
||||
ss << L"File \"" << g_handler->GetLastDownloadFile() <<
|
||||
L"\" failed to download.";
|
||||
NSString* str = WStringToNSString(ss.str());
|
||||
std::stringstream ss;
|
||||
ss << "File \"" << g_handler->GetLastDownloadFile() <<
|
||||
"\" failed to download.";
|
||||
NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())];
|
||||
[self alert:@"File Download" withMessage:str];
|
||||
[str release];
|
||||
}
|
||||
@@ -373,13 +372,14 @@ int main(int argc, char* argv[])
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& url)
|
||||
const CefString& url)
|
||||
{
|
||||
if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain())
|
||||
{
|
||||
// Set the edit window text
|
||||
NSTextField* textField = (NSTextField*)m_EditHwnd;
|
||||
NSString* str = WStringToNSString(url);
|
||||
NSString* str =
|
||||
[NSString stringWithUTF8String:(std::string(url).c_str())];
|
||||
[textField setStringValue:str];
|
||||
[str release];
|
||||
}
|
||||
@@ -387,11 +387,12 @@ CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||
}
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleTitleChange(
|
||||
CefRefPtr<CefBrowser> browser, const std::wstring& title)
|
||||
CefRefPtr<CefBrowser> browser, const CefString& title)
|
||||
{
|
||||
// Set the frame window title bar
|
||||
NSWindow* window = (NSWindow*)m_MainHwnd;
|
||||
NSString* str = WStringToNSString(title);
|
||||
NSString* str =
|
||||
[NSString stringWithUTF8String:(std::string(title).c_str())];
|
||||
[window setTitle:str];
|
||||
[str release];
|
||||
return RV_CONTINUE;
|
||||
@@ -399,17 +400,17 @@ CefHandler::RetVal ClientHandler::HandleTitleChange(
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefRequest> request,
|
||||
std::wstring& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
|
||||
std::wstring& mimeType, int loadFlags)
|
||||
CefString& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
|
||||
CefString& mimeType, int loadFlags)
|
||||
{
|
||||
std::wstring url = request->GetURL();
|
||||
if(url == L"http://tests/request") {
|
||||
std::string url = request->GetURL();
|
||||
if(url == "http://tests/request") {
|
||||
// Show the request contents
|
||||
std::wstring dump;
|
||||
std::string dump;
|
||||
DumpRequestContents(request, dump);
|
||||
resourceStream = CefStreamReader::CreateForData(
|
||||
(void*)dump.c_str(), dump.size() * sizeof(wchar_t));
|
||||
mimeType = L"text/plain";
|
||||
(void*)dump.c_str(), dump.size());
|
||||
mimeType = "text/plain";
|
||||
}
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
@@ -440,7 +441,7 @@ void ClientHandler::SendNotification(NotificationType type)
|
||||
|
||||
// Global functions
|
||||
|
||||
std::wstring AppGetWorkingDirectory()
|
||||
std::string AppGetWorkingDirectory()
|
||||
{
|
||||
return StringToWString(szWorkingDir);
|
||||
return szWorkingDir;
|
||||
}
|
||||
|
@@ -13,8 +13,9 @@
|
||||
#include "scheme_test.h"
|
||||
#include "string_util.h"
|
||||
#include "uiplugin_test.h"
|
||||
#include <sstream>
|
||||
#include <commdlg.h>
|
||||
#include <direct.h>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
@@ -30,7 +31,7 @@
|
||||
HINSTANCE hInst; // current instance
|
||||
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
||||
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
|
||||
TCHAR szWorkingDir[MAX_PATH]; // The current working directory
|
||||
char szWorkingDir[MAX_PATH]; // The current working directory
|
||||
UINT uFindMsg; // Message identifier for find events.
|
||||
HWND hFindDlg = NULL; // Handle for the find dialog.
|
||||
|
||||
@@ -59,12 +60,15 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
// Retrieve the current working directory.
|
||||
if(_wgetcwd(szWorkingDir, MAX_PATH) == NULL)
|
||||
if(_getcwd(szWorkingDir, MAX_PATH) == NULL)
|
||||
szWorkingDir[0] = 0;
|
||||
|
||||
CefSettings settings;
|
||||
CefBrowserSettings browserDefaults;
|
||||
|
||||
// Specify a cache path value.
|
||||
//CefString(&settings.cache_path).FromASCII("c:\\temp\\cache");
|
||||
|
||||
#ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP
|
||||
// Initialize the CEF with messages processed using the current application's
|
||||
// message loop.
|
||||
@@ -357,7 +361,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
// Creat the new child child browser window
|
||||
CefBrowser::CreateBrowser(info, false,
|
||||
static_cast<CefRefPtr<CefHandler> >(g_handler),
|
||||
L"http://www.google.com");
|
||||
"http://www.google.com");
|
||||
|
||||
// Start the timer that will be used to update child window state
|
||||
SetTimer(hWnd, 1, 250, NULL);
|
||||
@@ -401,8 +405,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
if(g_handler.get()) {
|
||||
std::wstringstream ss;
|
||||
ss << L"Console messages will be written to "
|
||||
<< g_handler->GetLogFile();
|
||||
MessageBoxW(hWnd, ss.str().c_str(), L"Console Messages",
|
||||
<< std::wstring(CefString(g_handler->GetLogFile()));
|
||||
MessageBox(hWnd, ss.str().c_str(), L"Console Messages",
|
||||
MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
return 0;
|
||||
@@ -410,14 +414,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case ID_WARN_DOWNLOADERROR:
|
||||
if(g_handler.get()) {
|
||||
std::wstringstream ss;
|
||||
ss << L"File \"" << g_handler->GetLastDownloadFile() << L"\" ";
|
||||
ss << L"File \"" <<
|
||||
std::wstring(CefString(g_handler->GetLastDownloadFile())) <<
|
||||
L"\" ";
|
||||
|
||||
if(wmId == ID_WARN_DOWNLOADCOMPLETE)
|
||||
ss << L"downloaded successfully.";
|
||||
else
|
||||
ss << L"failed to download.";
|
||||
|
||||
MessageBoxW(hWnd, ss.str().c_str(), L"File Download",
|
||||
MessageBox(hWnd, ss.str().c_str(), L"File Download",
|
||||
MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
return 0;
|
||||
@@ -625,18 +631,18 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& url)
|
||||
const CefString& url)
|
||||
{
|
||||
if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain())
|
||||
{
|
||||
// Set the edit window text
|
||||
SetWindowText(m_EditHwnd, url.c_str());
|
||||
SetWindowText(m_EditHwnd, std::wstring(url).c_str());
|
||||
}
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleTitleChange(
|
||||
CefRefPtr<CefBrowser> browser, const std::wstring& title)
|
||||
CefRefPtr<CefBrowser> browser, const CefString& title)
|
||||
{
|
||||
// Set the frame window title bar
|
||||
CefWindowHandle hwnd = browser->GetWindowHandle();
|
||||
@@ -645,53 +651,53 @@ CefHandler::RetVal ClientHandler::HandleTitleChange(
|
||||
// The frame window will be the parent of the browser window
|
||||
hwnd = GetParent(hwnd);
|
||||
}
|
||||
SetWindowText(hwnd, title.c_str());
|
||||
SetWindowText(hwnd, std::wstring(title).c_str());
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefRequest> request,
|
||||
std::wstring& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
|
||||
std::wstring& mimeType, int loadFlags)
|
||||
CefString& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
|
||||
CefString& mimeType, int loadFlags)
|
||||
{
|
||||
DWORD dwSize;
|
||||
LPBYTE pBytes;
|
||||
|
||||
std::wstring url = request->GetURL();
|
||||
if(url == L"http://tests/request") {
|
||||
std::string url = request->GetURL();
|
||||
if(url == "http://tests/request") {
|
||||
// Show the request contents
|
||||
std::wstring dump;
|
||||
std::string dump;
|
||||
DumpRequestContents(request, dump);
|
||||
resourceStream = CefStreamReader::CreateForData(
|
||||
(void*)dump.c_str(), dump.size() * sizeof(wchar_t));
|
||||
mimeType = L"text/plain";
|
||||
} else if(url == L"http://tests/uiapp") {
|
||||
resourceStream = CefStreamReader::CreateForData((void*)dump.c_str(),
|
||||
dump.size());
|
||||
mimeType = "text/plain";
|
||||
} else if(url == "http://tests/uiapp") {
|
||||
// Show the uiapp contents
|
||||
if(LoadBinaryResource(IDS_UIPLUGIN, dwSize, pBytes)) {
|
||||
resourceStream = CefStreamReader::CreateForHandler(
|
||||
new CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"text/html";
|
||||
mimeType = "text/html";
|
||||
}
|
||||
} else if(url == L"http://tests/localstorage") {
|
||||
} else if(url == "http://tests/localstorage") {
|
||||
// Show the localstorage contents
|
||||
if(LoadBinaryResource(IDS_LOCALSTORAGE, dwSize, pBytes)) {
|
||||
resourceStream = CefStreamReader::CreateForHandler(
|
||||
new CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"text/html";
|
||||
mimeType = "text/html";
|
||||
}
|
||||
} else if(wcsstr(url.c_str(), L"/ps_logo2.png") != NULL) {
|
||||
} else if(strstr(url.c_str(), "/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 CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"image/png";
|
||||
mimeType = "image/png";
|
||||
}
|
||||
} else if(wcsstr(url.c_str(), L"/logoball.png") != NULL) {
|
||||
} else if(strstr(url.c_str(), "/logoball.png") != NULL) {
|
||||
// Load the "logoball.png" image resource.
|
||||
if(LoadBinaryResource(IDS_LOGOBALL, dwSize, pBytes)) {
|
||||
resourceStream = CefStreamReader::CreateForHandler(
|
||||
new CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"image/png";
|
||||
mimeType = "image/png";
|
||||
}
|
||||
}
|
||||
return RV_CONTINUE;
|
||||
@@ -720,7 +726,7 @@ void ClientHandler::SendNotification(NotificationType type)
|
||||
|
||||
// Global functions
|
||||
|
||||
std::wstring AppGetWorkingDirectory()
|
||||
std::string AppGetWorkingDirectory()
|
||||
{
|
||||
return szWorkingDir;
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ class ClientDownloadHandler : public CefThreadSafeBase<CefDownloadHandler>
|
||||
{
|
||||
public:
|
||||
ClientDownloadHandler(CefRefPtr<DownloadListener> listener,
|
||||
const std::wstring& fileName)
|
||||
const CefString& fileName)
|
||||
: listener_(listener), filename_(fileName), file_(NULL)
|
||||
{
|
||||
// Open the file on the FILE thread.
|
||||
@@ -140,8 +140,9 @@ public:
|
||||
// Save the file in the user's "My Documents" folder.
|
||||
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE,
|
||||
NULL, 0, szFolderPath))) {
|
||||
LPWSTR name = PathFindFileName(filename_.c_str());
|
||||
LPWSTR ext = PathFindExtension(filename_.c_str());
|
||||
std::wstring fileNameStr = filename_;
|
||||
LPWSTR name = PathFindFileName(fileNameStr.c_str());
|
||||
LPWSTR ext = PathFindExtension(fileNameStr.c_str());
|
||||
int ct = 0;
|
||||
std::wstringstream ss;
|
||||
|
||||
@@ -222,13 +223,13 @@ public:
|
||||
|
||||
private:
|
||||
CefRefPtr<DownloadListener> listener_;
|
||||
std::wstring filename_;
|
||||
CefString filename_;
|
||||
FILE* file_;
|
||||
std::vector<std::vector<char>*> pending_data_;
|
||||
};
|
||||
|
||||
CefRefPtr<CefDownloadHandler> CreateDownloadHandler(
|
||||
CefRefPtr<DownloadListener> listener, const std::wstring& fileName)
|
||||
CefRefPtr<DownloadListener> listener, const CefString& fileName)
|
||||
{
|
||||
return new ClientDownloadHandler(listener, fileName);
|
||||
}
|
||||
|
@@ -12,14 +12,14 @@ class DownloadListener : public CefBase
|
||||
{
|
||||
public:
|
||||
// Called when the download is complete.
|
||||
virtual void NotifyDownloadComplete(const std::wstring& fileName) =0;
|
||||
virtual void NotifyDownloadComplete(const CefString& fileName) =0;
|
||||
|
||||
// Called if the download fails.
|
||||
virtual void NotifyDownloadError(const std::wstring& fileName) =0;
|
||||
virtual void NotifyDownloadError(const CefString& fileName) =0;
|
||||
};
|
||||
|
||||
// Create a new download handler to manage download of a single file.
|
||||
CefRefPtr<CefDownloadHandler> CreateDownloadHandler(
|
||||
CefRefPtr<DownloadListener> listener, const std::wstring& fileName);
|
||||
CefRefPtr<DownloadListener> listener, const CefString& fileName);
|
||||
|
||||
#endif // _CEFCLIENT_DOWNLOAD_HANDLER_H
|
||||
|
@@ -9,18 +9,18 @@
|
||||
class ClientV8ExtensionHandler : public CefThreadSafeBase<CefV8Handler>
|
||||
{
|
||||
public:
|
||||
ClientV8ExtensionHandler() : test_param_(L"An initial string value.") {}
|
||||
ClientV8ExtensionHandler() : test_param_("An initial string value.") {}
|
||||
virtual ~ClientV8ExtensionHandler() {}
|
||||
|
||||
// Execute with the specified argument list and return value. Return true if
|
||||
// the method was handled.
|
||||
virtual bool Execute(const std::wstring& name,
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception)
|
||||
CefString& exception)
|
||||
{
|
||||
if(name == L"SetTestParam")
|
||||
if(name == "SetTestParam")
|
||||
{
|
||||
// Handle the SetTestParam native function by saving the string argument
|
||||
// into the local member.
|
||||
@@ -30,38 +30,38 @@ public:
|
||||
test_param_ = arguments[0]->GetStringValue();
|
||||
return true;
|
||||
}
|
||||
else if(name == L"GetTestParam")
|
||||
else if(name == "GetTestParam")
|
||||
{
|
||||
// Handle the GetTestParam native function by returning the local member
|
||||
// value.
|
||||
retval = CefV8Value::CreateString(test_param_);
|
||||
return true;
|
||||
}
|
||||
else if(name == L"GetTestObject")
|
||||
else if(name == "GetTestObject")
|
||||
{
|
||||
// Handle the GetTestObject native function by creating and returning a
|
||||
// new V8 object.
|
||||
retval = CefV8Value::CreateObject(NULL);
|
||||
// Add a string parameter to the new V8 object.
|
||||
retval->SetValue(L"param", CefV8Value::CreateString(
|
||||
L"Retrieving a parameter on a native object succeeded."));
|
||||
retval->SetValue("param", CefV8Value::CreateString(
|
||||
"Retrieving a parameter on a native object succeeded."));
|
||||
// Add a function to the new V8 object.
|
||||
retval->SetValue(L"GetMessage",
|
||||
CefV8Value::CreateFunction(L"GetMessage", this));
|
||||
retval->SetValue("GetMessage",
|
||||
CefV8Value::CreateFunction("GetMessage", this));
|
||||
return true;
|
||||
}
|
||||
else if(name == L"GetMessage")
|
||||
else if(name == "GetMessage")
|
||||
{
|
||||
// Handle the GetMessage object function by returning a string.
|
||||
retval = CefV8Value::CreateString(
|
||||
L"Calling a function on a native object succeeded.");
|
||||
"Calling a function on a native object succeeded.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
std::wstring test_param_;
|
||||
CefString test_param_;
|
||||
};
|
||||
|
||||
|
||||
@@ -69,43 +69,43 @@ void InitExtensionTest()
|
||||
{
|
||||
// Register a V8 extension with the below JavaScript code that calls native
|
||||
// methods implemented in ClientV8ExtensionHandler.
|
||||
std::wstring code = L"var cef;"
|
||||
L"if (!cef)"
|
||||
L" cef = {};"
|
||||
L"if (!cef.test)"
|
||||
L" cef.test = {};"
|
||||
L"(function() {"
|
||||
L" cef.test.__defineGetter__('test_param', function() {"
|
||||
L" native function GetTestParam();"
|
||||
L" return GetTestParam();"
|
||||
L" });"
|
||||
L" cef.test.__defineSetter__('test_param', function(b) {"
|
||||
L" native function SetTestParam();"
|
||||
L" if(b) SetTestParam(b);"
|
||||
L" });"
|
||||
L" cef.test.test_object = function() {"
|
||||
L" native function GetTestObject();"
|
||||
L" return GetTestObject();"
|
||||
L" };"
|
||||
L"})();";
|
||||
CefRegisterExtension(L"v8/test", code, new ClientV8ExtensionHandler());
|
||||
std::string code = "var cef;"
|
||||
"if (!cef)"
|
||||
" cef = {};"
|
||||
"if (!cef.test)"
|
||||
" cef.test = {};"
|
||||
"(function() {"
|
||||
" cef.test.__defineGetter__('test_param', function() {"
|
||||
" native function GetTestParam();"
|
||||
" return GetTestParam();"
|
||||
" });"
|
||||
" cef.test.__defineSetter__('test_param', function(b) {"
|
||||
" native function SetTestParam();"
|
||||
" if(b) SetTestParam(b);"
|
||||
" });"
|
||||
" cef.test.test_object = function() {"
|
||||
" native function GetTestObject();"
|
||||
" return GetTestObject();"
|
||||
" };"
|
||||
"})();";
|
||||
CefRegisterExtension("v8/test", code, new ClientV8ExtensionHandler());
|
||||
}
|
||||
|
||||
void RunExtensionTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
std::wstring html =
|
||||
L"<html><body>ClientV8ExtensionHandler says:<br><pre>"
|
||||
L"<script language=\"JavaScript\">"
|
||||
L"cef.test.test_param ="
|
||||
L" 'Assign and retrieve a value succeeded the first time.';"
|
||||
L"document.writeln(cef.test.test_param);"
|
||||
L"cef.test.test_param ="
|
||||
L" 'Assign and retrieve a value succeeded the second time.';"
|
||||
L"document.writeln(cef.test.test_param);"
|
||||
L"var obj = cef.test.test_object();"
|
||||
L"document.writeln(obj.param);"
|
||||
L"document.writeln(obj.GetMessage());"
|
||||
L"</script>"
|
||||
L"</pre></body></html>";
|
||||
browser->GetMainFrame()->LoadString(html, L"about:blank");
|
||||
std::string html =
|
||||
"<html><body>ClientV8ExtensionHandler says:<br><pre>"
|
||||
"<script language=\"JavaScript\">"
|
||||
"cef.test.test_param ="
|
||||
" 'Assign and retrieve a value succeeded the first time.';"
|
||||
"document.writeln(cef.test.test_param);"
|
||||
"cef.test.test_param ="
|
||||
" 'Assign and retrieve a value succeeded the second time.';"
|
||||
"document.writeln(cef.test.test_param);"
|
||||
"var obj = cef.test.test_object();"
|
||||
"document.writeln(obj.param);"
|
||||
"document.writeln(obj.GetMessage());"
|
||||
"</script>"
|
||||
"</pre></body></html>";
|
||||
browser->GetMainFrame()->LoadString(html, "about:blank");
|
||||
}
|
||||
|
@@ -9,14 +9,14 @@ void InitPluginTest()
|
||||
{
|
||||
// Structure providing information about the client plugin.
|
||||
CefPluginInfo plugin_info;
|
||||
plugin_info.display_name = L"Client Plugin";
|
||||
plugin_info.unique_name = L"client_plugin";
|
||||
plugin_info.version = L"1, 0, 0, 1";
|
||||
plugin_info.description = L"My Example Client Plugin";
|
||||
plugin_info.display_name = "Client Plugin";
|
||||
plugin_info.unique_name = "client_plugin";
|
||||
plugin_info.version = "1, 0, 0, 1";
|
||||
plugin_info.description = "My Example Client Plugin";
|
||||
|
||||
CefPluginMimeType mime_type;
|
||||
mime_type.mime_type = L"application/x-client-plugin";
|
||||
mime_type.file_extensions.push_back(L"*");
|
||||
mime_type.mime_type = "application/x-client-plugin";
|
||||
mime_type.file_extensions.push_back("*");
|
||||
plugin_info.mime_types.push_back(mime_type);
|
||||
|
||||
plugin_info.np_getentrypoints = NP_GetEntryPoints;
|
||||
@@ -29,10 +29,10 @@ void InitPluginTest()
|
||||
|
||||
void RunPluginTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
std::wstring html =
|
||||
L"<html><body>Client Plugin:<br>"
|
||||
L"<embed type=\"application/x-client-plugin\""
|
||||
L"width=600 height=40>"
|
||||
L"</body></html>";
|
||||
browser->GetMainFrame()->LoadString(html, L"about:blank");
|
||||
std::string html =
|
||||
"<html><body>Client Plugin:<br>"
|
||||
"<embed type=\"application/x-client-plugin\""
|
||||
"width=600 height=40>"
|
||||
"</body></html>";
|
||||
browser->GetMainFrame()->LoadString(html, "about:blank");
|
||||
}
|
||||
|
@@ -28,13 +28,13 @@ public:
|
||||
// specified number of bytes have been read. If there is a response set
|
||||
// |mime_type| to the mime type for the response.
|
||||
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
|
||||
std::wstring& mime_type, int* response_length)
|
||||
CefString& mime_type, int* response_length)
|
||||
{
|
||||
bool handled = false;
|
||||
|
||||
Lock();
|
||||
std::wstring url = request->GetURL();
|
||||
if(wcsstr(url.c_str(), L"handler.html") != NULL) {
|
||||
std::string url = request->GetURL();
|
||||
if(strstr(url.c_str(), "handler.html") != NULL) {
|
||||
// Build the response html
|
||||
html_ = "<html><head><title>Client Scheme Handler</title></head><body>"
|
||||
"This contents of this page page are served by the "
|
||||
@@ -48,9 +48,9 @@ public:
|
||||
html_.append("<pre>");
|
||||
|
||||
// Output a string representation of the request
|
||||
std::wstring dump;
|
||||
std::string dump;
|
||||
DumpRequestContents(request, dump);
|
||||
html_.append(WStringToString(dump));
|
||||
html_.append(dump);
|
||||
|
||||
html_.append("</pre><br/>Try the test form:"
|
||||
"<form method=\"POST\" action=\"handler.html\">"
|
||||
@@ -64,10 +64,10 @@ public:
|
||||
bytes_ = html_.c_str();
|
||||
|
||||
// Set the resulting mime type
|
||||
mime_type = L"text/html";
|
||||
mime_type = "text/html";
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if(wcsstr(url.c_str(), L"client.gif") != NULL) {
|
||||
else if(strstr(url.c_str(), "client.gif") != NULL) {
|
||||
// Load the response image
|
||||
DWORD dwSize;
|
||||
LPBYTE pBytes;
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
bytes_ = reinterpret_cast<const char*>(pBytes);
|
||||
handled = true;
|
||||
// Set the resulting mime type
|
||||
mime_type = L"image/jpg";
|
||||
mime_type = "image/jpg";
|
||||
}
|
||||
}
|
||||
#endif // _WIN32
|
||||
@@ -140,10 +140,10 @@ public:
|
||||
|
||||
void InitSchemeTest()
|
||||
{
|
||||
CefRegisterScheme(L"client", L"tests", new ClientSchemeHandlerFactory());
|
||||
CefRegisterScheme("client", "tests", new ClientSchemeHandlerFactory());
|
||||
}
|
||||
|
||||
void RunSchemeTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
browser->GetMainFrame()->LoadURL(L"client://tests/handler.html");
|
||||
browser->GetMainFrame()->LoadURL("client://tests/handler.html");
|
||||
}
|
||||
|
@@ -5,20 +5,21 @@
|
||||
#include "string_util.h"
|
||||
#include <sstream>
|
||||
|
||||
void DumpRequestContents(CefRefPtr<CefRequest> request, std::wstring& str)
|
||||
void DumpRequestContents(CefRefPtr<CefRequest> request, std::string& str)
|
||||
{
|
||||
std::wstringstream ss;
|
||||
std::stringstream ss;
|
||||
|
||||
ss << L"URL: " << request->GetURL();
|
||||
ss << L"\nMethod: " << request->GetMethod();
|
||||
ss << "URL: " << std::string(request->GetURL());
|
||||
ss << "\nMethod: " << std::string(request->GetMethod());
|
||||
|
||||
CefRequest::HeaderMap headerMap;
|
||||
request->GetHeaderMap(headerMap);
|
||||
if(headerMap.size() > 0) {
|
||||
ss << L"\nHeaders:";
|
||||
ss << "\nHeaders:";
|
||||
CefRequest::HeaderMap::const_iterator it = headerMap.begin();
|
||||
for(; it != headerMap.end(); ++it) {
|
||||
ss << L"\n\t" << (*it).first << L": " << (*it).second;
|
||||
ss << "\n\t" << std::string((*it).first) << ": " <<
|
||||
std::string((*it).second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,26 +28,26 @@ void DumpRequestContents(CefRefPtr<CefRequest> request, std::wstring& str)
|
||||
CefPostData::ElementVector elements;
|
||||
postData->GetElements(elements);
|
||||
if(elements.size() > 0) {
|
||||
ss << L"\nPost Data:";
|
||||
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 << L"\n\tBytes: ";
|
||||
ss << "\n\tBytes: ";
|
||||
if(element->GetBytesCount() == 0)
|
||||
ss << L"(empty)";
|
||||
ss << "(empty)";
|
||||
else {
|
||||
// retrieve the data.
|
||||
size_t size = element->GetBytesCount();
|
||||
char* bytes = new char[size];
|
||||
element->GetBytes(size, bytes);
|
||||
ss << StringToWString(std::string(bytes, size));
|
||||
ss << std::string(bytes, size);
|
||||
delete [] bytes;
|
||||
}
|
||||
} else if(element->GetType() == PDE_TYPE_FILE) {
|
||||
ss << L"\n\tFile: " << element->GetFile();
|
||||
ss << "\n\tFile: " << std::string(element->GetFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,19 +56,19 @@ void DumpRequestContents(CefRefPtr<CefRequest> request, std::wstring& str)
|
||||
str = ss.str();
|
||||
}
|
||||
|
||||
std::wstring StringReplace(const std::wstring& str, const std::wstring& from,
|
||||
const std::wstring& to)
|
||||
std::string StringReplace(const std::string& str, const std::string& from,
|
||||
const std::string& to)
|
||||
{
|
||||
std::wstring result = str;
|
||||
std::wstring::size_type pos = 0;
|
||||
std::wstring::size_type from_len = from.length();
|
||||
std::wstring::size_type to_len = to.length();
|
||||
std::string result = str;
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type from_len = from.length();
|
||||
std::string::size_type to_len = to.length();
|
||||
do {
|
||||
pos = result.find(from, pos);
|
||||
if(pos != std::wstring::npos) {
|
||||
if(pos != std::string::npos) {
|
||||
result.replace(pos, from_len, to);
|
||||
pos += to_len;
|
||||
}
|
||||
} while(pos != std::wstring::npos);
|
||||
} while(pos != std::string::npos);
|
||||
return result;
|
||||
}
|
||||
|
@@ -6,20 +6,12 @@
|
||||
#define _CEFCLIENT_STRING_UTIL_H
|
||||
|
||||
#include "include/cef.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
// Convert a std::string to a std::wstring
|
||||
std::wstring StringToWString(const std::string& s);
|
||||
|
||||
// Convert a std::wstring to a std::string
|
||||
std::string WStringToString(const std::wstring& s);
|
||||
|
||||
// Dump the contents of the request into a string.
|
||||
void DumpRequestContents(CefRefPtr<CefRequest> request, std::wstring& str);
|
||||
void DumpRequestContents(CefRefPtr<CefRequest> request, std::string& str);
|
||||
|
||||
// Replace all instances of |from| with |to| in |str|.
|
||||
std::wstring StringReplace(const std::wstring& str, const std::wstring& from,
|
||||
const std::wstring& to);
|
||||
std::string StringReplace(const std::string& str, const std::string& from,
|
||||
const std::string& to);
|
||||
|
||||
#endif // _CEFCLIENT_STRING_UTIL_H
|
||||
|
@@ -1,22 +0,0 @@
|
||||
// Copyright (c) 2010 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.
|
||||
|
||||
#ifndef _CEFCLIENT_STRING_UTIL_MAC_H
|
||||
#define _CEFCLIENT_STRING_UTIL_MAC_H
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
#include <string>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
// Convert a std::wstring to an NSString. The NSString must be released by the
|
||||
// caller.
|
||||
NSString* WStringToNSString(const std::wstring& str);
|
||||
|
||||
// Convert an NSString to a std::wstring.
|
||||
std::wstring NSStringToWString(NSString* str);
|
||||
|
||||
#endif // defined(__APPLE__)
|
||||
|
||||
#endif // _CEFCLIENT_STRING_UTIL_MAC_H
|
@@ -1,47 +0,0 @@
|
||||
// Copyright (c) 2010 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.
|
||||
|
||||
#include "string_util.h"
|
||||
#include "string_util_mac.h"
|
||||
#include "util.h"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
#if TARGET_RT_BIG_ENDIAN
|
||||
#define WCHAR_T_ENCODING NSUTF32BigEndianStringEncoding
|
||||
#else
|
||||
#define WCHAR_T_ENCODING NSUTF32LittleEndianStringEncoding
|
||||
#endif
|
||||
|
||||
std::wstring StringToWString(const std::string& s)
|
||||
{
|
||||
NSString* nsstr = [[NSString alloc] initWithCString:s.c_str()];
|
||||
std::wstring wstr = NSStringToWString(nsstr);
|
||||
[nsstr release];
|
||||
return wstr;
|
||||
}
|
||||
|
||||
std::string WStringToString(const std::wstring& s)
|
||||
{
|
||||
NSString* nsstr = WStringToNSString(s);
|
||||
std::string str = [nsstr UTF8String];
|
||||
[nsstr release];
|
||||
return str;
|
||||
}
|
||||
|
||||
NSString* WStringToNSString(const std::wstring& str)
|
||||
{
|
||||
return [[NSString alloc] initWithBytes:(void*)str.c_str()
|
||||
length:str.length()*4
|
||||
encoding:WCHAR_T_ENCODING];
|
||||
}
|
||||
|
||||
std::wstring NSStringToWString(NSString* str)
|
||||
{
|
||||
NSData* data = [str dataUsingEncoding:WCHAR_T_ENCODING];
|
||||
return std::wstring((wchar_t*)[data bytes],
|
||||
[data length] / sizeof(wchar_t));
|
||||
}
|
||||
|
||||
#endif // defined(__APPLE__)
|
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2010 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.
|
||||
|
||||
#include "string_util.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
std::wstring StringToWString(const std::string& s)
|
||||
{
|
||||
wchar_t* wch;
|
||||
UINT bytes = MultiByteToWideChar(CP_ACP, 0, s.c_str(), s.size()+1, NULL, 0);
|
||||
wch = new wchar_t[bytes];
|
||||
if(wch)
|
||||
bytes = MultiByteToWideChar(CP_ACP, 0, s.c_str(), s.size()+1, wch, bytes);
|
||||
std::wstring str = wch;
|
||||
delete [] wch;
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string WStringToString(const std::wstring& s)
|
||||
{
|
||||
char* ch;
|
||||
UINT bytes = WideCharToMultiByte(CP_ACP, 0, s.c_str(), s.size()+1, NULL, 0,
|
||||
NULL, NULL);
|
||||
ch = new char[bytes];
|
||||
if(ch)
|
||||
bytes = WideCharToMultiByte(CP_ACP, 0, s.c_str(), s.size()+1, ch, bytes,
|
||||
NULL, NULL);
|
||||
std::string str = ch;
|
||||
delete [] ch;
|
||||
return str;
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
@@ -141,9 +141,9 @@ NPError API_CALL NP_UIShutdown(void)
|
||||
// Send the notification to the browser as a JavaScript function call.
|
||||
static void NotifyNewRotation(float value)
|
||||
{
|
||||
std::wstringstream buf;
|
||||
buf << L"notifyNewRotation(" << value << L");";
|
||||
AppGetBrowser()->GetMainFrame()->ExecuteJavaScript(buf.str(), std::wstring(),
|
||||
std::stringstream buf;
|
||||
buf << "notifyNewRotation(" << value << ");";
|
||||
AppGetBrowser()->GetMainFrame()->ExecuteJavaScript(buf.str(), CefString(),
|
||||
0);
|
||||
}
|
||||
|
||||
|
@@ -15,13 +15,13 @@ public:
|
||||
|
||||
// Execute with the specified argument list and return value. Return true if
|
||||
// the method was handled.
|
||||
virtual bool Execute(const std::wstring& name,
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
std::wstring& exception)
|
||||
CefString& exception)
|
||||
{
|
||||
if(name == L"modifyRotation") {
|
||||
if(name == "modifyRotation") {
|
||||
// This function requires one argument.
|
||||
if(arguments.size() != 1)
|
||||
return false;
|
||||
@@ -40,11 +40,11 @@ public:
|
||||
ModifyRotation(increment);
|
||||
return true;
|
||||
}
|
||||
} else if(name == L"resetRotation") {
|
||||
} else if(name == "resetRotation") {
|
||||
// Reset the rotation value.
|
||||
ResetRotation();
|
||||
return true;
|
||||
} else if(name == L"viewSource") {
|
||||
} else if(name == "viewSource") {
|
||||
// View the page source.
|
||||
AppGetBrowser()->GetMainFrame()->ViewSource();
|
||||
return true;
|
||||
@@ -58,14 +58,14 @@ void InitUIPluginTest()
|
||||
{
|
||||
// Structure providing information about the client plugin.
|
||||
CefPluginInfo plugin_info;
|
||||
plugin_info.display_name = L"Client UI Plugin";
|
||||
plugin_info.unique_name = L"client_ui_plugin";
|
||||
plugin_info.version = L"1, 0, 0, 1";
|
||||
plugin_info.description = L"My Example Client UI Plugin";
|
||||
plugin_info.display_name = "Client UI Plugin";
|
||||
plugin_info.unique_name = "client_ui_plugin";
|
||||
plugin_info.version = "1, 0, 0, 1";
|
||||
plugin_info.description = "My Example Client UI Plugin";
|
||||
|
||||
CefPluginMimeType mime_type;
|
||||
mime_type.mime_type = L"application/x-client-ui-plugin";
|
||||
mime_type.file_extensions.push_back(L"*");
|
||||
mime_type.mime_type = "application/x-client-ui-plugin";
|
||||
mime_type.file_extensions.push_back("*");
|
||||
plugin_info.mime_types.push_back(mime_type);
|
||||
|
||||
plugin_info.np_getentrypoints = NP_UIGetEntryPoints;
|
||||
@@ -77,29 +77,29 @@ void InitUIPluginTest()
|
||||
|
||||
// Register a V8 extension with the below JavaScript code that calls native
|
||||
// methods implemented in ClientV8UIHandler.
|
||||
std::wstring code = L"var cef;"
|
||||
L"if (!cef)"
|
||||
L" cef = {};"
|
||||
L"if (!cef.uiapp)"
|
||||
L" cef.uiapp = {};"
|
||||
L"(function() {"
|
||||
L" cef.uiapp.modifyRotation = function(val) {"
|
||||
L" native function modifyRotation();"
|
||||
L" return modifyRotation(val);"
|
||||
L" };"
|
||||
L" cef.uiapp.resetRotation = function() {"
|
||||
L" native function resetRotation();"
|
||||
L" return resetRotation();"
|
||||
L" };"
|
||||
L" cef.uiapp.viewSource = function() {"
|
||||
L" native function viewSource();"
|
||||
L" return viewSource();"
|
||||
L" };"
|
||||
L"})();";
|
||||
CefRegisterExtension(L"uiplugin/test", code, new ClientV8UIHandler());
|
||||
std::string code = "var cef;"
|
||||
"if (!cef)"
|
||||
" cef = {};"
|
||||
"if (!cef.uiapp)"
|
||||
" cef.uiapp = {};"
|
||||
"(function() {"
|
||||
" cef.uiapp.modifyRotation = function(val) {"
|
||||
" native function modifyRotation();"
|
||||
" return modifyRotation(val);"
|
||||
" };"
|
||||
" cef.uiapp.resetRotation = function() {"
|
||||
" native function resetRotation();"
|
||||
" return resetRotation();"
|
||||
" };"
|
||||
" cef.uiapp.viewSource = function() {"
|
||||
" native function viewSource();"
|
||||
" return viewSource();"
|
||||
" };"
|
||||
"})();";
|
||||
CefRegisterExtension("uiplugin/test", code, new ClientV8UIHandler());
|
||||
}
|
||||
|
||||
void RunUIPluginTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
browser->GetMainFrame()->LoadURL(L"http://tests/uiapp");
|
||||
browser->GetMainFrame()->LoadURL("http://tests/uiapp");
|
||||
}
|
||||
|
Reference in New Issue
Block a user