Break cef.h into multiple headers (issue #142).

- Move wrapper classes from cef_wrapper.h to wrapper/ directory.
- Move C API functions/classes from cef_capi.h to capi/ directory.
- Move global function implementations from cef_context.cc to *_impl.cc files.
- Output auto-generated file paths in cef_paths.gypi.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@442 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-12-23 17:36:30 +00:00
parent 97add0e3b7
commit ff976bc07f
398 changed files with 14181 additions and 10661 deletions

View File

@@ -3,7 +3,12 @@
// be found in the LICENSE file.
#include "browser_devtools_scheme_handler.h"
#include "include/cef.h"
#include "include/cef_browser.h"
#include "include/cef_request.h"
#include "include/cef_response.h"
#include "include/cef_scheme.h"
#include "include/cef_stream.h"
#include "include/cef_url.h"
#include "browser_webkit_glue.h"
#include <string>

View File

@@ -3,7 +3,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "include/cef.h"
#include "browser_drag_delegate_win.h"
#include "browser_impl.h"
#include "browser_webview_delegate.h"

View File

@@ -3,8 +3,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser_devtools_scheme_handler.h"
#include "browser_impl.h"
#include "browser_devtools_scheme_handler.h"
#include "browser_webkit_glue.h"
#include "browser_zoom_map.h"
#include "cef_context.h"

View File

@@ -6,7 +6,9 @@
#ifndef _BROWSER_IMPL_H
#define _BROWSER_IMPL_H
#include "include/cef.h"
#include "include/cef_browser.h"
#include "include/cef_client.h"
#include "include/cef_frame.h"
#include "webview_host.h"
#include "browser_devtools_agent.h"

View File

@@ -16,7 +16,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h"
#include "include/cef.h"
#include "include/cef_request.h"
class GURL;
class CefBrowserImpl;

View File

@@ -6,12 +6,13 @@
#ifndef _BROWSER_RESOURCE_LOADER_BRIDGE_H
#define _BROWSER_RESOURCE_LOADER_BRIDGE_H
#include "include/cef.h"
#include "include/cef_base.h"
#include "base/message_loop_proxy.h"
#include "net/url_request/url_request.h"
#include "webkit/glue/resource_loader_bridge.h"
#include <string>
class CefBrowser;
class GURL;
class BrowserResourceLoaderBridge {

View File

@@ -2,7 +2,8 @@
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "../include/cef.h"
#include "browser_settings.h"
#include "include/internal/cef_types_wrappers.h"
#include "base/utf_string_conversions.h"
#include "webkit/glue/webpreferences.h"

View File

@@ -2,8 +2,6 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef.h"
#if defined(OS_WIN)
#include <windows.h>
#endif

View File

@@ -1,25 +1,15 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2011 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 "include/cef_nplugin.h"
#include "cef_context.h"
#include "browser_devtools_scheme_handler.h"
#include "browser_impl.h"
#include "browser_webkit_glue.h"
#include "cef_context.h"
#include "cef_time_util.h"
#include "dom_storage_common.h"
#include "dom_storage_namespace.h"
#include "dom_storage_area.h"
#include "base/bind.h"
#include "base/file_util.h"
#include "base/stringprintf.h"
#include "base/string_split.h"
#include "base/synchronization/waitable_event.h"
#include "base/utf_string_conversions.h"
#include "net/base/cookie_monster.h"
#include "webkit/plugins/npapi/plugin_list.h"
#if defined(OS_MACOSX) || defined(OS_WIN)
#include "crypto/nss_util.h"
@@ -34,167 +24,6 @@ CefRefPtr<CefContext> _Context;
namespace {
void UIT_RegisterPlugin(CefPluginInfo* plugin_info)
{
REQUIRE_UIT();
webkit::WebPluginInfo info;
info.path = FilePath(CefString(&plugin_info->unique_name));
info.name = CefString(&plugin_info->display_name);
info.version = CefString(&plugin_info->version);
info.desc = CefString(&plugin_info->description);
typedef std::vector<std::string> VectorType;
VectorType mime_types, file_extensions, descriptions, file_extensions_parts;
base::SplitString(CefString(&plugin_info->mime_types), '|', &mime_types);
base::SplitString(CefString(&plugin_info->file_extensions), '|',
&file_extensions);
base::SplitString(CefString(&plugin_info->type_descriptions), '|',
&descriptions);
for (size_t i = 0; i < mime_types.size(); ++i) {
webkit::WebPluginMimeType mimeType;
mimeType.mime_type = mime_types[i];
if (file_extensions.size() > i) {
base::SplitString(file_extensions[i], ',', &file_extensions_parts);
VectorType::const_iterator it = file_extensions_parts.begin();
for(; it != file_extensions_parts.end(); ++it)
mimeType.file_extensions.push_back(*(it));
file_extensions_parts.clear();
}
if (descriptions.size() > i)
mimeType.description = UTF8ToUTF16(descriptions[i]);
info.mime_types.push_back(mimeType);
}
webkit::npapi::PluginEntryPoints entry_points;
#if !defined(OS_POSIX) || defined(OS_MACOSX)
entry_points.np_getentrypoints = plugin_info->np_getentrypoints;
#endif
entry_points.np_initialize = plugin_info->np_initialize;
entry_points.np_shutdown = plugin_info->np_shutdown;
webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(
info, entry_points, true);
delete plugin_info;
}
int GetThreadId(CefThreadId threadId)
{
switch(threadId) {
case TID_UI: return CefThread::UI;
case TID_IO: return CefThread::IO;
case TID_FILE: return CefThread::FILE;
};
NOTREACHED();
return -1;
}
// Callback class for visiting cookies.
class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
public:
VisitCookiesCallback(CefRefPtr<CefCookieVisitor> visitor)
: visitor_(visitor)
{
}
void Run(const net::CookieList& list)
{
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
int total = list.size(), count = 0;
net::CookieList::const_iterator it = list.begin();
for (; it != list.end(); ++it, ++count) {
CefCookie cookie;
const net::CookieMonster::CanonicalCookie& cc = *(it);
CefString(&cookie.name).FromString(cc.Name());
CefString(&cookie.value).FromString(cc.Value());
CefString(&cookie.domain).FromString(cc.Domain());
CefString(&cookie.path).FromString(cc.Path());
cookie.secure = cc.IsSecure();
cookie.httponly = cc.IsHttpOnly();
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
cookie.has_expires = cc.DoesExpire();
if (cookie.has_expires)
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
bool deleteCookie = false;
bool keepLooping = visitor_->Visit(cookie, count, total, deleteCookie);
if (deleteCookie) {
cookie_monster->DeleteCanonicalCookieAsync(cc,
net::CookieMonster::DeleteCookieCallback());
}
if (!keepLooping)
break;
}
}
private:
CefRefPtr<CefCookieVisitor> visitor_;
};
void IOT_VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor)
{
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(visitor));
cookie_monster->GetAllCookiesAsync(
base::Bind(&VisitCookiesCallback::Run, callback.get()));
}
void IOT_VisitUrlCookies(const GURL& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor)
{
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
net::CookieOptions options;
if (includeHttpOnly)
options.set_include_httponly();
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(visitor));
cookie_monster->GetAllCookiesForURLWithOptionsAsync(url, options,
base::Bind(&VisitCookiesCallback::Run, callback.get()));
}
void IOT_SetCookiePath(const CefString& path)
{
REQUIRE_IOT();
FilePath cookie_path;
if (!path.empty())
cookie_path = FilePath(path);
_Context->request_context()->SetCookieStoragePath(cookie_path);
}
// Used in multi-threaded message loop mode to observe shutdown of the UI
// thread.
class DestructionObserver : public MessageLoop::DestructionObserver
@@ -210,145 +39,6 @@ private:
base::WaitableEvent *event_;
};
void UIT_VisitStorage(int64 namespace_id, const CefString& origin,
const CefString& key,
CefRefPtr<CefStorageVisitor> visitor)
{
REQUIRE_UIT();
DOMStorageContext* context = _Context->storage_context();
// Allow storage to be allocated for localStorage so that on-disk data, if
// any, will be available.
bool allocation_allowed = (namespace_id == kLocalStorageNamespaceId);
DOMStorageNamespace* ns =
context->GetStorageNamespace(namespace_id, allocation_allowed);
if (!ns)
return;
typedef std::vector<DOMStorageArea*> AreaList;
AreaList areas;
if (!origin.empty()) {
// Visit only the area with the specified origin.
DOMStorageArea* area = ns->GetStorageArea(origin, allocation_allowed);
if (area)
areas.push_back(area);
} else {
// Visit all areas.
ns->GetStorageAreas(areas, true);
}
if (areas.empty())
return;
// Count the total number of matching keys.
unsigned int total = 0;
{
NullableString16 value;
AreaList::iterator it = areas.begin();
for (; it != areas.end(); ) {
DOMStorageArea* area = (*it);
if (!key.empty()) {
value = area->GetItem(key);
if (value.is_null()) {
it = areas.erase(it);
// Don't increment the iterator.
continue;
} else {
total++;
}
} else {
total += area->Length();
}
++it;
}
}
if (total == 0)
return;
DOMStorageArea* area;
bool stop = false, deleteData;
unsigned int count = 0, i, len;
NullableString16 keyVal, valueVal;
string16 keyStr, valueStr;
typedef std::vector<string16> String16List;
String16List delete_keys;
// Visit all matching pairs.
AreaList::iterator it = areas.begin();
for (; it != areas.end() && !stop; ++it) {
// Each area.
area = *(it);
if (!key.empty()) {
// Visit only the matching key.
valueVal = area->GetItem(key);
if (valueVal.is_null())
valueStr.clear();
else
valueStr = valueVal.string();
deleteData = false;
stop = !visitor->Visit(static_cast<CefStorageType>(namespace_id),
area->origin(), key, valueStr, count, total, deleteData);
if (deleteData)
area->RemoveItem(key);
count++;
} else {
// Visit all keys.
len = area->Length();
for(i = 0; i < len && !stop; ++i) {
keyVal = area->Key(i);
if (keyVal.is_null()) {
keyStr.clear();
valueStr.clear();
} else {
keyStr = keyVal.string();
valueVal = area->GetItem(keyStr);
if (valueVal.is_null())
valueStr.clear();
else
valueStr = valueVal.string();
}
deleteData = false;
stop = !visitor->Visit(static_cast<CefStorageType>(namespace_id),
area->origin(), keyStr, valueStr, count, total, deleteData);
if (deleteData)
delete_keys.push_back(keyStr);
count++;
}
// Delete the requested keys.
if (!delete_keys.empty()) {
String16List::const_iterator it = delete_keys.begin();
for (; it != delete_keys.end(); ++it)
area->RemoveItem(*it);
delete_keys.clear();
}
}
}
}
void UIT_SetStoragePath(int64 namespace_id, const CefString& path)
{
REQUIRE_UIT();
if (namespace_id != kLocalStorageNamespaceId)
return;
FilePath file_path;
if (!path.empty())
file_path = FilePath(path);
DOMStorageContext* context = _Context->storage_context();
DCHECK(context);
if (context)
context->SetLocalStoragePath(file_path);
}
} // anonymous
bool CefInitialize(const CefSettings& settings, CefRefPtr<CefApp> application)
@@ -441,410 +131,6 @@ void CefQuitMessageLoop()
_Context->process()->QuitMessageLoop();
}
bool CefRegisterPlugin(const CefPluginInfo& plugin_info)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
CefThread::PostTask(CefThread::UI, FROM_HERE,
NewRunnableFunction(UIT_RegisterPlugin, new CefPluginInfo(plugin_info)));
return true;
}
bool CefCurrentlyOn(CefThreadId threadId)
{
int id = GetThreadId(threadId);
if(id < 0)
return false;
return CefThread::CurrentlyOn(static_cast<CefThread::ID>(id));
}
class CefTaskHelper : public Task
{
public:
CefTaskHelper(CefRefPtr<CefTask> task, CefThreadId threadId)
: task_(task), thread_id_(threadId) {}
virtual void Run() { task_->Execute(thread_id_); }
private:
CefRefPtr<CefTask> task_;
CefThreadId thread_id_;
DISALLOW_COPY_AND_ASSIGN(CefTaskHelper);
};
bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task)
{
int id = GetThreadId(threadId);
if(id < 0)
return false;
return CefThread::PostTask(static_cast<CefThread::ID>(id), FROM_HERE,
new CefTaskHelper(task, threadId));
}
bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr<CefTask> task,
long delay_ms)
{
int id = GetThreadId(threadId);
if(id < 0)
return false;
return CefThread::PostDelayedTask(static_cast<CefThread::ID>(id), FROM_HERE,
new CefTaskHelper(task, threadId), delay_ms);
}
bool CefParseURL(const CefString& url,
CefURLParts& parts)
{
GURL gurl(url.ToString());
if (!gurl.is_valid())
return false;
CefString(&parts.spec).FromString(gurl.spec());
CefString(&parts.scheme).FromString(gurl.scheme());
CefString(&parts.username).FromString(gurl.username());
CefString(&parts.password).FromString(gurl.password());
CefString(&parts.host).FromString(gurl.host());
CefString(&parts.port).FromString(gurl.port());
CefString(&parts.path).FromString(gurl.path());
CefString(&parts.query).FromString(gurl.query());
return true;
}
bool CefCreateURL(const CefURLParts& parts,
CefString& url)
{
std::string spec = CefString(parts.spec.str, parts.spec.length, false);
std::string scheme = CefString(parts.scheme.str, parts.scheme.length, false);
std::string username =
CefString(parts.username.str, parts.username.length, false);
std::string password =
CefString(parts.password.str, parts.password.length, false);
std::string host = CefString(parts.host.str, parts.host.length, false);
std::string port = CefString(parts.port.str, parts.port.length, false);
std::string path = CefString(parts.path.str, parts.path.length, false);
std::string query = CefString(parts.query.str, parts.query.length, false);
GURL gurl;
if (!spec.empty()) {
gurl = GURL(spec);
} else if (!scheme.empty() && !host.empty()) {
std::stringstream ss;
ss << scheme << "://";
if (!username.empty()) {
ss << username;
if (!password.empty())
ss << ":" << password;
ss << "@";
}
ss << host;
if (!port.empty())
ss << ":" << port;
if (!path.empty())
ss << path;
if (!query.empty())
ss << "?" << query;
gurl = GURL(ss.str());
}
if (gurl.is_valid()) {
url = gurl.spec();
return true;
}
return false;
}
bool CefVisitAllCookies(CefRefPtr<CefCookieVisitor> visitor)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
return CefThread::PostTask(CefThread::IO, FROM_HERE,
NewRunnableFunction(IOT_VisitAllCookies, visitor));
}
bool CefVisitUrlCookies(const CefString& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
return CefThread::PostTask(CefThread::IO, FROM_HERE,
NewRunnableFunction(IOT_VisitUrlCookies, gurl, includeHttpOnly, visitor));
}
bool CefSetCookie(const CefString& url, const CefCookie& cookie)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the IO thread.
if (!CefThread::CurrentlyOn(CefThread::IO)) {
NOTREACHED() << "called on invalid thread";
return false;
}
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return false;
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
std::string name = CefString(&cookie.name).ToString();
std::string value = CefString(&cookie.value).ToString();
std::string domain = CefString(&cookie.domain).ToString();
std::string path = CefString(&cookie.path).ToString();
base::Time expiration_time;
if (cookie.has_expires)
cef_time_to_basetime(cookie.expires, expiration_time);
cookie_monster->SetCookieWithDetailsAsync(gurl, name, value, domain, path,
expiration_time, cookie.secure, cookie.httponly,
net::CookieStore::SetCookiesCallback());
return true;
}
bool CefDeleteCookies(const CefString& url, const CefString& cookie_name)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the IO thread.
if (!CefThread::CurrentlyOn(CefThread::IO)) {
NOTREACHED() << "called on invalid thread";
return false;
}
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return false;
if (url.empty()) {
// Delete all cookies.
cookie_monster->DeleteAllAsync(net::CookieMonster::DeleteCallback());
return true;
}
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
if (cookie_name.empty()) {
// Delete all matching host cookies.
cookie_monster->DeleteAllForHostAsync(gurl,
net::CookieMonster::DeleteCallback());
} else {
// Delete all matching host and domain cookies.
cookie_monster->DeleteCookieAsync(gurl, cookie_name, base::Closure());
}
return true;
}
bool CefSetCookiePath(const CefString& path)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
if (CefThread::CurrentlyOn(CefThread::IO)) {
IOT_SetCookiePath(path);
} else {
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(&IOT_SetCookiePath, path));
}
return true;
}
bool CefVisitStorage(CefStorageType type, const CefString& origin,
const CefString& key,
CefRefPtr<CefStorageVisitor> visitor)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
int64 namespace_id;
if (type == ST_LOCALSTORAGE) {
namespace_id = kLocalStorageNamespaceId;
} else if(type == ST_SESSIONSTORAGE) {
namespace_id = kLocalStorageNamespaceId + 1;
} else {
NOTREACHED() << "invalid type";
return false;
}
if (CefThread::CurrentlyOn(CefThread::UI)) {
UIT_VisitStorage(namespace_id, origin, key, visitor);
} else {
CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&UIT_VisitStorage, namespace_id, origin, key, visitor));
}
return true;
}
bool CefSetStorage(CefStorageType type, const CefString& origin,
const CefString& key, const CefString& value)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the UI thread.
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";
return false;
}
int64 namespace_id;
if (type == ST_LOCALSTORAGE) {
namespace_id = kLocalStorageNamespaceId;
} else if(type == ST_SESSIONSTORAGE) {
namespace_id = kLocalStorageNamespaceId + 1;
} else {
NOTREACHED() << "invalid type";
return false;
}
if (origin.empty()) {
NOTREACHED() << "invalid origin";
return false;
}
DOMStorageArea* area =
_Context->storage_context()->GetStorageArea(namespace_id, origin, true);
if (!area)
return false;
WebKit::WebStorageArea::Result result;
area->SetItem(key, value, &result);
return (result == WebKit::WebStorageArea::ResultOK);
}
bool CefDeleteStorage(CefStorageType type, const CefString& origin,
const CefString& key)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the UI thread.
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";
return false;
}
int64 namespace_id;
if (type == ST_LOCALSTORAGE) {
namespace_id = kLocalStorageNamespaceId;
} else if(type == ST_SESSIONSTORAGE) {
namespace_id = kLocalStorageNamespaceId + 1;
} else {
NOTREACHED() << "invalid type";
return false;
}
DOMStorageContext* context = _Context->storage_context();
// Allow storage to be allocated for localStorage so that on-disk data, if
// any, will be available.
bool allocation_allowed = (namespace_id == kLocalStorageNamespaceId);
if (origin.empty()) {
// Delete all storage for the namespace.
if (namespace_id == kLocalStorageNamespaceId)
context->DeleteAllLocalStorageFiles();
else
context->PurgeMemory(namespace_id);
} else if(key.empty()) {
// Clear the storage area for the specified origin.
if (namespace_id == kLocalStorageNamespaceId) {
context->DeleteLocalStorageForOrigin(origin);
} else {
DOMStorageArea* area =
context->GetStorageArea(namespace_id, origin, allocation_allowed);
if (area) {
// Calling Clear() is necessary to remove the data from the namespace.
area->Clear();
area->PurgeMemory();
}
}
} else {
// Delete the specified key.
DOMStorageArea* area =
context->GetStorageArea(namespace_id, origin, allocation_allowed);
if (area)
area->RemoveItem(key);
}
return true;
}
bool CefSetStoragePath(CefStorageType type, const CefString& path)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
int64 namespace_id;
if (type == ST_LOCALSTORAGE) {
namespace_id = kLocalStorageNamespaceId;
} else {
NOTREACHED() << "invalid type";
return false;
}
if (CefThread::CurrentlyOn(CefThread::UI)) {
UIT_SetStoragePath(namespace_id, path);
} else {
CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&UIT_SetStoragePath, namespace_id, path));
}
return true;
}
// CefContext

