| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/tools/test_shell/webview_host.h" | 5 #include "webkit/tools/test_shell/webview_host.h" |
| 6 | 6 |
| 7 #include "base/gfx/rect.h" | 7 #include "base/gfx/rect.h" |
| 8 #include "base/gfx/size.h" | 8 #include "base/gfx/size.h" |
| 9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
| 10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
| 11 #include "webkit/api/public/WebView.h" |
| 11 #include "webkit/glue/webpreferences.h" | 12 #include "webkit/glue/webpreferences.h" |
| 12 #include "webkit/glue/webview.h" | |
| 13 #include "webkit/tools/test_shell/test_webview_delegate.h" | 13 #include "webkit/tools/test_shell/test_webview_delegate.h" |
| 14 | 14 |
| 15 using namespace WebKit; |
| 16 |
| 15 static const wchar_t kWindowClassName[] = L"WebViewHost"; | 17 static const wchar_t kWindowClassName[] = L"WebViewHost"; |
| 16 | 18 |
| 17 /*static*/ | 19 /*static*/ |
| 18 WebViewHost* WebViewHost::Create(HWND parent_view, | 20 WebViewHost* WebViewHost::Create(HWND parent_view, |
| 19 TestWebViewDelegate* delegate, | 21 TestWebViewDelegate* delegate, |
| 20 const WebPreferences& prefs) { | 22 const WebPreferences& prefs) { |
| 21 WebViewHost* host = new WebViewHost(); | 23 WebViewHost* host = new WebViewHost(); |
| 22 | 24 |
| 23 static bool registered_class = false; | 25 static bool registered_class = false; |
| 24 if (!registered_class) { | 26 if (!registered_class) { |
| 25 WNDCLASSEX wcex = {0}; | 27 WNDCLASSEX wcex = {0}; |
| 26 wcex.cbSize = sizeof(wcex); | 28 wcex.cbSize = sizeof(wcex); |
| 27 wcex.style = CS_DBLCLKS; | 29 wcex.style = CS_DBLCLKS; |
| 28 wcex.lpfnWndProc = WebWidgetHost::WndProc; | 30 wcex.lpfnWndProc = WebWidgetHost::WndProc; |
| 29 wcex.hInstance = GetModuleHandle(NULL); | 31 wcex.hInstance = GetModuleHandle(NULL); |
| 30 wcex.hCursor = LoadCursor(NULL, IDC_ARROW); | 32 wcex.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 31 wcex.lpszClassName = kWindowClassName; | 33 wcex.lpszClassName = kWindowClassName; |
| 32 RegisterClassEx(&wcex); | 34 RegisterClassEx(&wcex); |
| 33 registered_class = true; | 35 registered_class = true; |
| 34 } | 36 } |
| 35 | 37 |
| 36 host->view_ = CreateWindow(kWindowClassName, NULL, | 38 host->view_ = CreateWindow(kWindowClassName, NULL, |
| 37 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0, 0, | 39 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0, 0, |
| 38 0, 0, parent_view, NULL, | 40 0, 0, parent_view, NULL, |
| 39 GetModuleHandle(NULL), NULL); | 41 GetModuleHandle(NULL), NULL); |
| 40 win_util::SetWindowUserData(host->view_, host); | 42 win_util::SetWindowUserData(host->view_, host); |
| 41 | 43 |
| 42 host->webwidget_ = WebView::Create(delegate); | 44 host->webwidget_ = WebView::create(delegate); |
| 43 prefs.Apply(host->webview()); | 45 prefs.Apply(host->webview()); |
| 44 host->webview()->initializeMainFrame(delegate); | 46 host->webview()->initializeMainFrame(delegate); |
| 45 | 47 |
| 46 return host; | 48 return host; |
| 47 } | 49 } |
| 48 | 50 |
| 49 WebView* WebViewHost::webview() const { | 51 WebView* WebViewHost::webview() const { |
| 50 return static_cast<WebView*>(webwidget_); | 52 return static_cast<WebView*>(webwidget_); |
| 51 } | 53 } |
| OLD | NEW |