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