mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-24 16:07:42 +01:00
- Fix Mac compile errors due to string type changes (issue #146).
- Fix Windows crash due to string type changes (issue #147). - Add missing svn:eol-style properties. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@149 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
81b7d378f7
commit
e826c9b1a0
@ -40,6 +40,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cef_export.h"
|
||||
#include <stddef.h>
|
||||
|
||||
// CEF character type definitions. wchat_t is 2 bytes on Windows and 4 bytes on
|
||||
// most other platforms.
|
||||
@ -47,7 +48,7 @@ extern "C" {
|
||||
#ifdef _WIN32
|
||||
typedef wchar_t char16_t;
|
||||
#else // _WIN32
|
||||
typedef uint16 char16_t;
|
||||
typedef unsigned short char16_t;
|
||||
#ifndef WCHAR_T_IS_UTF32
|
||||
#define WCHAR_T_IS_UTF32
|
||||
#endif // WCHAR_T_IS_UTF32
|
||||
|
@ -250,7 +250,7 @@ struct CefStringTraitsUTF16 {
|
||||
{
|
||||
return string16(s->str, s->length);
|
||||
}
|
||||
static inline bool FromString16(const string16& str, struct_type* s)
|
||||
static inline bool from_string16(const string16& str, struct_type* s)
|
||||
{
|
||||
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ?
|
||||
true : false;
|
||||
|
@ -245,7 +245,7 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetCefFrame(WebFrame* frame)
|
||||
cef_frame = frame_main_;
|
||||
} else {
|
||||
// Locate or create the appropriate named reference.
|
||||
CefString name = frame->name();
|
||||
CefString name = string16(frame->name());
|
||||
DCHECK(!name.empty());
|
||||
FrameMap::const_iterator it = frames_.find(name);
|
||||
if(it != frames_.end())
|
||||
@ -381,7 +381,7 @@ CefString CefBrowserImpl::GetSource(CefRefPtr<CefFrame> frame)
|
||||
// Retrieve the document string directly
|
||||
WebKit::WebFrame* web_frame = GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
return web_frame->contentAsMarkup();
|
||||
return string16(web_frame->contentAsMarkup());
|
||||
return CefString();
|
||||
}
|
||||
}
|
||||
@ -474,7 +474,7 @@ CefString CefBrowserImpl::GetURL(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
WebFrame* web_frame = GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
return web_frame->url().spec();
|
||||
return std::string(web_frame->url().spec());
|
||||
return CefString();
|
||||
}
|
||||
|
||||
|
@ -391,6 +391,7 @@ void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) {
|
||||
// Make a copy of settings.
|
||||
printing::PrintSettings settings = print_context_.settings();
|
||||
cef_print_options_t print_options;
|
||||
memset(&print_options, 0, sizeof(print_options));
|
||||
settings.UpdatePrintOptions(print_options);
|
||||
|
||||
// Ask the handler if they want to update the print options.
|
||||
|
@ -195,27 +195,26 @@ void BrowserWebViewDelegate::DidMovePlugin(
|
||||
// Protected methods ----------------------------------------------------------
|
||||
|
||||
void BrowserWebViewDelegate::ShowJavaScriptAlert(
|
||||
WebKit::WebFrame* webframe, const std::wstring& message) {
|
||||
NSString *text =
|
||||
[NSString stringWithUTF8String:(std::string(message).c_str())];
|
||||
WebKit::WebFrame* webframe, const CefString& message) {
|
||||
std::string messageStr(message);
|
||||
NSString *text = [NSString stringWithUTF8String:messageStr.c_str()];
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:@"JavaScript Alert"
|
||||
defaultButton:@"OK"
|
||||
alternateButton:nil
|
||||
otherButton:nil
|
||||
informativeTextWithFormat:text];
|
||||
[alert runModal];
|
||||
[text release];
|
||||
}
|
||||
|
||||
bool BrowserWebViewDelegate::ShowJavaScriptConfirm(
|
||||
WebKit::WebFrame* webframe, const std::wstring& message) {
|
||||
WebKit::WebFrame* webframe, const CefString& message) {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BrowserWebViewDelegate::ShowJavaScriptPrompt(
|
||||
WebKit::WebFrame* webframe, const std::wstring& message,
|
||||
const std::wstring& default_value, std::wstring* result) {
|
||||
WebKit::WebFrame* webframe, const CefString& message,
|
||||
const CefString& default_value, CefString* result) {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
@ -228,17 +227,3 @@ bool BrowserWebViewDelegate::ShowFileChooser(std::vector<FilePath>& file_names,
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Private methods ------------------------------------------------------------
|
||||
/*
|
||||
void BrowserWebViewDelegate::SetPageTitle(const std::wstring& title) {
|
||||
[[browser_->GetWebViewHost()->view_handle() window]
|
||||
setTitle:[NSString stringWithUTF8String:(std::string(title).c_str())]];
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::SetAddressBarURL(const GURL& url) {
|
||||
const char* frameURL = url.spec().c_str();
|
||||
NSString *address = [NSString stringWithUTF8String:frameURL];
|
||||
[browser_->GetEditWnd() setStringValue:address];
|
||||
}
|
||||
*/
|
||||
|
@ -283,6 +283,8 @@ void BrowserWebViewDelegate::showContextMenu(
|
||||
if(handler.get()) {
|
||||
// Gather menu information
|
||||
CefHandler::MenuInfo menuInfo;
|
||||
memset(&menuInfo, 0, sizeof(menuInfo));
|
||||
|
||||
CefString linkStr(std::string(data.linkURL.spec()));
|
||||
CefString imageStr(std::string(data.srcURL.spec()));
|
||||
CefString pageStr(std::string(data.pageURL.spec()));
|
||||
|
@ -67,11 +67,7 @@ static void UIT_RegisterPlugin(struct CefPluginInfo* plugin_info)
|
||||
|
||||
NPAPI::PluginVersionInfo info;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
info.path = FilePath(plugin_info->unique_name);
|
||||
#else
|
||||
info.path = FilePath(WideToUTF8(plugin_info->unique_name));
|
||||
#endif
|
||||
info.product_name = plugin_info->display_name;
|
||||
info.file_description = plugin_info->description;
|
||||
info.file_version =plugin_info->version;
|
||||
|
@ -167,7 +167,8 @@ CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1,
|
||||
if (str1->length == 0 && str2->length == 0)
|
||||
return 0;
|
||||
#if defined(WCHAR_T_IS_UTF32)
|
||||
int r = c16memcmp(str1->str, str2->str, std::min(str1->length, str2->length));
|
||||
int r = base::c16memcmp(str1->str, str2->str, std::min(str1->length,
|
||||
str2->length));
|
||||
#else
|
||||
int r = wcsncmp(str1->str, str2->str, std::min(str1->length, str2->length));
|
||||
#endif
|
||||
|
@ -448,11 +448,7 @@ void CefPostDataElementImpl::Set(const net::UploadData::Element& element)
|
||||
std::string(element.bytes().begin(),
|
||||
element.bytes().end()).c_str()));
|
||||
} else if (element.type() == net::UploadData::TYPE_FILE) {
|
||||
#if defined(OS_WIN)
|
||||
SetToFile(element.file_path().value());
|
||||
#else
|
||||
SetToFile(UTF8ToWide(element.file_path().value()));
|
||||
#endif
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ void WebWidgetHost::Paint() {
|
||||
}
|
||||
}
|
||||
|
||||
void WebWidgetHost::SetTooltipText(const std::string& tooltip_text) {
|
||||
void WebWidgetHost::SetTooltipText(const CefString& tooltip_text) {
|
||||
// TODO(port): Implement this method.
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,10 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_created(
|
||||
if(parentBrowser)
|
||||
browserPtr = CefBrowserCToCpp::Wrap(parentBrowser);
|
||||
|
||||
CefString urlStr(url);
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleBeforeCreated(
|
||||
browserPtr, wndInfo, popup?true:false, features, handlerPtr,
|
||||
CefString(url), browserSettings);
|
||||
urlStr, browserSettings);
|
||||
|
||||
if(handlerPtr.get() != origHandler) {
|
||||
// The handler has been changed.
|
||||
@ -177,9 +178,10 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_error(
|
||||
if(!self || !browser || !errorText || !frame)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefString errorTextStr(errorText);
|
||||
return CefHandlerCppToC::Get(self)->HandleLoadError(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode,
|
||||
CefString(failedUrl), CefString(errorText));
|
||||
CefString(failedUrl), errorTextStr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
|
||||
@ -198,10 +200,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
|
||||
|
||||
CefRefPtr<CefStreamReader> streamPtr;
|
||||
|
||||
CefString redirectUrlStr(redirectUrl);
|
||||
CefString mimeTypeStr(mimeType);
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
|
||||
HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser),
|
||||
CefRequestCToCpp::Wrap(request), CefString(redirectUrl), streamPtr,
|
||||
CefString(mimeType), loadFlags);
|
||||
CefRequestCToCpp::Wrap(request), redirectUrlStr, streamPtr, mimeTypeStr,
|
||||
loadFlags);
|
||||
|
||||
if(streamPtr.get())
|
||||
*resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr);
|
||||
@ -257,8 +261,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label(
|
||||
if(!self || !browser || !label)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefString labelStr(label);
|
||||
return CefHandlerCppToC::Get(self)->HandleGetMenuLabel(
|
||||
CefBrowserCToCpp::Wrap(browser), menuId, CefString(label));
|
||||
CefBrowserCToCpp::Wrap(browser), menuId, labelStr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_menu_action(
|
||||
@ -307,12 +312,17 @@ enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
|
||||
|
||||
CefPrintInfo info = *printInfo;
|
||||
|
||||
CefString topLeftStr(topLeft);
|
||||
CefString topCenterStr(topCenter);
|
||||
CefString topRightStr(topRight);
|
||||
CefString bottomLeftStr(bottomLeft);
|
||||
CefString bottomCenterStr(bottomCenter);
|
||||
CefString bottomRightStr(bottomRight);
|
||||
return CefHandlerCppToC::Get(self)->
|
||||
HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser),
|
||||
CefFrameCToCpp::Wrap(frame), info, CefString(url), CefString(title),
|
||||
currentPage, maxPages, CefString(topLeft), CefString(topCenter),
|
||||
CefString(topRight), CefString(bottomLeft), CefString(bottomCenter),
|
||||
CefString(bottomRight));
|
||||
currentPage, maxPages, topLeftStr, topCenterStr, topRightStr,
|
||||
bottomLeftStr, bottomCenterStr, bottomRightStr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_jsalert(
|
||||
@ -364,9 +374,10 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
|
||||
return RV_CONTINUE;
|
||||
|
||||
bool ret = false;
|
||||
CefString resultStr(result);
|
||||
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSPrompt(
|
||||
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
|
||||
CefString(message), CefString(defaultValue), ret, CefString(result));
|
||||
CefString(message), CefString(defaultValue), ret, resultStr);
|
||||
*retval = (ret ? 1 : 0);
|
||||
|
||||
return rv;
|
||||
@ -448,8 +459,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_tooltip(
|
||||
if(!self || !browser || !text)
|
||||
return RV_CONTINUE;
|
||||
|
||||
CefString textStr(text);
|
||||
return CefHandlerCppToC::Get(self)->HandleTooltip(
|
||||
CefBrowserCToCpp::Wrap(browser), CefString(text));
|
||||
CefBrowserCToCpp::Wrap(browser), textStr);
|
||||
}
|
||||
|
||||
enum cef_retval_t CEF_CALLBACK handler_handle_console_message(
|
||||
|
@ -27,8 +27,9 @@ int CEF_CALLBACK scheme_handler_process_request(
|
||||
if(!self || !request || !mime_type || !response_length)
|
||||
return 0;
|
||||
|
||||
CefString mimeTypeStr(mime_type);
|
||||
return CefSchemeHandlerCppToC::Get(self)->ProcessRequest(
|
||||
CefRequestCToCpp::Wrap(request), CefString(mime_type), response_length);
|
||||
CefRequestCToCpp::Wrap(request), mimeTypeStr, response_length);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK scheme_handler_cancel(struct _cef_scheme_handler_t* self)
|
||||
|
@ -35,8 +35,9 @@ int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self,
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> retValPtr;
|
||||
CefString exceptionStr(exception);
|
||||
bool rv = CefV8HandlerCppToC::Get(self)->Execute(CefString(name), objectPtr,
|
||||
list, retValPtr, CefString(exception));
|
||||
list, retValPtr, exceptionStr);
|
||||
if(rv) {
|
||||
if(retValPtr.get() && retval)
|
||||
*retval = CefV8ValueCToCpp::Unwrap(retValPtr);
|
||||
|
@ -385,8 +385,9 @@ int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self,
|
||||
}
|
||||
CefRefPtr<CefV8Value> retvalPtr;
|
||||
|
||||
CefString exceptionStr(exception);
|
||||
bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr,
|
||||
argsList, retvalPtr, CefString(exception));
|
||||
argsList, retvalPtr, exceptionStr);
|
||||
if(retvalPtr.get() && retval)
|
||||
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
|
||||
|
||||
|
@ -95,7 +95,6 @@ const int kWindowHeight = 600;
|
||||
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 {
|
||||
@ -104,7 +103,6 @@ const int kWindowHeight = 600;
|
||||
"\" downloaded successfully.";
|
||||
NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())];
|
||||
[self alert:@"File Download" withMessage:str];
|
||||
[str release];
|
||||
}
|
||||
|
||||
- (void)notifyDownloadError:(id)object {
|
||||
@ -113,7 +111,6 @@ const int kWindowHeight = 600;
|
||||
"\" failed to download.";
|
||||
NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())];
|
||||
[self alert:@"File Download" withMessage:str];
|
||||
[str release];
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification*)notification {
|
||||
@ -281,7 +278,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
window_info.SetAsChild((void*)[mainWnd contentView], 0, 0,
|
||||
kWindowWidth, kWindowHeight);
|
||||
CefBrowser::CreateBrowser(window_info, false, g_handler.get(),
|
||||
L"http://www.google.com");
|
||||
"http://www.google.com");
|
||||
|
||||
// Show the window.
|
||||
[mainWnd makeKeyAndOrderFront: nil];
|
||||
@ -378,10 +375,9 @@ CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||
{
|
||||
// Set the edit window text
|
||||
NSTextField* textField = (NSTextField*)m_EditHwnd;
|
||||
NSString* str =
|
||||
[NSString stringWithUTF8String:(std::string(url).c_str())];
|
||||
std::string urlStr(url);
|
||||
NSString* str = [NSString stringWithUTF8String:urlStr.c_str()];
|
||||
[textField setStringValue:str];
|
||||
[str release];
|
||||
}
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
@ -391,10 +387,9 @@ CefHandler::RetVal ClientHandler::HandleTitleChange(
|
||||
{
|
||||
// Set the frame window title bar
|
||||
NSWindow* window = (NSWindow*)m_MainHwnd;
|
||||
NSString* str =
|
||||
[NSString stringWithUTF8String:(std::string(title).c_str())];
|
||||
std::string titleStr(title);
|
||||
NSString* str = [NSString stringWithUTF8String:titleStr.c_str()];
|
||||
[window setTitle:str];
|
||||
[str release];
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
TEST(StringTest, UTF8)
|
||||
{
|
||||
CefStringUTF8 str1("Test String");
|
||||
ASSERT_EQ(str1.length(), 11);
|
||||
ASSERT_EQ(str1.length(), (size_t)11);
|
||||
ASSERT_FALSE(str1.empty());
|
||||
ASSERT_TRUE(str1.IsOwner());
|
||||
|
||||
@ -52,7 +52,7 @@ TEST(StringTest, UTF8)
|
||||
TEST(StringTest, UTF16)
|
||||
{
|
||||
CefStringUTF16 str1("Test String");
|
||||
ASSERT_EQ(str1.length(), 11);
|
||||
ASSERT_EQ(str1.length(), (size_t)11);
|
||||
ASSERT_FALSE(str1.empty());
|
||||
ASSERT_TRUE(str1.IsOwner());
|
||||
|
||||
@ -91,7 +91,7 @@ TEST(StringTest, UTF16)
|
||||
TEST(StringTest, Wide)
|
||||
{
|
||||
CefStringWide str1("Test String");
|
||||
ASSERT_EQ(str1.length(), 11);
|
||||
ASSERT_EQ(str1.length(), (size_t)11);
|
||||
ASSERT_FALSE(str1.empty());
|
||||
ASSERT_TRUE(str1.IsOwner());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user