libcef: Update due to underlying chromium changes.

- WebKit API changes.
- Add WebSocketStreamHandleBridge implementation.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@60 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2009-10-21 23:27:29 +00:00
parent faabcb28c5
commit 5186e4a223
20 changed files with 336 additions and 27 deletions

View File

@ -43,3 +43,4 @@ Date | CEF Revision | Chromium Revision
2009-10-02 | /trunk@51 | /trunk@27900
2009-10-12 | /trunk@53 | /trunk@28713
2009-10-18 | /trunk@58 | /trunk@29378
2009-10-21 | /trunk@60 | /trunk@29687

View File

@ -344,6 +344,8 @@
'libcef/browser_request_context.h',
'libcef/browser_resource_loader_bridge.cc',
'libcef/browser_resource_loader_bridge.h',
'libcef/browser_socket_stream_bridge.cc',
'libcef/browser_socket_stream_bridge.h',
'libcef/browser_webkit_glue.cc',
'libcef/browser_webkit_glue.h',
'libcef/browser_webkit_glue_win.cc',

View File

@ -6,10 +6,10 @@
#include "browser_drag_delegate.h"
#include "webkit/api/public/WebPoint.h"
#include "webkit/glue/webview.h"
#include "webkit/api/public/WebView.h"
using WebKit::WebPoint;
using WebKit::WebView;
namespace {

View File

@ -10,11 +10,13 @@
#include "base/base_drag_source.h"
namespace WebKit {
class WebView;
}
class BrowserDragDelegate : public BaseDragSource {
public:
BrowserDragDelegate(HWND source_hwnd, WebView* webview)
BrowserDragDelegate(HWND source_hwnd, WebKit::WebView* webview)
: BaseDragSource(),
source_hwnd_(source_hwnd),
webview_(webview) { }
@ -26,7 +28,7 @@ class BrowserDragDelegate : public BaseDragSource {
virtual void OnDragSourceMove();
private:
WebView* webview_;
WebKit::WebView* webview_;
// A HWND for the source we are associated with, used for translating
// mouse coordinates from screen to client coordinates.

View File

@ -7,12 +7,13 @@
#include "webkit/api/public/WebDragData.h"
#include "webkit/api/public/WebPoint.h"
#include "webkit/api/public/WebView.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webview.h"
using WebKit::WebDragOperation;
using WebKit::WebDragOperationCopy;
using WebKit::WebPoint;
using WebKit::WebView;
// BaseDropTarget methods ----------------------------------------------------

View File

@ -10,11 +10,13 @@
#include "base/base_drop_target.h"
namespace WebKit {
class WebView;
}
class BrowserDropDelegate : public BaseDropTarget {
public:
BrowserDropDelegate(HWND source_hwnd, WebView* webview)
BrowserDropDelegate(HWND source_hwnd, WebKit::WebView* webview)
: BaseDropTarget(source_hwnd),
webview_(webview) { }
@ -36,7 +38,7 @@ class BrowserDropDelegate : public BaseDropTarget {
private:
WebView* webview_;
WebKit::WebView* webview_;
};
#endif // _BROWSER_DROP_DELEGATE_H

View File

@ -14,6 +14,7 @@
#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebURLRequest.h"
#include "webkit/api/public/WebView.h"
#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/glue_util.h"
@ -23,6 +24,7 @@ using WebKit::WebScriptSource;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebURLRequest;
using WebKit::WebView;
using webkit_glue::StdStringToWebString;
using webkit_glue::WebStringToStdString;
@ -673,3 +675,12 @@ void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId,
if(frame)
frame->Release();
}
// CefFrameImpl
bool CefFrameImpl::IsFocused()
{
return (browser_->GetWebFrame(this) ==
browser_->GetWebView()->focusedFrame());
}

View File

@ -16,7 +16,9 @@
#include "printing/win_printing_context.h"
#endif
#include "webkit/glue/webview.h"
namespace WebKit {
class WebView;
}
#define BUFFER_SIZE 32768
@ -91,7 +93,7 @@ public:
int startLine);
virtual std::wstring GetURL(CefRefPtr<CefFrame> frame);
WebView* GetWebView() const {
WebKit::WebView* GetWebView() const {
return webviewhost_.get() ? webviewhost_->webview() : NULL;
}
WebViewHost* GetWebViewHost() const {
@ -272,9 +274,7 @@ public:
int startLine)
{ return browser_->ExecuteJavaScript(this, jsCode, scriptUrl, startLine); }
virtual bool IsMain() { return name_.empty(); }
virtual bool IsFocused()
{ return (browser_->GetWebFrame(this) ==
browser_->GetWebView()->focusedFrame()); }
virtual bool IsFocused();
virtual std::wstring GetName() { return name_; }
virtual std::wstring GetURL() { return browser_->GetURL(this); }

View File

@ -15,6 +15,7 @@
#include "webkit/api/public/WebFrame.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebSize.h"
#include "webkit/api/public/WebView.h"
#include "webkit/glue/webkit_glue.h"
#include <shellapi.h>

View File

@ -34,6 +34,7 @@
#include "browser_appcache_system.h"
#include "browser_resource_loader_bridge.h"
#include "browser_request_context.h"
#include "browser_socket_stream_bridge.h"
#include "browser_impl.h"
#include "request_impl.h"
@ -55,9 +56,9 @@
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request.h"
#include "webkit/api/public/WebFrame.h"
#include "webkit/api/public/WebView.h"
#include "webkit/appcache/appcache_interfaces.h"
#include "webkit/glue/resource_loader_bridge.h"
#include "webkit/glue/webview.h"
using webkit_glue::ResourceLoaderBridge;
using net::CookiePolicy;
@ -83,9 +84,11 @@ class IOThread : public base::Thread {
virtual void Init() {
BrowserAppCacheSystem::InitializeOnIOThread(request_context);
BrowserSocketStreamBridge::InitializeOnIOThread(request_context);
}
virtual void CleanUp() {
BrowserSocketStreamBridge::Cleanup();
if (request_context) {
request_context->Release();
request_context = NULL;

View File

@ -0,0 +1,227 @@
// Copyright (c) 2009 The Chromium 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 <vector>
#include "browser_socket_stream_bridge.h"
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "googleurl/src/gurl.h"
#include "net/socket_stream/socket_stream.h"
#include "net/url_request/url_request_context.h"
#include "webkit/api/public/WebSocketStreamHandle.h"
#include "webkit/glue/websocketstreamhandle_bridge.h"
#include "webkit/glue/websocketstreamhandle_delegate.h"
using webkit_glue::WebSocketStreamHandleBridge;
static const int kNoSocketId = 0;
namespace {
MessageLoop* g_io_thread;
scoped_refptr<URLRequestContext> g_request_context;
class WebSocketStreamHandleBridgeImpl
: public base::RefCountedThreadSafe<WebSocketStreamHandleBridgeImpl>,
public WebSocketStreamHandleBridge,
public net::SocketStream::Delegate {
public:
WebSocketStreamHandleBridgeImpl(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate);
virtual ~WebSocketStreamHandleBridgeImpl();
// WebSocketStreamHandleBridge methods.
virtual void Connect(const GURL& url);
virtual bool Send(const std::vector<char>& data);
virtual void Close();
// net::SocketStream::Delegate methods.
virtual void OnConnected(net::SocketStream* req,
int max_pending_send_allowed);
virtual void OnSentData(net::SocketStream* req,
int amount_sent);
virtual void OnReceivedData(net::SocketStream* req,
const char* data, int len);
virtual void OnClose(net::SocketStream* req);
private:
// Runs on |g_io_thread|;
void DoConnect(const GURL& url);
void DoSend(std::vector<char>* data);
void DoClose();
// Runs on |message_loop_|;
void DoOnConnected(int max_amount_send_allowed);
void DoOnSentData(int amount_sent);
void DoOnReceivedData(std::vector<char>* data);
void DoOnClose(webkit_glue::WebSocketStreamHandleDelegate* delegate);
int socket_id_;
MessageLoop* message_loop_;
WebKit::WebSocketStreamHandle* handle_;
webkit_glue::WebSocketStreamHandleDelegate* delegate_;
scoped_refptr<net::SocketStream> socket_;
DISALLOW_COPY_AND_ASSIGN(WebSocketStreamHandleBridgeImpl);
};
WebSocketStreamHandleBridgeImpl::WebSocketStreamHandleBridgeImpl(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate)
: socket_id_(kNoSocketId),
message_loop_(MessageLoop::current()),
handle_(handle),
delegate_(delegate) {
}
WebSocketStreamHandleBridgeImpl::~WebSocketStreamHandleBridgeImpl() {
CHECK(socket_id_ == kNoSocketId);
}
void WebSocketStreamHandleBridgeImpl::Connect(const GURL& url) {
CHECK(g_io_thread);
AddRef(); // Released in DoOnClose().
g_io_thread->PostTask(
FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoConnect,
url));
if (delegate_)
delegate_->WillOpenStream(handle_, url);
}
bool WebSocketStreamHandleBridgeImpl::Send(
const std::vector<char>& data) {
CHECK(g_io_thread);
g_io_thread->PostTask(
FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoSend,
new std::vector<char>(data)));
return true;
}
void WebSocketStreamHandleBridgeImpl::Close() {
CHECK(g_io_thread);
g_io_thread->PostTask(
FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoClose));
}
void WebSocketStreamHandleBridgeImpl::OnConnected(
net::SocketStream* socket, int max_pending_send_allowed) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnConnected,
max_pending_send_allowed));
}
void WebSocketStreamHandleBridgeImpl::OnSentData(
net::SocketStream* socket, int amount_sent) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnSentData,
amount_sent));
}
void WebSocketStreamHandleBridgeImpl::OnReceivedData(
net::SocketStream* socket, const char* data, int len) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this,
&WebSocketStreamHandleBridgeImpl::DoOnReceivedData,
new std::vector<char>(data, data + len)));
}
void WebSocketStreamHandleBridgeImpl::OnClose(net::SocketStream* socket) {
webkit_glue::WebSocketStreamHandleDelegate* delegate = delegate_;
delegate_ = NULL;
socket_ = 0;
socket_id_ = kNoSocketId;
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnClose,
delegate));
}
void WebSocketStreamHandleBridgeImpl::DoConnect(const GURL& url) {
CHECK(MessageLoop::current() == g_io_thread);
socket_ = new net::SocketStream(url, this);
socket_->set_context(g_request_context);
socket_->Connect();
}
void WebSocketStreamHandleBridgeImpl::DoSend(std::vector<char>* data) {
CHECK(MessageLoop::current() == g_io_thread);
scoped_ptr<std::vector<char> > scoped_data(data);
if (!socket_)
return;
if (!socket_->SendData(&(data->at(0)), data->size()))
socket_->Close();
}
void WebSocketStreamHandleBridgeImpl::DoClose() {
CHECK(MessageLoop::current() == g_io_thread);
if (!socket_)
return;
socket_->Close();
}
void WebSocketStreamHandleBridgeImpl::DoOnConnected(
int max_pending_send_allowed) {
CHECK(MessageLoop::current() == message_loop_);
if (delegate_)
delegate_->DidOpenStream(handle_, max_pending_send_allowed);
}
void WebSocketStreamHandleBridgeImpl::DoOnSentData(int amount_sent) {
CHECK(MessageLoop::current() == message_loop_);
if (delegate_)
delegate_->DidSendData(handle_, amount_sent);
}
void WebSocketStreamHandleBridgeImpl::DoOnReceivedData(
std::vector<char>* data) {
CHECK(MessageLoop::current() == message_loop_);
scoped_ptr<std::vector<char> > scoped_data(data);
if (delegate_)
delegate_->DidReceiveData(handle_, &(data->at(0)), data->size());
}
void WebSocketStreamHandleBridgeImpl::DoOnClose(
webkit_glue::WebSocketStreamHandleDelegate* delegate) {
CHECK(MessageLoop::current() == message_loop_);
CHECK(!socket_);
if (delegate)
delegate->DidClose(handle_);
Release();
}
} // namespace
/* static */
void BrowserSocketStreamBridge::InitializeOnIOThread(
URLRequestContext* request_context) {
g_io_thread = MessageLoop::current();
g_request_context = request_context;
}
void BrowserSocketStreamBridge::Cleanup() {
g_io_thread = NULL;
g_request_context = NULL;
}
namespace webkit_glue {
/* static */
WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create(
WebKit::WebSocketStreamHandle* handle,
WebSocketStreamHandleDelegate* delegate) {
return new WebSocketStreamHandleBridgeImpl(handle, delegate);
}
} // namespace webkit_glue

View File

@ -0,0 +1,16 @@
// Copyright (c) 2009 The Chromium 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 _BROWSER_SOCKET_STREAM_BRIDGE_H
#define _BROWSER_SOCKET_STREAM_BRIDGE_H
class URLRequestContext;
class BrowserSocketStreamBridge {
public:
static void InitializeOnIOThread(URLRequestContext* request_context);
static void Cleanup();
};
#endif // _BROWSER_SOCKET_STREAM_BRIDGE_H

View File

@ -12,15 +12,15 @@
namespace WebKit {
class WebFrame;
}
class WebView;
}
namespace webkit_glue {
#if defined(OS_WIN)
// Capture a bitmap of the web view.
void CaptureWebViewBitmap(HWND mainWnd, WebView* webview, HBITMAP& bitmap,
SIZE& size);
void CaptureWebViewBitmap(HWND mainWnd, WebKit::WebView* webview,
HBITMAP& bitmap, SIZE& size);
// Save a bitmap image to file, providing optional alternative data in |lpBits|
BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits);

View File

@ -22,12 +22,13 @@ MSVC_POP_WARNING();
#include "skia/ext/platform_canvas.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebSize.h"
#include "webkit/api/public/WebView.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webview.h"
#include "webkit/glue/plugins/plugin_list.h"
using WebKit::WebRect;
using WebKit::WebSize;
using WebKit::WebView;
namespace webkit_glue {

View File

@ -47,6 +47,7 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
ASCIIToUTF16(webkit_glue::GetUIResourceProtocol()));
WebKit::registerExtension(extensions_v8::GearsExtension::Get());
WebKit::registerExtension(extensions_v8::IntervalExtension::Get());
WebKit::enableWebSockets();
// Load libraries for media and enable the media player.
FilePath module_path;

