mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update all files to use Windows CRLF (\r\n) line endings (issue #45).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@33 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -1,49 +1,49 @@
|
||||
// Copyright (c) 2009 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 "precompiled_libcef.h"
|
||||
#include "v8_impl.h"
|
||||
#include "context.h"
|
||||
#include "tracker.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/string_util.h"
|
||||
#include "webkit/api/public/WebKit.h"
|
||||
|
||||
|
||||
// Memory manager.
|
||||
|
||||
base::LazyInstance<CefTrackManager> g_v8_tracker(base::LINKER_INITIALIZED);
|
||||
|
||||
class TrackBase : public CefTrackObject
|
||||
{
|
||||
public:
|
||||
TrackBase(CefBase* base) { base_ = base; }
|
||||
|
||||
protected:
|
||||
CefRefPtr<CefBase> base_;
|
||||
};
|
||||
|
||||
class TrackString : public CefTrackObject
|
||||
{
|
||||
public:
|
||||
TrackString(const std::string& str) : string_(str) {}
|
||||
const char* GetString() { return string_.c_str(); }
|
||||
|
||||
private:
|
||||
std::string string_;
|
||||
};
|
||||
|
||||
|
||||
static void TrackAdd(CefTrackObject* object)
|
||||
{
|
||||
g_v8_tracker.Pointer()->Add(object);
|
||||
}
|
||||
// Copyright (c) 2009 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.
|
||||
|
||||
static void TrackDelete(CefTrackObject* object)
|
||||
{
|
||||
g_v8_tracker.Pointer()->Delete(object);
|
||||
}
|
||||
#include "precompiled_libcef.h"
|
||||
#include "v8_impl.h"
|
||||
#include "context.h"
|
||||
#include "tracker.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/string_util.h"
|
||||
#include "webkit/api/public/WebKit.h"
|
||||
|
||||
|
||||
// Memory manager.
|
||||
|
||||
base::LazyInstance<CefTrackManager> g_v8_tracker(base::LINKER_INITIALIZED);
|
||||
|
||||
class TrackBase : public CefTrackObject
|
||||
{
|
||||
public:
|
||||
TrackBase(CefBase* base) { base_ = base; }
|
||||
|
||||
protected:
|
||||
CefRefPtr<CefBase> base_;
|
||||
};
|
||||
|
||||
class TrackString : public CefTrackObject
|
||||
{
|
||||
public:
|
||||
TrackString(const std::string& str) : string_(str) {}
|
||||
const char* GetString() { return string_.c_str(); }
|
||||
|
||||
private:
|
||||
std::string string_;
|
||||
};
|
||||
|
||||
|
||||
static void TrackAdd(CefTrackObject* object)
|
||||
{
|
||||
g_v8_tracker.Pointer()->Add(object);
|
||||
}
|
||||
|
||||
static void TrackDelete(CefTrackObject* object)
|
||||
{
|
||||
g_v8_tracker.Pointer()->Delete(object);
|
||||
}
|
||||
|
||||
// Callback for weak persistent reference destruction.
|
||||
static void TrackDestructor(v8::Persistent<v8::Value> object,
|
||||
@ -51,10 +51,10 @@ static void TrackDestructor(v8::Persistent<v8::Value> object,
|
||||
{
|
||||
if(parameter)
|
||||
TrackDelete(static_cast<CefTrackObject*>(parameter));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Convert a wide string to a V8 string.
|
||||
|
||||
// Convert a wide string to a V8 string.
|
||||
static v8::Handle<v8::String> GetV8String(const std::wstring& str)
|
||||
{
|
||||
return v8::String::New(
|
||||
@ -64,84 +64,84 @@ static v8::Handle<v8::String> GetV8String(const std::wstring& str)
|
||||
// Convert a V8 string to a wide string.
|
||||
static std::wstring GetWString(v8::Handle<v8::String> str)
|
||||
{
|
||||
uint16_t* buf = new uint16_t[str->Length()+1];
|
||||
str->Write(buf);
|
||||
std::wstring value = reinterpret_cast<wchar_t*>(buf);
|
||||
uint16_t* buf = new uint16_t[str->Length()+1];
|
||||
str->Write(buf);
|
||||
std::wstring value = reinterpret_cast<wchar_t*>(buf);
|
||||
delete [] buf;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
// V8 function callback
|
||||
static v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args)
|
||||
{
|
||||
v8::HandleScope handle_scope;
|
||||
CefV8Handler* handler =
|
||||
static_cast<CefV8Handler*>(v8::External::Unwrap(args.Data()));
|
||||
|
||||
CefV8ValueList params;
|
||||
for(int i = 0; i < args.Length(); i++)
|
||||
params.push_back(new CefV8ValueImpl(args[i]));
|
||||
|
||||
std::wstring func_name =
|
||||
GetWString(v8::Handle<v8::String>::Cast(args.Callee()->GetName()));
|
||||
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(args.This());
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
std::wstring exception;
|
||||
v8::Handle<v8::Value> value = v8::Null();
|
||||
|
||||
if(handler->Execute(func_name, object, params, retval, exception)) {
|
||||
if(!exception.empty())
|
||||
value = v8::ThrowException(GetV8String(exception));
|
||||
else {
|
||||
CefV8ValueImpl* rv = static_cast<CefV8ValueImpl*>(retval.get());
|
||||
if(rv)
|
||||
value = rv->GetValue();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
// V8 extension registration.
|
||||
|
||||
class ExtensionWrapper : public v8::Extension {
|
||||
public:
|
||||
ExtensionWrapper(const char* extension_name,
|
||||
const char* javascript_code,
|
||||
CefV8Handler* handler)
|
||||
: v8::Extension(extension_name, javascript_code), handler_(handler)
|
||||
{
|
||||
// The reference will be released when the application exits.
|
||||
TrackAdd(new TrackBase(handler));
|
||||
}
|
||||
|
||||
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
|
||||
v8::Handle<v8::String> name)
|
||||
{
|
||||
return v8::FunctionTemplate::New(FunctionCallbackImpl,
|
||||
v8::External::New(handler_));
|
||||
}
|
||||
|
||||
void UIT_RegisterExtension()
|
||||
{
|
||||
WebKit::registerExtension(this);
|
||||
}
|
||||
|
||||
void AddRef() {}
|
||||
void Release() {}
|
||||
|
||||
private:
|
||||
CefV8Handler* handler_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// V8 function callback
|
||||
static v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args)
|
||||
{
|
||||
v8::HandleScope handle_scope;
|
||||
CefV8Handler* handler =
|
||||
static_cast<CefV8Handler*>(v8::External::Unwrap(args.Data()));
|
||||
|
||||
CefV8ValueList params;
|
||||
for(int i = 0; i < args.Length(); i++)
|
||||
params.push_back(new CefV8ValueImpl(args[i]));
|
||||
|
||||
std::wstring func_name =
|
||||
GetWString(v8::Handle<v8::String>::Cast(args.Callee()->GetName()));
|
||||
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(args.This());
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
std::wstring exception;
|
||||
v8::Handle<v8::Value> value = v8::Null();
|
||||
|
||||
if(handler->Execute(func_name, object, params, retval, exception)) {
|
||||
if(!exception.empty())
|
||||
value = v8::ThrowException(GetV8String(exception));
|
||||
else {
|
||||
CefV8ValueImpl* rv = static_cast<CefV8ValueImpl*>(retval.get());
|
||||
if(rv)
|
||||
value = rv->GetValue();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
// V8 extension registration.
|
||||
|
||||
class ExtensionWrapper : public v8::Extension {
|
||||
public:
|
||||
ExtensionWrapper(const char* extension_name,
|
||||
const char* javascript_code,
|
||||
CefV8Handler* handler)
|
||||
: v8::Extension(extension_name, javascript_code), handler_(handler)
|
||||
{
|
||||
// The reference will be released when the application exits.
|
||||
TrackAdd(new TrackBase(handler));
|
||||
}
|
||||
|
||||
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
|
||||
v8::Handle<v8::String> name)
|
||||
{
|
||||
return v8::FunctionTemplate::New(FunctionCallbackImpl,
|
||||
v8::External::New(handler_));
|
||||
}
|
||||
|
||||
void UIT_RegisterExtension()
|
||||
{
|
||||
WebKit::registerExtension(this);
|
||||
}
|
||||
|
||||
void AddRef() {}
|
||||
void Release() {}
|
||||
|
||||
private:
|
||||
CefV8Handler* handler_;
|
||||
};
|
||||
|
||||
bool CefRegisterExtension(const std::wstring& extension_name,
|
||||
const std::wstring& javascript_code,
|
||||
CefRefPtr<CefV8Handler> handler)
|
||||
{
|
||||
// Verify that the context is already initialized
|
||||
if(!_Context.get())
|
||||
// Verify that the context is already initialized
|
||||
if(!_Context.get())
|
||||
return false;
|
||||
|
||||
if(!handler.get())
|
||||
@ -158,7 +158,7 @@ bool CefRegisterExtension(const std::wstring& extension_name,
|
||||
PostTask(FROM_HERE, NewRunnableMethod(wrapper,
|
||||
&ExtensionWrapper::UIT_RegisterExtension));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CefV8Value
|
||||
@ -579,9 +579,9 @@ bool CefV8ValueImpl::GetKeys(std::vector<std::wstring>& keys)
|
||||
v8::Local<v8::Array> arr_keys = obj->GetPropertyNames();
|
||||
uint32_t len = arr_keys->Length();
|
||||
for(uint32_t i = 0; i < len; ++i) {
|
||||
v8::Local<v8::Value> value = arr_keys->Get(v8::Integer::New(i));
|
||||
std::wstring str = GetWString(value->ToString());
|
||||
if(!IsReservedKey(str))
|
||||
v8::Local<v8::Value> value = arr_keys->Get(v8::Integer::New(i));
|
||||
std::wstring str = GetWString(value->ToString());
|
||||
if(!IsReservedKey(str))
|
||||
keys.push_back(str);
|
||||
}
|
||||
rv = true;
|
||||
|
Reference in New Issue
Block a user