2009-07-24 21:11:01 +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"
|
2009-09-17 18:56:32 +02:00
|
|
|
#include "browser_webview_delegate.h"
|
2009-07-24 21:11:01 +02:00
|
|
|
|
2010-06-21 20:02:39 +02:00
|
|
|
#include "gfx/rect.h"
|
|
|
|
#include "gfx/size.h"
|
2009-07-24 21:11:01 +02:00
|
|
|
#include "base/win_util.h"
|
2010-01-12 02:37:00 +01:00
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
|
2009-08-20 19:53:30 +02:00
|
|
|
#include "webkit/glue/webpreferences.h"
|
2009-10-22 01:27:29 +02:00
|
|
|
|
|
|
|
using namespace WebKit;
|
2009-07-24 21:11:01 +02:00
|
|
|
|
|
|
|
static const wchar_t kWindowClassName[] = L"WebViewHost";
|
|
|
|
|
|
|
|
/*static*/
|
|
|
|
WebViewHost* WebViewHost::Create(HWND parent_view,
|
2009-09-17 18:56:32 +02:00
|
|
|
BrowserWebViewDelegate* delegate,
|
2009-07-24 21:11:01 +02:00
|
|
|
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);
|
|
|
|
win_util::SetWindowUserData(host->view_, host);
|
|
|
|
|
2009-10-22 01:27:29 +02:00
|
|
|
host->webwidget_ = WebView::create(delegate);
|
2009-09-17 18:56:32 +02:00
|
|
|
prefs.Apply(host->webview());
|
2009-10-03 03:36:52 +02:00
|
|
|
host->webview()->initializeMainFrame(delegate);
|
2009-07-24 21:11:01 +02:00
|
|
|
|
|
|
|
return host;
|
|
|
|
}
|
|
|
|
|
|
|
|
WebView* WebViewHost::webview() const {
|
|
|
|
return static_cast<WebView*>(webwidget_);
|
|
|
|
}
|
|
|
|
|