View File

@ -45,6 +45,7 @@
#include "webkit/api/public/WebURLError.h"
#include "webkit/api/public/WebURLRequest.h"
#include "webkit/api/public/WebURLResponse.h"
#include "webkit/api/public/WebView.h"
#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/media/buffered_data_source.h"
@ -54,7 +55,6 @@
#include "webkit/glue/webplugin_impl.h"
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webview.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/plugins/webplugin_delegate_impl.h"
#include "webkit/glue/webmediaplayer_impl.h"
@ -98,6 +98,7 @@ using WebKit::WebURL;
using WebKit::WebURLError;
using WebKit::WebURLRequest;
using WebKit::WebURLResponse;
using WebKit::WebView;
using WebKit::WebWidget;
using WebKit::WebWorker;
using WebKit::WebWorkerClient;
@ -543,6 +544,33 @@ WebNavigationPolicy BrowserWebViewDelegate::decidePolicyForNavigation(
return result;
}
bool BrowserWebViewDelegate::canHandleRequest(
WebFrame* frame, const WebURLRequest& request) {
return true;
}
WebURLError BrowserWebViewDelegate::cannotHandleRequestError(
WebFrame* frame, const WebURLRequest& request) {
WebURLError error;
error.domain = WebString::fromUTF8(net::kErrorDomain);
error.reason = net::ERR_ABORTED;
error.unreachableURL = request.url();
return error;
}
WebURLError BrowserWebViewDelegate::cancelledError(
WebFrame* frame, const WebURLRequest& request) {
WebURLError error;
error.domain = WebString::fromUTF8(net::kErrorDomain);
error.reason = net::ERR_ABORTED;
error.unreachableURL = request.url();
return error;
}
void BrowserWebViewDelegate::unableToImplementPolicyWithError(
WebFrame* frame, const WebURLError& error) {
}
void BrowserWebViewDelegate::willSubmitForm(WebFrame* frame, const WebForm&) {
// Ignore
}

