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

Side by Side Diff: webkit/tools/test_shell/mac/test_webview_delegate.mm

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) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/test_webview_delegate.h" 5 #include "webkit/tools/test_shell/test_webview_delegate.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "webkit/api/public/WebCursorInfo.h" 10 #include "webkit/api/public/WebCursorInfo.h"
11 #include "webkit/glue/webcursor.h" 11 #include "webkit/glue/webcursor.h"
12 #include "webkit/glue/webview.h" 12 #include "webkit/glue/webview.h"
13 #include "webkit/glue/plugins/plugin_list.h" 13 #include "webkit/glue/plugins/plugin_list.h"
14 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 14 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
15 #include "webkit/glue/webmenurunner_mac.h" 15 #include "webkit/glue/webmenurunner_mac.h"
16 #include "webkit/tools/test_shell/test_shell.h" 16 #include "webkit/tools/test_shell/test_shell.h"
17 17
18 using WebKit::WebCursorInfo; 18 using WebKit::WebCursorInfo;
19 using WebKit::WebNavigationPolicy; 19 using WebKit::WebNavigationPolicy;
20 using WebKit::WebPopupMenuInfo; 20 using WebKit::WebPopupMenuInfo;
21 using WebKit::WebRect; 21 using WebKit::WebRect;
22 using WebKit::WebWidget; 22 using WebKit::WebWidget;
23 23
24 // WebViewDelegate ----------------------------------------------------------- 24 // WebViewDelegate ------------------------------------------------------------
25 25
26 WebWidget* TestWebViewDelegate::CreatePopupWidgetWithInfo( 26 WebWidget* TestWebViewDelegate::CreatePopupWidgetWithInfo(
27 WebView* webview, 27 WebView* webview,
28 const WebPopupMenuInfo& info) { 28 const WebPopupMenuInfo& info) {
29 WebWidget* webwidget = shell_->CreatePopupWidget(webview); 29 WebWidget* webwidget = shell_->CreatePopupWidget(webview);
30 popup_menu_info_.reset(new WebPopupMenuInfo(info)); 30 popup_menu_info_.reset(new WebPopupMenuInfo(info));
31 return webwidget; 31 return webwidget;
32 } 32 }
33 33
34 WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
35 WebView* webview,
36 const GURL& url,
37 const std::string& mime_type,
38 const std::string& clsid,
39 std::string* actual_mime_type) {
40 WebWidgetHost *host = GetWidgetHost();
41 if (!host)
42 return NULL;
43 gfx::NativeView view = host->view_handle();
44
45 bool allow_wildcard = true;
46 WebPluginInfo info;
47 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
48 allow_wildcard, &info,
49 actual_mime_type))
50 return NULL;
51
52 if (actual_mime_type && !actual_mime_type->empty())
53 return WebPluginDelegateImpl::Create(info.path, *actual_mime_type, view);
54 else
55 return WebPluginDelegateImpl::Create(info.path, mime_type, view);
56 }
57
58 void TestWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) {
59 // TODO(port): add me once plugins work.
60 }
61
62 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { 34 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) {
63 NSString *text = 35 NSString *text =
64 [NSString stringWithUTF8String:WideToUTF8(message).c_str()]; 36 [NSString stringWithUTF8String:WideToUTF8(message).c_str()];
65 NSAlert *alert = [NSAlert alertWithMessageText:@"JavaScript Alert" 37 NSAlert *alert = [NSAlert alertWithMessageText:@"JavaScript Alert"
66 defaultButton:@"OK" 38 defaultButton:@"OK"
67 alternateButton:nil 39 alternateButton:nil
68 otherButton:nil 40 otherButton:nil
69 informativeTextWithFormat:text]; 41 informativeTextWithFormat:text];
70 [alert runModal]; 42 [alert runModal];
71 } 43 }
72 44
73 45 // WebWidgetClient ------------------------------------------------------------
74 // WebWidgetDelegate ---------------------------------------------------------
75 46
76 void TestWebViewDelegate::show(WebNavigationPolicy policy) { 47 void TestWebViewDelegate::show(WebNavigationPolicy policy) {
77 if (!popup_menu_info_.get()) 48 if (!popup_menu_info_.get())
78 return; 49 return;
79 if (this != shell_->popup_delegate()) 50 if (this != shell_->popup_delegate())
80 return; 51 return;
81 // Display a HTML select menu. 52 // Display a HTML select menu.
82 53
83 std::vector<WebMenuItem> items; 54 std::vector<WebMenuItem> items;
84 for (size_t i = 0; i < popup_menu_info_->items.size(); ++i) 55 for (size_t i = 0; i < popup_menu_info_->items.size(); ++i)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 [view frame].size.height - resize_rect.origin.y - 163 [view frame].size.height - resize_rect.origin.y -
193 resize_rect.size.height; 164 resize_rect.size.height;
194 } 165 }
195 return gfx::Rect(NSRectToCGRect(resize_rect)); 166 return gfx::Rect(NSRectToCGRect(resize_rect));
196 } 167 }
197 168
198 void TestWebViewDelegate::runModal() { 169 void TestWebViewDelegate::runModal() {
199 NOTIMPLEMENTED(); 170 NOTIMPLEMENTED();
200 } 171 }
201 172
173 // WebPluginPageDelegate ------------------------------------------------------
174
175 webkit_glue::WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
176 const GURL& url,
177 const std::string& mime_type,
178 const std::string& clsid,
179 std::string* actual_mime_type) {
180 WebWidgetHost *host = GetWidgetHost();
181 if (!host)
182 return NULL;
183 gfx::NativeView view = host->view_handle();
184
185 bool allow_wildcard = true;
186 WebPluginInfo info;
187 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
188 allow_wildcard, &info,
189 actual_mime_type))
190 return NULL;
191
192 if (actual_mime_type && !actual_mime_type->empty())
193 return WebPluginDelegateImpl::Create(info.path, *actual_mime_type, view);
194 else
195 return WebPluginDelegateImpl::Create(info.path, mime_type, view);
196 }
197
198 void TestWebViewDelegate::CreatedPluginWindow(
199 gfx::PluginWindowHandle handle) {
200 }
201
202 void TestWebViewDelegate::WillDestroyPluginWindow(
203 gfx::PluginWindowHandle handle) {
204 }
205
206 void TestWebViewDelegate::DidMovePlugin(
207 const webkit_glue::WebPluginGeometry& move) {
208 // TODO(port): add me once plugins work.
209 }
210
211 // Public methods -------------------------------------------------------------
212
202 void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) { 213 void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) {
203 // No selection clipboard on mac, do nothing. 214 // No selection clipboard on mac, do nothing.
204 } 215 }
205 216
206 // Private methods ----------------------------------------------------------- 217 // Private methods ------------------------------------------------------------
207 218
208 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { 219 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) {
209 [[shell_->webViewHost()->view_handle() window] 220 [[shell_->webViewHost()->view_handle() window]
210 setTitle:[NSString stringWithUTF8String:WideToUTF8(title).c_str()]]; 221 setTitle:[NSString stringWithUTF8String:WideToUTF8(title).c_str()]];
211 } 222 }
212 223
213 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { 224 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) {
214 const char* frameURL = url.spec().c_str(); 225 const char* frameURL = url.spec().c_str();
215 NSString *address = [NSString stringWithUTF8String:frameURL]; 226 NSString *address = [NSString stringWithUTF8String:frameURL];
216 [shell_->editWnd() setStringValue:address]; 227 [shell_->editWnd() setStringValue:address];
217 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698