View File

@@ -5,7 +5,8 @@
#ifndef _CEF_CONTEXT_H
#define _CEF_CONTEXT_H
#include "include/cef.h"
#include "include/cef_app.h"
#include "include/cef_base.h"
#include "browser_file_system.h"
#include "browser_request_context.h"
#include "cef_process.h"

View File

@@ -5,7 +5,6 @@
#import <AppKit/AppKit.h>
#include "include/cef.h"
#import "include/cef_application_mac.h"
#include "cef_process_ui_thread.h"
#include "browser_webkit_glue.h"

View File

@@ -2,7 +2,7 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef.h"
#include "include/cef_command_line.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/logging.h"

241
libcef/cookie_impl.cc Normal file
View File

@@ -0,0 +1,241 @@
// Copyright (c) 2011 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 "include/cef_cookie.h"
#include "cef_context.h"
#include "cef_thread.h"
#include "cef_time_util.h"
#include "net/base/cookie_monster.h"
namespace {
// Callback class for visiting cookies.
class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
public:
VisitCookiesCallback(CefRefPtr<CefCookieVisitor> visitor)
: visitor_(visitor)
{
}
void Run(const net::CookieList& list)
{
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
int total = list.size(), count = 0;
net::CookieList::const_iterator it = list.begin();
for (; it != list.end(); ++it, ++count) {
CefCookie cookie;
const net::CookieMonster::CanonicalCookie& cc = *(it);
CefString(&cookie.name).FromString(cc.Name());
CefString(&cookie.value).FromString(cc.Value());
CefString(&cookie.domain).FromString(cc.Domain());
CefString(&cookie.path).FromString(cc.Path());
cookie.secure = cc.IsSecure();
cookie.httponly = cc.IsHttpOnly();
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
cookie.has_expires = cc.DoesExpire();
if (cookie.has_expires)
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
bool deleteCookie = false;
bool keepLooping = visitor_->Visit(cookie, count, total, deleteCookie);
if (deleteCookie) {
cookie_monster->DeleteCanonicalCookieAsync(cc,
net::CookieMonster::DeleteCookieCallback());
}
if (!keepLooping)
break;
}
}
private:
CefRefPtr<CefCookieVisitor> visitor_;
};
void IOT_VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor)
{
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(visitor));
cookie_monster->GetAllCookiesAsync(
base::Bind(&VisitCookiesCallback::Run, callback.get()));
}
void IOT_VisitUrlCookies(const GURL& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor)
{
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
net::CookieOptions options;
if (includeHttpOnly)
options.set_include_httponly();
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(visitor));
cookie_monster->GetAllCookiesForURLWithOptionsAsync(url, options,
base::Bind(&VisitCookiesCallback::Run, callback.get()));
}
void IOT_SetCookiePath(const CefString& path)
{
REQUIRE_IOT();
FilePath cookie_path;
if (!path.empty())
cookie_path = FilePath(path);
_Context->request_context()->SetCookieStoragePath(cookie_path);
}
} // anonymous
bool CefVisitAllCookies(CefRefPtr<CefCookieVisitor> visitor)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
return CefThread::PostTask(CefThread::IO, FROM_HERE,
NewRunnableFunction(IOT_VisitAllCookies, visitor));
}
bool CefVisitUrlCookies(const CefString& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
return CefThread::PostTask(CefThread::IO, FROM_HERE,
NewRunnableFunction(IOT_VisitUrlCookies, gurl, includeHttpOnly, visitor));
}
bool CefSetCookie(const CefString& url, const CefCookie& cookie)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the IO thread.
if (!CefThread::CurrentlyOn(CefThread::IO)) {
NOTREACHED() << "called on invalid thread";
return false;
}
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return false;
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
std::string name = CefString(&cookie.name).ToString();
std::string value = CefString(&cookie.value).ToString();
std::string domain = CefString(&cookie.domain).ToString();
std::string path = CefString(&cookie.path).ToString();
base::Time expiration_time;
if (cookie.has_expires)
cef_time_to_basetime(cookie.expires, expiration_time);
cookie_monster->SetCookieWithDetailsAsync(gurl, name, value, domain, path,
expiration_time, cookie.secure, cookie.httponly,
net::CookieStore::SetCookiesCallback());
return true;
}
bool CefDeleteCookies(const CefString& url, const CefString& cookie_name)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the IO thread.
if (!CefThread::CurrentlyOn(CefThread::IO)) {
NOTREACHED() << "called on invalid thread";
return false;
}
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return false;
if (url.empty()) {
// Delete all cookies.
cookie_monster->DeleteAllAsync(net::CookieMonster::DeleteCallback());
return true;
}
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
if (cookie_name.empty()) {
// Delete all matching host cookies.
cookie_monster->DeleteAllForHostAsync(gurl,
net::CookieMonster::DeleteCallback());
} else {
// Delete all matching host and domain cookies.
cookie_monster->DeleteCookieAsync(gurl, cookie_name, base::Closure());
}
return true;
}
bool CefSetCookiePath(const CefString& path)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
if (CefThread::CurrentlyOn(CefThread::IO)) {
IOT_SetCookiePath(path);
} else {
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(&IOT_SetCookiePath, path));
}
return true;
}

