cef/cef1/libcef/webview_host_win.cc
Marshall Greenblatt 801ff3ca43 - Update to Chromium revision 138235.
- Move to the new DOM storage backend. Persistent localStorage support will need to be re-implemented (issue #603).
- Add CefV8Value::CreateUInt method and indicate that integer types are 32bit via usage of int32 and uint32 types (issue #331).
- Add CefV8Context::Eval method for synchronous JavaScript execution that returns a value or exception (issue #444).
- Move exception handling from an ExecuteFunction argument to a CefV8Value attribute (issue #546).
- Make user data an attribute for all CefV8Value object types and not just CreateObject (issue #547).
- Un-fork SQLitePersistentCookieStore by adding stub implementations for sqlite_diagnostics and browser_thread.
- Update tools/cef_parser.py to match the CEF3 version.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@644 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-23 19:01:04 +00:00

100 lines
3.4 KiB
C++

// Copyright (c) 2006-2008 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 "libcef/webview_host.h"
#include "libcef/browser_webview_delegate.h"
#include "libcef/cef_context.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFactory.h"
#include "ui/base/win/hwnd_util.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "webkit/glue/webpreferences.h"
using WebKit::WebDevToolsAgentClient;
using WebKit::WebKeyboardEvent;
using WebKit::WebInputEvent;
using WebKit::WebInputEventFactory;
using WebKit::WebView;
static const wchar_t kWindowClassName[] = L"WebViewHost";
/*static*/
WebViewHost* WebViewHost::Create(HWND parent_view,
const gfx::Rect&,
BrowserWebViewDelegate* delegate,
PaintDelegate* paint_delegate,
WebDevToolsAgentClient* dev_tools_client,
const webkit_glue::WebPreferences& prefs) {
WebViewHost* host = new WebViewHost(delegate);
if (!paint_delegate) {
static bool registered_class = false;
if (!registered_class) {
WNDCLASSEX wcex = {0};
wcex.cbSize = sizeof(wcex);
wcex.style = CS_DBLCLKS;
wcex.lpfnWndProc = WebWidgetHost::WndProc;
wcex.hInstance = GetModuleHandle(NULL);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.lpszClassName = kWindowClassName;
RegisterClassEx(&wcex);
registered_class = true;
}
host->view_ = CreateWindow(kWindowClassName, NULL,
WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0, 0,
0, 0, parent_view, NULL,
GetModuleHandle(NULL), NULL);
ui::SetWindowUserData(host->view_, host);
} else {
host->paint_delegate_ = paint_delegate;
}
#if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT)
host->webwidget_ = WebView::create(delegate, NULL);
#else
host->webwidget_ = WebView::create(delegate);
#endif
host->webview()->setDevToolsAgentClient(dev_tools_client);
host->webview()->setPermissionClient(delegate);
prefs.Apply(host->webview());
host->webview()->initializeMainFrame(delegate);
return host;
}
WebView* WebViewHost::webview() const {
return static_cast<WebView*>(webwidget_);
}
bool WebViewHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
switch (message) {
case WM_SETFOCUS:
// Set the current WebViewHost in case a drag action is started before mouse
// events are detected for the window.
_Context->set_current_webviewhost(this);
break;
}
return false;
}
void WebViewHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
_Context->set_current_webviewhost(this);
WebWidgetHost::MouseEvent(message, wparam, lparam);
}
void WebViewHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) {
// Give the client a chance to handle keyboard events before they're passed
// to WebKit.
const WebKeyboardEvent& event = WebInputEventFactory::keyboardEvent(
view_, message, wparam, lparam);
if (delegate_->OnKeyboardEvent(event, false))
return;
WebWidgetHost::KeyEvent(message, wparam, lparam);
}