View File

@ -24,9 +24,9 @@
#include "webkit/api/public/WebContextMenuData.h"
#include "webkit/api/public/WebFrameClient.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebViewClient.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webplugin_page_delegate.h"
#include "webkit/glue/webview_delegate.h"
#if defined(OS_WIN)
#include "browser_drag_delegate.h"
#include "browser_drop_delegate.h"
@ -38,13 +38,13 @@ struct WebPreferences;
class GURL;
class WebWidgetHost;
class BrowserWebViewDelegate : public WebViewDelegate,
class BrowserWebViewDelegate : public WebKit::WebViewClient,
public WebKit::WebFrameClient,
public webkit_glue::WebPluginPageDelegate,
public base::SupportsWeakPtr<BrowserWebViewDelegate> {
public:
// WebKit::WebViewClient
virtual WebView* createView(WebKit::WebFrame* creator);
virtual WebKit::WebView* createView(WebKit::WebFrame* creator);
virtual WebKit::WebWidget* createPopupMenu(bool activatable);
virtual WebKit::WebWidget* createPopupMenu(
const WebKit::WebPopupMenuInfo& info);
@ -156,6 +156,14 @@ class BrowserWebViewDelegate : public WebViewDelegate,
WebKit::WebFrame*, const WebKit::WebURLRequest&,
WebKit::WebNavigationType, const WebKit::WebNode&,
WebKit::WebNavigationPolicy default_policy, bool isRedirect);
virtual bool canHandleRequest(
WebKit::WebFrame*, const WebKit::WebURLRequest&);
virtual WebKit::WebURLError cannotHandleRequestError(
WebKit::WebFrame*, const WebKit::WebURLRequest& request);
virtual WebKit::WebURLError cancelledError(
WebKit::WebFrame*, const WebKit::WebURLRequest& request);
virtual void unableToImplementPolicyWithError(
WebKit::WebFrame*, const WebKit::WebURLError&);
virtual void willSubmitForm(WebKit::WebFrame*, const WebKit::WebForm&);
virtual void willPerformClientRedirect(
WebKit::WebFrame*, const WebKit::WebURL& from, const WebKit::WebURL& to,
@ -275,7 +283,7 @@ class BrowserWebViewDelegate : public WebViewDelegate,
protected:
// Called when the URL of the page changes.
void UpdateAddressBar(WebView* webView);
void UpdateAddressBar(WebKit::WebView* webView);
// Default handling of JavaScript messages.
void ShowJavaScriptAlert(WebKit::WebFrame* webframe,

View File

@ -29,11 +29,11 @@
#include "webkit/api/public/WebCursorInfo.h"
#include "webkit/api/public/WebFrame.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebView.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webplugin.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webview.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/plugins/webplugin_delegate_impl.h"
#include "webkit/glue/window_open_disposition.h"

View File

@ -8,8 +8,10 @@
#include "base/gfx/rect.h"
#include "base/gfx/size.h"
#include "base/win_util.h"
#include "webkit/api/public/WebView.h"
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webview.h"
using namespace WebKit;
static const wchar_t kWindowClassName[] = L"WebViewHost";
@ -38,7 +40,7 @@ WebViewHost* WebViewHost::Create(HWND parent_view,
GetModuleHandle(NULL), NULL);
win_util::SetWindowUserData(host->view_, host);
host->webwidget_ = WebView::Create(delegate);
host->webwidget_ = WebView::create(delegate);
prefs.Apply(host->webview());
host->webview()->initializeMainFrame(delegate);

View File

@ -11,9 +11,12 @@
#include "webwidget_host.h"
struct WebPreferences;
class WebView;
class BrowserWebViewDelegate;
namespace WebKit {
class WebView;
}
// This class is a simple ViewHandle-based host for a WebView
class WebViewHost : public WebWidgetHost {
public:
@ -24,7 +27,7 @@ class WebViewHost : public WebWidgetHost {
BrowserWebViewDelegate* delegate,
const WebPreferences& prefs);
WebView* webview() const;
WebKit::WebView* webview() const;
protected:
#if defined(OS_WIN)