View File

@@ -5,7 +5,7 @@
#ifndef _DOM_DOCUMENT_IMPL_H
#define _DOM_DOCUMENT_IMPL_H
#include "include/cef.h"
#include "include/cef_dom.h"
#include <map>
namespace WebKit {

View File

@@ -5,7 +5,7 @@
#ifndef _DOM_EVENT_IMPL_H
#define _DOM_EVENT_IMPL_H
#include "include/cef.h"
#include "include/cef_dom.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"
class CefDOMDocumentImpl;

View File

@@ -5,7 +5,7 @@
#ifndef _DOM_NODE_IMPL_H
#define _DOM_NODE_IMPL_H
#include "include/cef.h"
#include "include/cef_dom.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
class CefDOMDocumentImpl;

View File

@@ -5,7 +5,7 @@
#ifndef _DRAG_DATA_IMPL_H
#define _DRAG_DATA_IMPL_H
#include "../include/cef.h"
#include "include/cef_drag_data.h"
#include "webkit/glue/webdropdata.h"
// Implementation of CefDragData.

View File

@@ -2,7 +2,6 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef.h"
#include "http_header_utils.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"

View File

@@ -5,6 +5,7 @@
#ifndef _HTTP_HEADER_UTILS_H
#define _HTTP_HEADER_UTILS_H
#include "include/cef_request.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeaderVisitor.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"

80
libcef/nplugin_impl.cc Normal file
View File

@@ -0,0 +1,80 @@
// Copyright (c) 2011 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 "include/cef_nplugin.h"
#include "cef_context.h"
#include "cef_thread.h"
#include "base/string_split.h"
#include "base/utf_string_conversions.h"
#include "webkit/plugins/npapi/plugin_list.h"
namespace {
void UIT_RegisterPlugin(CefPluginInfo* plugin_info)
{
REQUIRE_UIT();
webkit::WebPluginInfo info;
info.path = FilePath(CefString(&plugin_info->unique_name));
info.name = CefString(&plugin_info->display_name);
info.version = CefString(&plugin_info->version);
info.desc = CefString(&plugin_info->description);
typedef std::vector<std::string> VectorType;
VectorType mime_types, file_extensions, descriptions, file_extensions_parts;
base::SplitString(CefString(&plugin_info->mime_types), '|', &mime_types);
base::SplitString(CefString(&plugin_info->file_extensions), '|',
&file_extensions);
base::SplitString(CefString(&plugin_info->type_descriptions), '|',
&descriptions);
for (size_t i = 0; i < mime_types.size(); ++i) {
webkit::WebPluginMimeType mimeType;
mimeType.mime_type = mime_types[i];
if (file_extensions.size() > i) {
base::SplitString(file_extensions[i], ',', &file_extensions_parts);
VectorType::const_iterator it = file_extensions_parts.begin();
for(; it != file_extensions_parts.end(); ++it)
mimeType.file_extensions.push_back(*(it));
file_extensions_parts.clear();
}
if (descriptions.size() > i)
mimeType.description = UTF8ToUTF16(descriptions[i]);
info.mime_types.push_back(mimeType);
}
webkit::npapi::PluginEntryPoints entry_points;
#if !defined(OS_POSIX) || defined(OS_MACOSX)
entry_points.np_getentrypoints = plugin_info->np_getentrypoints;
#endif
entry_points.np_initialize = plugin_info->np_initialize;
entry_points.np_shutdown = plugin_info->np_shutdown;
webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(
info, entry_points, true);
delete plugin_info;
}
} // anonymous
bool CefRegisterPlugin(const CefPluginInfo& plugin_info)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
CefThread::PostTask(CefThread::UI, FROM_HERE,
NewRunnableFunction(UIT_RegisterPlugin, new CefPluginInfo(plugin_info)));
return true;
}

