Fix various Mac compile errors.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@115 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
4474199dba
commit
383168173a
|
@ -41,14 +41,16 @@ using WebKit::WebURL;
|
|||
using WebKit::WebURLRequest;
|
||||
using WebKit::WebView;
|
||||
using webkit_glue::StdStringToWebString;
|
||||
using webkit_glue::StdWStringToWebString;
|
||||
using webkit_glue::WebStringToStdString;
|
||||
using webkit_glue::WebStringToStdWString;
|
||||
|
||||
|
||||
CefBrowserImpl::CefBrowserImpl(CefWindowInfo& windowInfo, bool popup,
|
||||
CefRefPtr<CefHandler> handler)
|
||||
: window_info_(windowInfo), is_popup_(popup), is_modal_(false),
|
||||
handler_(handler), webviewhost_(NULL), popuphost_(NULL), unique_id_(0),
|
||||
frame_main_(NULL)
|
||||
handler_(handler), webviewhost_(NULL), popuphost_(NULL),
|
||||
frame_main_(NULL), unique_id_(0)
|
||||
{
|
||||
delegate_.reset(new BrowserWebViewDelegate(this));
|
||||
popup_delegate_.reset(new BrowserWebViewDelegate(this));
|
||||
|
@ -190,7 +192,7 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const std::wstring& name)
|
|||
if (!view)
|
||||
return NULL;
|
||||
|
||||
WebFrame* frame = view->findFrameByName(name);
|
||||
WebFrame* frame = view->findFrameByName(StdWStringToWebString(name));
|
||||
if(frame)
|
||||
return GetCefFrame(frame);
|
||||
return NULL;
|
||||
|
@ -285,7 +287,7 @@ WebFrame* CefBrowserImpl::GetWebFrame(CefRefPtr<CefFrame> frame)
|
|||
std::wstring name = frame->GetName();
|
||||
if(name.empty())
|
||||
return view ->mainFrame();
|
||||
return view ->findFrameByName(name);
|
||||
return view ->findFrameByName(StdWStringToWebString(name));
|
||||
}
|
||||
|
||||
void CefBrowserImpl::Undo(CefRefPtr<CefFrame> frame)
|
||||
|
@ -578,11 +580,12 @@ void CefBrowserImpl::UIT_LoadURLForRequest(CefFrame* frame,
|
|||
if (url.empty())
|
||||
return;
|
||||
|
||||
GURL gurl(url);
|
||||
GURL gurl(StdWStringToWebString(url));
|
||||
|
||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||
// Try to add "http://" at the beginning
|
||||
gurl = GURL(std::wstring(L"http://") + url);
|
||||
std::wstring new_url = std::wstring(L"http://") + url;
|
||||
gurl = GURL(StdWStringToWebString(new_url));
|
||||
if (!gurl.is_valid())
|
||||
return;
|
||||
}
|
||||
|
@ -600,11 +603,12 @@ void CefBrowserImpl::UIT_LoadHTML(CefFrame* frame,
|
|||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
GURL gurl(url);
|
||||
GURL gurl(StdWStringToWebString(url));
|
||||
|
||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||
// Try to add "http://" at the beginning
|
||||
gurl = GURL(std::wstring(L"http://") + url);
|
||||
std::wstring new_url = std::wstring(L"http://") + url;
|
||||
gurl = GURL(StdWStringToWebString(new_url));
|
||||
if (!gurl.is_valid())
|
||||
return;
|
||||
}
|
||||
|
@ -622,11 +626,12 @@ void CefBrowserImpl::UIT_LoadHTMLForStreamRef(CefFrame* frame,
|
|||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
GURL gurl(url);
|
||||
GURL gurl(StdWStringToWebString(url));
|
||||
|
||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||
// Try to add "http://" at the beginning
|
||||
gurl = GURL(std::wstring(L"http://") + url);
|
||||
std::wstring new_url = std::wstring(L"http://") + url;
|
||||
gurl = GURL(StdWStringToWebString(new_url));
|
||||
if (!gurl.is_valid())
|
||||
return;
|
||||
}
|
||||
|
@ -662,8 +667,9 @@ void CefBrowserImpl::UIT_ExecuteJavaScript(CefFrame* frame,
|
|||
WebFrame* web_frame = GetWebFrame(frame);
|
||||
if(web_frame) {
|
||||
web_frame->executeScript(
|
||||
WebScriptSource(WebString(js_code), WebURL(GURL(script_url)),
|
||||
start_line));
|
||||
WebScriptSource(StdWStringToWebString(js_code),
|
||||
WebURL(GURL(StdWStringToWebString(script_url))),
|
||||
start_line));
|
||||
}
|
||||
|
||||
frame->Release();
|
||||
|
@ -693,10 +699,13 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
|||
|
||||
// Get the right target frame for the entry.
|
||||
WebFrame* frame;
|
||||
if (!entry.GetTargetFrame().empty())
|
||||
frame = view->findFrameByName(entry.GetTargetFrame());
|
||||
else
|
||||
if (!entry.GetTargetFrame().empty()) {
|
||||
frame = view->findFrameByName(
|
||||
StdWStringToWebString(entry.GetTargetFrame()));
|
||||
} else {
|
||||
frame = view->mainFrame();
|
||||
}
|
||||
|
||||
// TODO(mpcomplete): should we clear the target frame, or should
|
||||
// back/forward navigations maintain the target frame?
|
||||
|
||||
|
@ -720,10 +729,8 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
|||
DCHECK(entry.GetPageID() == -1);
|
||||
WebURLRequest request(entry.GetURL());
|
||||
|
||||
if(entry.GetMethod().size() > 0) {
|
||||
request.setHTTPMethod(
|
||||
StdStringToWebString(WideToUTF8(entry.GetMethod())));
|
||||
}
|
||||
if(entry.GetMethod().size() > 0)
|
||||
request.setHTTPMethod(StdWStringToWebString(entry.GetMethod()));
|
||||
|
||||
if(entry.GetHeaders().size() > 0)
|
||||
CefRequestImpl::SetHeaderMap(entry.GetHeaders(), request);
|
||||
|
@ -955,8 +962,8 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
|
|||
// Just navigate back/forward.
|
||||
delegate->SelectFindResult(options.forward);
|
||||
} else {
|
||||
if (delegate->StartFind(search_text.c_str(), options.matchCase,
|
||||
identifier)) {
|
||||
if (delegate->StartFind(StdWStringToWebString(search_text),
|
||||
options.matchCase, identifier)) {
|
||||
} else {
|
||||
// No find results.
|
||||
UIT_NotifyFindStatus(identifier, 0, gfx::Rect(), 0, true);
|
||||
|
@ -983,8 +990,8 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
|
|||
WebRange current_selection = focused_frame->selectionRange();
|
||||
|
||||
do {
|
||||
result = search_frame->find(
|
||||
identifier, search_text, options, wrap_within_frame, &selection_rect);
|
||||
result = search_frame->find(identifier, StdWStringToWebString(search_text),
|
||||
options, wrap_within_frame, &selection_rect);
|
||||
|
||||
if (!result) {
|
||||
// don't leave text selected as you move to the next frame.
|
||||
|
@ -1010,7 +1017,8 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
|
|||
// match for the search word(s).
|
||||
if (multi_frame && search_frame == focused_frame) {
|
||||
result = search_frame->find(
|
||||
identifier, search_text, options, true, // Force wrapping.
|
||||
identifier, StdWStringToWebString(search_text),
|
||||
options, true, // Force wrapping.
|
||||
&selection_rect);
|
||||
}
|
||||
}
|
||||
|
@ -1051,7 +1059,7 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
|
|||
// Start new scoping request. If the scoping function determines that it
|
||||
// needs to scope, it will defer until later.
|
||||
search_frame->scopeStringMatches(identifier,
|
||||
search_text,
|
||||
StdWStringToWebString(search_text),
|
||||
options,
|
||||
true); // reset the tickmarks
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ BrowserNavigationEntry::BrowserNavigationEntry(int page_id,
|
|||
: page_id_(page_id),
|
||||
url_(url),
|
||||
title_(title),
|
||||
target_frame_(target_frame),
|
||||
method_(method),
|
||||
headers_(headers) {
|
||||
headers_(headers),
|
||||
target_frame_(target_frame) {
|
||||
if(!upload.isNull())
|
||||
upload_ = upload;
|
||||
}
|
||||
|
|
|
@ -107,9 +107,9 @@ class RequestProxy : public URLRequest::Delegate,
|
|||
public:
|
||||
// Takes ownership of the params.
|
||||
RequestProxy(CefRefPtr<CefBrowser> browser)
|
||||
: browser_(browser),
|
||||
download_to_file_(false),
|
||||
: download_to_file_(false),
|
||||
buf_(new net::IOBuffer(kDataSize)),
|
||||
browser_(browser),
|
||||
last_upload_position_(0)
|
||||
{
|
||||
}
|
||||
|
@ -814,9 +814,9 @@ namespace webkit_glue {
|
|||
// Factory function.
|
||||
ResourceLoaderBridge* ResourceLoaderBridge::Create(
|
||||
const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) {
|
||||
CefRefPtr<CefBrowser> browser =
|
||||
CefRefPtr<CefBrowserImpl> browser =
|
||||
_Context->GetBrowserByID(request_info.routing_id);
|
||||
return new ResourceLoaderBridgeImpl(browser, request_info);
|
||||
return new ResourceLoaderBridgeImpl(browser.get(), request_info);
|
||||
}
|
||||
|
||||
// Issue the proxy resolve request on the io thread, and wait
|
||||
|
|
|
@ -113,6 +113,14 @@ std::string WebStringToStdString(const WebKit::WebString& str) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
WebKit::WebString StdWStringToWebString(const std::wstring& str) {
|
||||
return StdStringToWebString(WideToUTF8(str));
|
||||
}
|
||||
|
||||
std::wstring WebStringToStdWString(const WebKit::WebString& str) {
|
||||
return UTF8ToWide(WebStringToStdString(str));
|
||||
}
|
||||
|
||||
std::string GetProductVersion() {
|
||||
return std::string("Chrome/7.0.517.0");
|
||||
}
|
||||
|
|
|
@ -43,4 +43,8 @@ WebKit::WebString StdStringToWebString(const std::string& str);
|
|||
|
||||
std::string WebStringToStdString(const WebKit::WebString& str);
|
||||
|
||||
WebKit::WebString StdWStringToWebString(const std::wstring& str);
|
||||
|
||||
std::wstring WebStringToStdWString(const WebKit::WebString& str);
|
||||
|
||||
} // namespace webkit_glue
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#include "base/string_util.h"
|
||||
#include "base/trace_event.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "gfx/gdi_util.h"
|
||||
#include "gfx/native_widget_types.h"
|
||||
#include "gfx/point.h"
|
||||
#include "media/filters/audio_renderer_impl.h"
|
||||
#include "net/base/net_errors.h"
|
||||
|
@ -296,6 +294,8 @@ bool BrowserWebViewDelegate::handleCurrentKeyboardEvent() {
|
|||
KEYEVENT_CHAR, event.windowsKeyCode,
|
||||
event.modifiers, event.isSystemKey?true:false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#if defined(OS_MACOSX) || defined(OS_WIN)
|
||||
#include "base/nss_util.h"
|
||||
#endif
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "webkit/glue/plugins/plugin_list.h"
|
||||
#include "webkit/glue/webpreferences.h"
|
||||
|
||||
|
@ -61,7 +62,11 @@ 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;
|
||||
|
|
|
@ -37,7 +37,11 @@ public:
|
|||
}
|
||||
|
||||
void DoMessageLoopIteration() {
|
||||
#if defined(OS_MACOSX)
|
||||
Run();
|
||||
#else
|
||||
Run(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "browser_socket_stream_bridge.h"
|
||||
#include "browser_webblobregistry_impl.h"
|
||||
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -34,7 +35,13 @@ void CefProcessIOThread::Init() {
|
|||
CoInitialize(NULL);
|
||||
#endif
|
||||
|
||||
request_context_ = new BrowserRequestContext(FilePath(_Context->cache_path()),
|
||||
#if defined(OS_WIN)
|
||||
FilePath cache_path(_Context->cache_path());
|
||||
#else
|
||||
FilePath cache_path(WideToUTF8(_Context->cache_path()));
|
||||
#endif
|
||||
|
||||
request_context_ = new BrowserRequestContext(cache_path,
|
||||
net::HttpCache::NORMAL, false);
|
||||
_Context->set_request_context(request_context_);
|
||||
|
||||
|
|
|
@ -3,8 +3,14 @@
|
|||
// can be found in the LICENSE file.
|
||||
|
||||
#include "include/cef_string.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#include <limits.h>
|
||||
#if defined(OS_MACOSX)
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
typedef unsigned long dword_t;
|
||||
|
|
|
@ -156,8 +156,8 @@ void CefRequestImpl::SetHeaderMap(const HeaderMap& map,
|
|||
HeaderMap::const_iterator it = map.begin();
|
||||
for(; it != map.end(); ++it) {
|
||||
request.setHTTPHeaderField(
|
||||
webkit_glue::StdStringToWebString(WideToUTF8(it->first.c_str())),
|
||||
webkit_glue::StdStringToWebString(WideToUTF8(it->second.c_str())));
|
||||
webkit_glue::StdWStringToWebString(it->first.c_str()),
|
||||
webkit_glue::StdWStringToWebString(it->second.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,7 +465,11 @@ 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();
|
||||
}
|
||||
|
@ -480,7 +484,11 @@ void CefPostDataElementImpl::Get(net::UploadData::Element& element)
|
|||
if(type_ == PDE_TYPE_BYTES) {
|
||||
element.SetToBytes(static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
|
||||
} else if(type_ == PDE_TYPE_FILE) {
|
||||
#if defined(OS_WIN)
|
||||
element.SetToFilePath(FilePath(data_.filename));
|
||||
#else
|
||||
element.SetToFilePath(FilePath(WideToUTF8(data_.filename)));
|
||||
#endif
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
@ -514,8 +522,7 @@ void CefPostDataElementImpl::Get(WebKit::WebHTTPBody::Element& element)
|
|||
static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
|
||||
} else if(type_ == PDE_TYPE_FILE) {
|
||||
element.type = WebKit::WebHTTPBody::Element::TypeFile;
|
||||
element.filePath.assign(
|
||||
webkit_glue::StdStringToWebString(WideToUTF8(data_.filename)));
|
||||
element.filePath.assign(webkit_glue::StdWStringToWebString(data_.filename));
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
|
|
@ -42,10 +42,6 @@ static void TrackAdd(CefTrackObject* object)
|
|||
g_scheme_tracker.Pointer()->Add(object);
|
||||
}
|
||||
|
||||
static void TrackDelete(CefTrackObject* object)
|
||||
{
|
||||
g_scheme_tracker.Pointer()->Delete(object);
|
||||
}
|
||||
|
||||
|
||||
// URLRequestJob implementation.
|
||||
|
@ -54,9 +50,9 @@ class CefUrlRequestJob : public URLRequestJob {
|
|||
public:
|
||||
CefUrlRequestJob(URLRequest* request, CefRefPtr<CefSchemeHandler> handler)
|
||||
: URLRequestJob(request),
|
||||
url_(request->url()),
|
||||
handler_(handler),
|
||||
response_length_(0),
|
||||
url_(request->url()),
|
||||
remaining_bytes_(0) { }
|
||||
|
||||
virtual ~CefUrlRequestJob(){}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "stream_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
|
||||
|
||||
// Static functions
|
||||
|
@ -13,7 +14,11 @@ CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile(
|
|||
const std::wstring& fileName)
|
||||
{
|
||||
CefRefPtr<CefStreamReader> reader;
|
||||
#if defined(OS_WIN)
|
||||
FILE *f = _wfopen(fileName.c_str(), L"rb");
|
||||
#else
|
||||
FILE *f = fopen(WideToUTF8(fileName).c_str(), "rb");
|
||||
#endif
|
||||
if(f)
|
||||
reader = new CefFileReader(f, true);
|
||||
return reader;
|
||||
|
@ -45,7 +50,11 @@ CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForFile(
|
|||
{
|
||||
DCHECK(!fileName.empty());
|
||||
CefRefPtr<CefStreamWriter> writer;
|
||||
#if defined(OS_WIN)
|
||||
FILE* file = _wfopen(fileName.c_str(), L"wb");
|
||||
#else
|
||||
FILE* file = fopen(WideToUTF8(fileName).c_str(), "wb");
|
||||
#endif
|
||||
if(file)
|
||||
writer = new CefFileWriter(file, true);
|
||||
return writer;
|
||||
|
@ -65,7 +74,7 @@ CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForHandler(
|
|||
// CefFileReader
|
||||
|
||||
CefFileReader::CefFileReader(FILE* file, bool close)
|
||||
: file_(file), close_(close)
|
||||
: close_(close), file_(file)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -255,7 +264,7 @@ void CefBytesReader::SetData(void* data, long datasize, bool copy)
|
|||
// CefBytesWriter
|
||||
|
||||
CefBytesWriter::CefBytesWriter(size_t grow)
|
||||
: grow_(grow), offset_(0), datasize_(grow)
|
||||
: grow_(grow), datasize_(grow), offset_(0)
|
||||
{
|
||||
DCHECK(grow > 0);
|
||||
data_ = malloc(grow);
|
||||
|
|
|
@ -17,6 +17,13 @@ template <class ClassName, class BaseName, class StructName>
|
|||
class CefCppToC : public CefThreadSafeBase<CefBase>
|
||||
{
|
||||
public:
|
||||
// Structure representation with pointer to the C++ class.
|
||||
struct Struct
|
||||
{
|
||||
StructName struct_;
|
||||
CefCppToC<ClassName,BaseName,StructName>* class_;
|
||||
};
|
||||
|
||||
// Use this method to retrieve the underlying class instance from our
|
||||
// own structure when the structure is passed as the required first
|
||||
// parameter of a C API function call. No explicit reference counting
|
||||
|
@ -24,8 +31,7 @@ public:
|
|||
static CefRefPtr<BaseName> Get(StructName* s)
|
||||
{
|
||||
// Cast our structure to the wrapper structure type.
|
||||
ClassName::Struct* wrapperStruct =
|
||||
reinterpret_cast<ClassName::Struct*>(s);
|
||||
Struct* wrapperStruct = reinterpret_cast<Struct*>(s);
|
||||
// Return the underlying object instance.
|
||||
return wrapperStruct->class_->GetClass();
|
||||
}
|
||||
|
@ -48,8 +54,7 @@ public:
|
|||
static CefRefPtr<BaseName> Unwrap(StructName* s)
|
||||
{
|
||||
// Cast our structure to the wrapper structure type.
|
||||
ClassName::Struct* wrapperStruct =
|
||||
reinterpret_cast<ClassName::Struct*>(s);
|
||||
Struct* wrapperStruct = reinterpret_cast<Struct*>(s);
|
||||
// Add the underlying object instance to a smart pointer.
|
||||
CefRefPtr<BaseName> objectPtr(wrapperStruct->class_->GetClass());
|
||||
// Release the reference to our wrapper object that was added before the
|
||||
|
@ -59,13 +64,6 @@ public:
|
|||
return objectPtr;
|
||||
}
|
||||
|
||||
// Structure representation with pointer to the C++ class.
|
||||
struct Struct
|
||||
{
|
||||
StructName struct_;
|
||||
CefCppToC<ClassName,BaseName,StructName>* class_;
|
||||
};
|
||||
|
||||
CefCppToC(BaseName* cls)
|
||||
: class_(cls)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue