Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PLUGINS_NPAPI_WEBVIEW_PLUGIN_H_ | 5 #ifndef WEBKIT_PLUGINS_NPAPI_WEBVIEW_PLUGIN_H_ |
|
jam
2011/11/22 18:03:32
nit: update ifdef guards
Bernhard Bauer
2011/11/22 18:53:33
Done.
| |
| 6 #define WEBKIT_PLUGINS_NPAPI_WEBVIEW_PLUGIN_H_ | 6 #define WEBKIT_PLUGINS_NPAPI_WEBVIEW_PLUGIN_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" | |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
| 19 | 18 |
| 20 namespace WebKit { | 19 namespace WebKit { |
| 21 class WebMouseEvent; | 20 class WebMouseEvent; |
| 22 } | 21 } |
| 23 struct WebPreferences; | 22 struct WebPreferences; |
| 24 | 23 |
| 25 namespace webkit { | 24 namespace webkit { |
| 26 namespace npapi { | |
| 27 | 25 |
| 28 // This class implements the WebPlugin interface by forwarding drawing and | 26 // This class implements the WebPlugin interface by forwarding drawing and |
| 29 // handling input events to a WebView. | 27 // handling input events to a WebView. |
| 30 // It can be used as a placeholder for an actual plugin, using HTML for the UI. | 28 // It can be used as a placeholder for an actual plugin, using HTML for the UI. |
| 31 // To show HTML data inside the WebViewPlugin, | 29 // To show HTML data inside the WebViewPlugin, |
| 32 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake | 30 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake |
| 33 // chrome:// URL as origin. | 31 // chrome:// URL as origin. |
| 34 | 32 |
| 35 class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient, | 33 class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient, |
| 36 public WebKit::WebFrameClient { | 34 public WebKit::WebFrameClient { |
| 37 public: | 35 public: |
| 38 class Delegate { | 36 class Delegate { |
| 39 public: | 37 public: |
| 40 // Bind |frame| to a Javascript object, enabling the delegate to receive | 38 // Bind |frame| to a Javascript object, enabling the delegate to receive |
| 41 // callback methods from Javascript inside the WebFrame. | 39 // callback methods from Javascript inside the WebFrame. |
| 42 // This method is called from WebFrameClient::didClearWindowObject. | 40 // This method is called from WebFrameClient::didClearWindowObject. |
| 43 virtual void BindWebFrame(WebKit::WebFrame* frame) = 0; | 41 virtual void BindWebFrame(WebKit::WebFrame* frame) = 0; |
| 44 | 42 |
| 45 // Called before the WebViewPlugin is destroyed. The delegate should delete | 43 // Called before the WebViewPlugin is destroyed. The delegate should delete |
| 46 // itself here. | 44 // itself here. |
| 47 virtual void WillDestroyPlugin() = 0; | 45 virtual void WillDestroyPlugin() = 0; |
| 48 | 46 |
| 49 // Called upon a context menu event. | 47 // Called upon a context menu event. |
| 50 virtual void ShowContextMenu(const WebKit::WebMouseEvent&) = 0; | 48 virtual void ShowContextMenu(const WebKit::WebMouseEvent&) {} |
|
jam
2011/11/22 18:03:32
nit: it's much better to have interfaces that are
Bernhard Bauer
2011/11/22 18:53:33
Hm, I guess that's from an earlier version where I
| |
| 51 }; | 49 }; |
| 52 | 50 |
| 53 explicit WebViewPlugin(Delegate* delegate); | 51 explicit WebViewPlugin(Delegate* delegate); |
| 54 | 52 |
| 55 // Convenience method to set up a new WebViewPlugin using |preferences| | 53 // Convenience method to set up a new WebViewPlugin using |preferences| |
| 56 // and displaying |html_data|. |url| should be a (fake) chrome:// URL; it is | 54 // and displaying |html_data|. |url| should be a (fake) chrome:// URL; it is |
| 57 // only used for navigation and never actually resolved. | 55 // only used for navigation and never actually resolved. |
| 58 static WebViewPlugin* Create(Delegate* delegate, | 56 static WebViewPlugin* Create(Delegate* delegate, |
| 59 const WebPreferences& preferences, | 57 const WebPreferences& preferences, |
| 60 const std::string& html_data, | 58 const std::string& html_data, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 // (which does nothing) to correctly overload it. | 132 // (which does nothing) to correctly overload it. |
| 135 virtual void didReceiveResponse(WebKit::WebFrame* frame, | 133 virtual void didReceiveResponse(WebKit::WebFrame* frame, |
| 136 unsigned identifier, | 134 unsigned identifier, |
| 137 const WebKit::WebURLResponse& response); | 135 const WebKit::WebURLResponse& response); |
| 138 | 136 |
| 139 private: | 137 private: |
| 140 friend class DeleteTask<WebViewPlugin>; | 138 friend class DeleteTask<WebViewPlugin>; |
| 141 virtual ~WebViewPlugin(); | 139 virtual ~WebViewPlugin(); |
| 142 | 140 |
| 143 Delegate* delegate_; | 141 Delegate* delegate_; |
| 142 // Destroys itself. | |
| 144 WebKit::WebCursorInfo current_cursor_; | 143 WebKit::WebCursorInfo current_cursor_; |
| 144 // Owns us. | |
| 145 WebKit::WebPluginContainer* container_; | 145 WebKit::WebPluginContainer* container_; |
| 146 // Owned by us, deleted via |close()|. | |
| 146 WebKit::WebView* web_view_; | 147 WebKit::WebView* web_view_; |
| 147 gfx::Rect rect_; | 148 gfx::Rect rect_; |
| 148 | 149 |
| 149 WebKit::WebURLResponse response_; | 150 WebKit::WebURLResponse response_; |
| 150 std::list<std::string> data_; | 151 std::list<std::string> data_; |
| 151 bool finished_loading_; | 152 bool finished_loading_; |
| 152 scoped_ptr<WebKit::WebURLError> error_; | 153 scoped_ptr<WebKit::WebURLError> error_; |
| 153 WebKit::WebString old_title_; | 154 WebKit::WebString old_title_; |
| 154 }; | 155 }; |
| 155 | 156 |
| 156 } // namespace npapi | |
| 157 } // namespace webkit | 157 } // namespace webkit |
| 158 | 158 |
| 159 #endif // WEBKIT_PLUGINS_NPAPI_WEBVIEW_PLUGIN_H_ | 159 #endif // WEBKIT_PLUGINS_NPAPI_WEBVIEW_PLUGIN_H_ |
| OLD | NEW |