View File

@@ -2,7 +2,7 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef.h"
#include "include/cef_origin_whitelist.h"
#include "cef_context.h"
#include "cef_thread.h"

View File

@@ -5,7 +5,7 @@
#ifndef _REQUEST_IMPL_H
#define _REQUEST_IMPL_H
#include "include/cef.h"
#include "include/cef_request.h"
#include "net/base/upload_data.h"
#include "net/http/http_request_headers.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h"

View File

@@ -2,7 +2,6 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef.h"
#include "response_impl.h"
#include "http_header_utils.h"

View File

@@ -5,7 +5,7 @@
#ifndef _RESPONSE_IMPL_H
#define _RESPONSE_IMPL_H
#include "include/cef.h"
#include "include/cef_response.h"
namespace net {
class HttpResponseHeaders;

View File

@@ -3,7 +3,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "include/cef.h"
#include "include/cef_browser.h"
#include "include/cef_scheme.h"
#include "browser_devtools_scheme_handler.h"
#include "browser_resource_loader_bridge.h"
#include "cef_context.h"

310
libcef/storage_impl.cc Normal file
View File

@@ -0,0 +1,310 @@
// Copyright (c) 2011 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 "include/cef_storage.h"
#include "cef_context.h"
#include "cef_thread.h"
#include "dom_storage_common.h"
#include "dom_storage_namespace.h"
#include "dom_storage_area.h"
namespace {
void UIT_VisitStorage(int64 namespace_id, const CefString& origin,
const CefString& key,
CefRefPtr<CefStorageVisitor> visitor)
{
REQUIRE_UIT();
DOMStorageContext* context = _Context->storage_context();
// Allow storage to be allocated for localStorage so that on-disk data, if
// any, will be available.
bool allocation_allowed = (namespace_id == kLocalStorageNamespaceId);
DOMStorageNamespace* ns =
context->GetStorageNamespace(namespace_id, allocation_allowed);
if (!ns)
return;
typedef std::vector<DOMStorageArea*> AreaList;
AreaList areas;
if (!origin.empty()) {
// Visit only the area with the specified origin.
DOMStorageArea* area = ns->GetStorageArea(origin, allocation_allowed);
if (area)
areas.push_back(area);
} else {
// Visit all areas.
ns->GetStorageAreas(areas, true);
}
if (areas.empty())
return;
// Count the total number of matching keys.
unsigned int total = 0;
{
NullableString16 value;
AreaList::iterator it = areas.begin();
for (; it != areas.end(); ) {
DOMStorageArea* area = (*it);
if (!key.empty()) {
value = area->GetItem(key);
if (value.is_null()) {
it = areas.erase(it);
// Don't increment the iterator.
continue;
} else {
total++;
}
} else {
total += area->Length();
}
++it;
}
}
if (total == 0)
return;
DOMStorageArea* area;
bool stop = false, deleteData;
unsigned int count = 0, i, len;
NullableString16 keyVal, valueVal;
string16 keyStr, valueStr;
typedef std::vector<string16> String16List;
String16List delete_keys;
// Visit all matching pairs.
AreaList::iterator it = areas.begin();
for (; it != areas.end() && !stop; ++it) {
// Each area.
area = *(it);
if (!key.empty()) {
// Visit only the matching key.
valueVal = area->GetItem(key);
if (valueVal.is_null())
valueStr.clear();
else
valueStr = valueVal.string();
deleteData = false;
stop = !visitor->Visit(static_cast<CefStorageType>(namespace_id),
area->origin(), key, valueStr, count, total, deleteData);
if (deleteData)
area->RemoveItem(key);
count++;
} else {
// Visit all keys.
len = area->Length();
for(i = 0; i < len && !stop; ++i) {
keyVal = area->Key(i);
if (keyVal.is_null()) {
keyStr.clear();
valueStr.clear();
} else {
keyStr = keyVal.string();
valueVal = area->GetItem(keyStr);
if (valueVal.is_null())
valueStr.clear();
else
valueStr = valueVal.string();
}
deleteData = false;
stop = !visitor->Visit(static_cast<CefStorageType>(namespace_id),
area->origin(), keyStr, valueStr, count, total, deleteData);
if (deleteData)
delete_keys.push_back(keyStr);
count++;
}
// Delete the requested keys.
if (!delete_keys.empty()) {
String16List::const_iterator it = delete_keys.begin();
for (; it != delete_keys.end(); ++it)
area->RemoveItem(*it);
delete_keys.clear();
}
}
}
}
void UIT_SetStoragePath(int64 namespace_id, const CefString& path)
{
REQUIRE_UIT();
if (namespace_id != kLocalStorageNamespaceId)
return;
FilePath file_path;
if (!path.empty())
file_path = FilePath(path);
DOMStorageContext* context = _Context->storage_context();
DCHECK(context);
if (context)
context->SetLocalStoragePath(file_path);
}
} // anonymous
bool CefVisitStorage(CefStorageType type, const CefString& origin,
const CefString& key,
CefRefPtr<CefStorageVisitor> visitor)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
int64 namespace_id;
if (type == ST_LOCALSTORAGE) {
namespace_id = kLocalStorageNamespaceId;
} else if(type == ST_SESSIONSTORAGE) {
namespace_id = kLocalStorageNamespaceId + 1;
} else {
NOTREACHED() << "invalid type";
return false;
}
if (CefThread::CurrentlyOn(CefThread::UI)) {
UIT_VisitStorage(namespace_id, origin, key, visitor);
} else {
CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&UIT_VisitStorage, namespace_id, origin, key, visitor));
}
return true;
}
bool CefSetStorage(CefStorageType type, const CefString& origin,
const CefString& key, const CefString& value)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the UI thread.
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";
return false;
}
int64 namespace_id;
if (type == ST_LOCALSTORAGE) {
namespace_id = kLocalStorageNamespaceId;
} else if(type == ST_SESSIONSTORAGE) {
namespace_id = kLocalStorageNamespaceId + 1;
} else {
NOTREACHED() << "invalid type";
return false;
}
if (origin.empty()) {
NOTREACHED() << "invalid origin";
return false;
}
DOMStorageArea* area =
_Context->storage_context()->GetStorageArea(namespace_id, origin, true);
if (!area)
return false;
WebKit::WebStorageArea::Result result;
area->SetItem(key, value, &result);
return (result == WebKit::WebStorageArea::ResultOK);
}
bool CefDeleteStorage(CefStorageType type, const CefString& origin,
const CefString& key)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the UI thread.
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";
return false;
}
int64 namespace_id;
if (type == ST_LOCALSTORAGE) {
namespace_id = kLocalStorageNamespaceId;
} else if(type == ST_SESSIONSTORAGE) {
namespace_id = kLocalStorageNamespaceId + 1;
} else {
NOTREACHED() << "invalid type";
return false;
}
DOMStorageContext* context = _Context->storage_context();
// Allow storage to be allocated for localStorage so that on-disk data, if
// any, will be available.
bool allocation_allowed = (namespace_id == kLocalStorageNamespaceId);
if (origin.empty()) {
// Delete all storage for the namespace.
if (namespace_id == kLocalStorageNamespaceId)
context->DeleteAllLocalStorageFiles();
else
context->PurgeMemory(namespace_id);
} else if(key.empty()) {
// Clear the storage area for the specified origin.
if (namespace_id == kLocalStorageNamespaceId) {
context->DeleteLocalStorageForOrigin(origin);
} else {
DOMStorageArea* area =
context->GetStorageArea(namespace_id, origin, allocation_allowed);
if (area) {
// Calling Clear() is necessary to remove the data from the namespace.
area->Clear();
area->PurgeMemory();
}
}
} else {
// Delete the specified key.
DOMStorageArea* area =
context->GetStorageArea(namespace_id, origin, allocation_allowed);
if (area)
area->RemoveItem(key);
}
return true;
}
bool CefSetStoragePath(CefStorageType type, const CefString& path)
{
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
int64 namespace_id;
if (type == ST_LOCALSTORAGE) {
namespace_id = kLocalStorageNamespaceId;
} else {
NOTREACHED() << "invalid type";
return false;
}
if (CefThread::CurrentlyOn(CefThread::UI)) {
UIT_SetStoragePath(namespace_id, path);
} else {
CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&UIT_SetStoragePath, namespace_id, path));
}
return true;
}

