Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: webkit/tools/test_shell/test_webview_delegate_win.cc

Issue 181014: Eliminate remaining WebCore dependencies from webplugin_impl.cc... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This file contains the implementation of TestWebViewDelegate, which serves 5 // This file contains the implementation of TestWebViewDelegate, which serves
6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to
7 // have initialized a MessageLoop before these methods are called. 7 // have initialized a MessageLoop before these methods are called.
8 8
9 #include "webkit/tools/test_shell/test_webview_delegate.h" 9 #include "webkit/tools/test_shell/test_webview_delegate.h"
10 10
(...skipping 21 matching lines...) Expand all
32 #include "webkit/glue/window_open_disposition.h" 32 #include "webkit/glue/window_open_disposition.h"
33 #include "webkit/tools/test_shell/drag_delegate.h" 33 #include "webkit/tools/test_shell/drag_delegate.h"
34 #include "webkit/tools/test_shell/drop_delegate.h" 34 #include "webkit/tools/test_shell/drop_delegate.h"
35 #include "webkit/tools/test_shell/test_navigation_controller.h" 35 #include "webkit/tools/test_shell/test_navigation_controller.h"
36 #include "webkit/tools/test_shell/test_shell.h" 36 #include "webkit/tools/test_shell/test_shell.h"
37 37
38 using WebKit::WebCursorInfo; 38 using WebKit::WebCursorInfo;
39 using WebKit::WebNavigationPolicy; 39 using WebKit::WebNavigationPolicy;
40 using WebKit::WebRect; 40 using WebKit::WebRect;
41 41
42 // WebViewDelegate ----------------------------------------------------------- 42 // WebViewDelegate ------------------------------------------------------------
43
44 WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
45 WebView* webview,
46 const GURL& url,
47 const std::string& mime_type,
48 const std::string& clsid,
49 std::string* actual_mime_type) {
50 HWND hwnd = shell_->webViewHost()->view_handle();
51 if (!hwnd)
52 return NULL;
53
54 bool allow_wildcard = true;
55 WebPluginInfo info;
56 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
57 allow_wildcard, &info,
58 actual_mime_type))
59 return NULL;
60
61 if (actual_mime_type && !actual_mime_type->empty())
62 return WebPluginDelegateImpl::Create(info.path, *actual_mime_type, hwnd);
63 else
64 return WebPluginDelegateImpl::Create(info.path, mime_type, hwnd);
65 }
66
67 void TestWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) {
68 unsigned long flags = 0;
69
70 if (move.rects_valid) {
71 HRGN hrgn = ::CreateRectRgn(move.clip_rect.x(),
72 move.clip_rect.y(),
73 move.clip_rect.right(),
74 move.clip_rect.bottom());
75 gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects);
76
77 // Note: System will own the hrgn after we call SetWindowRgn,
78 // so we don't need to call DeleteObject(hrgn)
79 ::SetWindowRgn(move.window, hrgn, FALSE);
80 } else {
81 flags |= (SWP_NOSIZE | SWP_NOMOVE);
82 }
83
84 if (move.visible)
85 flags |= SWP_SHOWWINDOW;
86 else
87 flags |= SWP_HIDEWINDOW;
88
89 ::SetWindowPos(move.window,
90 NULL,
91 move.window_rect.x(),
92 move.window_rect.y(),
93 move.window_rect.width(),
94 move.window_rect.height(),
95 flags);
96 }
97 43
98 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { 44 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) {
99 MessageBox(NULL, message.c_str(), L"JavaScript Alert", MB_OK); 45 MessageBox(NULL, message.c_str(), L"JavaScript Alert", MB_OK);
100 } 46 }
101 47
48 // WebWidgetClient ------------------------------------------------------------
49
102 void TestWebViewDelegate::show(WebNavigationPolicy) { 50 void TestWebViewDelegate::show(WebNavigationPolicy) {
103 if (WebWidgetHost* host = GetWidgetHost()) { 51 if (WebWidgetHost* host = GetWidgetHost()) {
104 HWND root = GetAncestor(host->view_handle(), GA_ROOT); 52 HWND root = GetAncestor(host->view_handle(), GA_ROOT);
105 ShowWindow(root, SW_SHOW); 53 ShowWindow(root, SW_SHOW);
106 UpdateWindow(root); 54 UpdateWindow(root);
107 } 55 }
108 } 56 }
109 57
110 void TestWebViewDelegate::closeWidgetSoon() { 58 void TestWebViewDelegate::closeWidgetSoon() {
111 if (this == shell_->delegate()) { 59 if (this == shell_->delegate()) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 EnableWindow(*i, FALSE); 117 EnableWindow(*i, FALSE);
170 } 118 }
171 119
172 shell_->set_is_modal(true); 120 shell_->set_is_modal(true);
173 MessageLoop::current()->Run(); 121 MessageLoop::current()->Run();
174 122
175 for (WindowList::const_iterator i = wl->begin(); i != wl->end(); ++i) 123 for (WindowList::const_iterator i = wl->begin(); i != wl->end(); ++i)
176 EnableWindow(*i, TRUE); 124 EnableWindow(*i, TRUE);
177 } 125 }
178 126
127 // WebPluginPageDelegate ------------------------------------------------------
128
129 webkit_glue::WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
130 const GURL& url,
131 const std::string& mime_type,
132 const std::string& clsid,
133 std::string* actual_mime_type) {
134 HWND hwnd = shell_->webViewHost()->view_handle();
135 if (!hwnd)
136 return NULL;
137
138 bool allow_wildcard = true;
139 WebPluginInfo info;
140 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
141 allow_wildcard, &info,
142 actual_mime_type))
143 return NULL;
144
145 if (actual_mime_type && !actual_mime_type->empty())
146 return WebPluginDelegateImpl::Create(info.path, *actual_mime_type, hwnd);
147 else
148 return WebPluginDelegateImpl::Create(info.path, mime_type, hwnd);
149 }
150
151 void TestWebViewDelegate::CreatedPluginWindow(
152 gfx::PluginWindowHandle handle) {
153 // ignored
154 }
155
156 void TestWebViewDelegate::WillDestroyPluginWindow(
157 gfx::PluginWindowHandle handle) {
158 // ignored
159 }
160
161 void TestWebViewDelegate::DidMovePlugin(
162 const webkit_glue::WebPluginGeometry& move) {
163 unsigned long flags = 0;
164
165 if (move.rects_valid) {
166 HRGN hrgn = ::CreateRectRgn(move.clip_rect.x(),
167 move.clip_rect.y(),
168 move.clip_rect.right(),
169 move.clip_rect.bottom());
170 gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects);
171
172 // Note: System will own the hrgn after we call SetWindowRgn,
173 // so we don't need to call DeleteObject(hrgn)
174 ::SetWindowRgn(move.window, hrgn, FALSE);
175 } else {
176 flags |= (SWP_NOSIZE | SWP_NOMOVE);
177 }
178
179 if (move.visible)
180 flags |= SWP_SHOWWINDOW;
181 else
182 flags |= SWP_HIDEWINDOW;
183
184 ::SetWindowPos(move.window,
185 NULL,
186 move.window_rect.x(),
187 move.window_rect.y(),
188 move.window_rect.width(),
189 move.window_rect.height(),
190 flags);
191 }
192
193 // Public methods -------------------------------------------------------------
194
179 void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) { 195 void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) {
180 // No selection clipboard on windows, do nothing. 196 // No selection clipboard on windows, do nothing.
181 } 197 }
182 198
183 // Private methods ----------------------------------------------------------- 199 // Private methods ------------------------------------------------------------
184 200
185 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { 201 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) {
186 // The Windows test shell, pre-refactoring, ignored this. *shrug* 202 // The Windows test shell, pre-refactoring, ignored this. *shrug*
187 } 203 }
188 204
189 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { 205 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) {
190 std::wstring url_string = UTF8ToWide(url.spec()); 206 std::wstring url_string = UTF8ToWide(url.spec());
191 SendMessage(shell_->editWnd(), WM_SETTEXT, 0, 207 SendMessage(shell_->editWnd(), WM_SETTEXT, 0,
192 reinterpret_cast<LPARAM>(url_string.c_str())); 208 reinterpret_cast<LPARAM>(url_string.c_str()));
193 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698