OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ |
6 #define WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ | 6 #define WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
12 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h" |
14 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | |
14 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
16 #include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h" |
19 | 20 |
20 struct WebPreferences; | 21 struct WebPreferences; |
21 | 22 |
22 // This class implements the WebPlugin interface by forwarding drawing and | 23 // This class implements the WebPlugin interface by forwarding drawing and |
23 // handling input events to a WebView. | 24 // handling input events to a WebView. |
24 // It can be used as a placeholder for an actual plugin, using HTML for the UI. | 25 // It can be used as a placeholder for an actual plugin, using HTML for the UI. |
25 // To show HTML data inside the WebViewPlugin, | 26 // To show HTML data inside the WebViewPlugin, |
26 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake | 27 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake |
27 // chrome:// URL as origin. | 28 // chrome:// URL as origin. |
28 | 29 |
29 class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient, | 30 class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient, |
30 public WebKit::WebFrameClient { | 31 public WebKit::WebFrameClient { |
31 public: | 32 public: |
32 class Delegate { | 33 class Delegate { |
33 public: | 34 public: |
34 // Bind |frame| to a Javascript object, enabling the delegate to receive | 35 // Bind |frame| to a Javascript object, enabling the delegate to receive |
35 // callback methods from Javascript inside the WebFrame. | 36 // callback methods from Javascript inside the WebFrame. |
36 // This method is called from WebFrameClient::didClearWindowObject. | 37 // This method is called from WebFrameClient::didClearWindowObject. |
37 virtual void BindWebFrame(WebKit::WebFrame* frame) = 0; | 38 virtual void BindWebFrame(WebKit::WebFrame* frame) = 0; |
38 | 39 |
39 // Called before the WebViewPlugin is destroyed. The delegate should delete | 40 // Called before the WebViewPlugin is destroyed. The delegate should delete |
40 // itself here. | 41 // itself here. |
41 virtual void WillDestroyPlugin() = 0; | 42 virtual void WillDestroyPlugin() = 0; |
43 | |
44 // Called upon a context menu event. | |
45 virtual void ShowContextMenu(const WebKit::WebMouseEvent&) = 0; | |
brettw
2010/12/07 06:23:56
This can be forward-declared like WebPreferences t
Chris Evans
2010/12/07 15:36:14
I don't believe this is possible, because WebMouse
| |
42 }; | 46 }; |
43 | 47 |
44 explicit WebViewPlugin(Delegate* delegate); | 48 explicit WebViewPlugin(Delegate* delegate); |
45 | 49 |
46 // Convenience method to set up a new WebViewPlugin using |preferences| | 50 // Convenience method to set up a new WebViewPlugin using |preferences| |
47 // and displaying |html_data|. |url| should be a (fake) chrome:// URL; it is | 51 // and displaying |html_data|. |url| should be a (fake) chrome:// URL; it is |
48 // only used for navigation and never actually resolved. | 52 // only used for navigation and never actually resolved. |
49 static WebViewPlugin* Create(Delegate* delegate, | 53 static WebViewPlugin* Create(Delegate* delegate, |
50 const WebPreferences& preferences, | 54 const WebPreferences& preferences, |
51 const std::string& html_data, | 55 const std::string& html_data, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 gfx::Rect rect_; | 131 gfx::Rect rect_; |
128 | 132 |
129 WebKit::WebURLResponse response_; | 133 WebKit::WebURLResponse response_; |
130 std::list<std::string> data_; | 134 std::list<std::string> data_; |
131 bool finished_loading_; | 135 bool finished_loading_; |
132 scoped_ptr<WebKit::WebURLError> error_; | 136 scoped_ptr<WebKit::WebURLError> error_; |
133 WebKit::WebString old_title_; | 137 WebKit::WebString old_title_; |
134 }; | 138 }; |
135 | 139 |
136 #endif // WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ | 140 #endif // WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_ |
OLD | NEW |