View File

@@ -5,7 +5,7 @@
#ifndef _STREAM_IMPL_H
#define _STREAM_IMPL_H
#include "../include/cef.h"
#include "include/cef_stream.h"
#include <stdio.h>
// Implementation of CefStreamReader for files.

63
libcef/task_impl.cc Normal file
View File

@@ -0,0 +1,63 @@
// Copyright (c) 2011 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 "include/cef_task.h"
#include "cef_thread.h"
namespace {
int GetThreadId(CefThreadId threadId)
{
switch(threadId) {
case TID_UI: return CefThread::UI;
case TID_IO: return CefThread::IO;
case TID_FILE: return CefThread::FILE;
};
NOTREACHED();
return -1;
}
} // anonymous
bool CefCurrentlyOn(CefThreadId threadId)
{
int id = GetThreadId(threadId);
if(id < 0)
return false;
return CefThread::CurrentlyOn(static_cast<CefThread::ID>(id));
}
class CefTaskHelper : public Task
{
public:
CefTaskHelper(CefRefPtr<CefTask> task, CefThreadId threadId)
: task_(task), thread_id_(threadId) {}
virtual void Run() { task_->Execute(thread_id_); }
private:
CefRefPtr<CefTask> task_;
CefThreadId thread_id_;
DISALLOW_COPY_AND_ASSIGN(CefTaskHelper);
};
bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task)
{
int id = GetThreadId(threadId);
if(id < 0)
return false;
return CefThread::PostTask(static_cast<CefThread::ID>(id), FROM_HERE,
new CefTaskHelper(task, threadId));
}
bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr<CefTask> task,
long delay_ms)
{
int id = GetThreadId(threadId);
if(id < 0)
return false;
return CefThread::PostDelayedTask(static_cast<CefThread::ID>(id), FROM_HERE,
new CefTaskHelper(task, threadId), delay_ms);
}

