2010-10-03 23:04:50 +02:00
|
|
|
// 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 "webview_host.h"
|
|
|
|
#include "browser_webview_delegate.h"
|
|
|
|
|
2011-01-07 22:34:20 +01:00
|
|
|
#include "app/win/hwnd_util.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "gfx/rect.h"
|
|
|
|
#include "gfx/size.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
|
|
|
|
#include "webkit/glue/webpreferences.h"
|
|
|
|
|
|
|
|
using namespace WebKit;
|
|
|
|
|
|
|
|
static const wchar_t kWindowClassName[] = L"WebViewHost";
|
|
|
|
|
|
|
|
/*static*/
|
|
|
|
WebViewHost* WebViewHost::Create(HWND parent_view,
|
2010-11-15 16:39:56 +01:00
|
|
|
const gfx::Rect&,
|
2010-10-03 23:04:50 +02:00
|
|
|
BrowserWebViewDelegate* delegate,
|
|
|
|
WebDevToolsAgentClient* dev_tools_client,
|
|
|
|
const WebPreferences& prefs) {
|
|
|
|
WebViewHost* host = new WebViewHost();
|
|
|
|
|
|
|
|
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);
|
2011-01-07 22:34:20 +01:00
|
|
|
app::win::SetWindowUserData(host->view_, host);
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-01-12 00:46:14 +01:00
|
|
|
#if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT)
|
|
|
|
host->webwidget_ = WebView::create(delegate, dev_tools_client, NULL);
|
|
|
|
#else
|
2010-10-03 23:04:50 +02:00
|
|
|
host->webwidget_ = WebView::create(delegate, dev_tools_client);
|
2011-01-12 00:46:14 +01:00
|
|
|
#endif
|
2010-10-03 23:04:50 +02:00
|
|
|
prefs.Apply(host->webview());
|
|
|
|
host->webview()->initializeMainFrame(delegate);
|
|
|
|
|
|
|
|
return host;
|
|
|
|
}
|
|
|
|
|
|
|
|
WebView* WebViewHost::webview() const {
|
|
|
|
return static_cast<WebView*>(webwidget_);
|
|
|
|
}
|
|
|
|
|