Chromium Code Reviews

Side by Side Diff: webkit/glue/plugins/test/plugin_create_instance_in_paint.cc

Issue 6012002: Move the NPAPI files from webkit/glue/plugins to webkit/plugins/npapi and put... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/glue/plugins/test/plugin_create_instance_in_paint.h"
6
7 #include "webkit/glue/plugins/test/plugin_client.h"
8
9 namespace NPAPIClient {
10
11 CreateInstanceInPaintTest::CreateInstanceInPaintTest(
12 NPP id, NPNetscapeFuncs *host_functions)
13 : PluginTest(id, host_functions),
14 window_(NULL), created_(false) {
15 }
16
17 NPError CreateInstanceInPaintTest::SetWindow(NPWindow* pNPWindow) {
18 if (pNPWindow->window == NULL)
19 return NPERR_NO_ERROR;
20
21 if (test_id() == "1") {
22 if (!window_) {
23 static ATOM window_class = 0;
24 if (!window_class) {
25 WNDCLASSEX wcex;
26 wcex.cbSize = sizeof(WNDCLASSEX);
27 wcex.style = CS_DBLCLKS;
28 wcex.lpfnWndProc =
29 &NPAPIClient::CreateInstanceInPaintTest::WindowProc;
30 wcex.cbClsExtra = 0;
31 wcex.cbWndExtra = 0;
32 wcex.hInstance = GetModuleHandle(NULL);
33 wcex.hIcon = 0;
34 wcex.hCursor = 0;
35 wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);
36 wcex.lpszMenuName = 0;
37 wcex.lpszClassName = L"CreateInstanceInPaintTestWindowClass";
38 wcex.hIconSm = 0;
39 window_class = RegisterClassEx(&wcex);
40 }
41
42 HWND parent = reinterpret_cast<HWND>(pNPWindow->window);
43 window_ = CreateWindowEx(
44 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
45 MAKEINTATOM(window_class), 0,
46 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE ,
47 0, 0, 100, 100, parent, 0, GetModuleHandle(NULL), 0);
48 DCHECK(window_);
49 // TODO: this property leaks.
50 ::SetProp(window_, L"Plugin_Instance", this);
51 }
52 } else if (test_id() == "2") {
53 SignalTestCompleted();
54 } else {
55 NOTREACHED();
56 }
57 return NPERR_NO_ERROR;
58 }
59
60 LRESULT CALLBACK CreateInstanceInPaintTest::WindowProc(
61 HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
62 if (message == WM_PAINT) {
63 CreateInstanceInPaintTest* this_instance =
64 reinterpret_cast<CreateInstanceInPaintTest*>
65 (::GetProp(window, L"Plugin_Instance"));
66 if (this_instance->test_id() == "1" && !this_instance->created_) {
67 ::RemoveProp(window, L"Plugin_Instance");
68 this_instance->created_ = true;
69 this_instance->HostFunctions()->geturlnotify(
70 this_instance->id(), "javascript:CreateNewInstance()", NULL,
71 reinterpret_cast<void*>(1));
72 }
73 }
74
75 return DefWindowProc(window, message, wparam, lparam);
76 }
77
78 } // namespace NPAPIClient
OLDNEW

Powered by Google App Engine