View File

@@ -5,7 +5,7 @@
#ifndef _TRACKER_H
#define _TRACKER_H
#include "include/cef.h"
#include "include/cef_base.h"
// Class extended by objects that must be tracked. After creating a tracked
// object you should add it to the appropriate track manager.

71
libcef/url_impl.cc Normal file
View File

@@ -0,0 +1,71 @@
// Copyright (c) 2011 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 "include/cef_url.h"
#include "googleurl/src/gurl.h"
#include <sstream>
bool CefParseURL(const CefString& url,
CefURLParts& parts)
{
GURL gurl(url.ToString());
if (!gurl.is_valid())
return false;
CefString(&parts.spec).FromString(gurl.spec());
CefString(&parts.scheme).FromString(gurl.scheme());
CefString(&parts.username).FromString(gurl.username());
CefString(&parts.password).FromString(gurl.password());
CefString(&parts.host).FromString(gurl.host());
CefString(&parts.port).FromString(gurl.port());
CefString(&parts.path).FromString(gurl.path());
CefString(&parts.query).FromString(gurl.query());
return true;
}
bool CefCreateURL(const CefURLParts& parts,
CefString& url)
{
std::string spec = CefString(parts.spec.str, parts.spec.length, false);
std::string scheme = CefString(parts.scheme.str, parts.scheme.length, false);
std::string username =
CefString(parts.username.str, parts.username.length, false);
std::string password =
CefString(parts.password.str, parts.password.length, false);
std::string host = CefString(parts.host.str, parts.host.length, false);
std::string port = CefString(parts.port.str, parts.port.length, false);
std::string path = CefString(parts.path.str, parts.path.length, false);
std::string query = CefString(parts.query.str, parts.query.length, false);
GURL gurl;
if (!spec.empty()) {
gurl = GURL(spec);
} else if (!scheme.empty() && !host.empty()) {
std::stringstream ss;
ss << scheme << "://";
if (!username.empty()) {
ss << username;
if (!password.empty())
ss << ":" << password;
ss << "@";
}
ss << host;
if (!port.empty())
ss << ":" << port;
if (!path.empty())
ss << path;
if (!query.empty())
ss << "?" << query;
gurl = GURL(ss.str());
}
if (gurl.is_valid()) {
url = gurl.spec();
return true;
}
return false;
}

View File

@@ -5,7 +5,7 @@
#ifndef _V8_IMPL_H
#define _V8_IMPL_H
#include "include/cef.h"
#include "include/cef_v8.h"
#include "v8/include/v8.h"
class CefTrackObject;

View File

@@ -2,7 +2,6 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef.h"
#include "web_urlrequest_impl.h"
#include "browser_webkit_init.h"
#include "cef_thread.h"

View File

@@ -5,7 +5,7 @@
#ifndef _WEB_URL_REQUEST_CLIENT_IMPL_H
#define _WEB_URL_REQUEST_CLIENT_IMPL_H
#include "include/cef.h"
#include "include/cef_web_urlrequest.h"
#include "base/memory/ref_counted.h"
class CefWebURLRequestImpl : public CefWebURLRequest

View File

@@ -3,6 +3,7 @@
// can be found in the LICENSE file.
#include "xml_reader_impl.h"
#include "include/cef_stream.h"
#include "base/logging.h"
// Static functions

View File

@@ -5,7 +5,7 @@
#ifndef _XML_READER_IMPL_H
#define _XML_READER_IMPL_H
#include "../include/cef.h"
#include "include/cef_xml_reader.h"
#include "base/threading/platform_thread.h"
#include <libxml/xmlreader.h>
#include <sstream>

View File

@@ -3,6 +3,7 @@
// can be found in the LICENSE file.
#include "zip_reader_impl.h"
#include "include/cef_stream.h"
#include "base/logging.h"
#include <time.h>

View File

@@ -5,7 +5,7 @@
#ifndef _ZIP_READER_IMPL_H
#define _ZIP_READER_IMPL_H
#include "../include/cef.h"
#include "include/cef_zip_reader.h"
#include "base/threading/platform_thread.h"
#include "third_party/zlib/contrib/minizip/unzip.h"
#include <sstream>