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

Side by Side Diff: webkit/glue/plugins/webview_plugin.h

Issue 6012002: Move the NPAPI files from webkit/glue/plugins to webkit/plugins/npapi and put... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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
« no previous file with comments | « webkit/glue/plugins/webplugininfo.cc ('k') | webkit/glue/plugins/webview_plugin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_
6 #define WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_
7
8 #include <list>
9
10 #include "base/scoped_ptr.h"
11 #include "base/task.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h"
14 #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/WebTextDirection.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h"
19
20 namespace WebKit {
21 class WebMouseEvent;
22 }
23 struct WebPreferences;
24
25 // This class implements the WebPlugin interface by forwarding drawing and
26 // handling input events to a WebView.
27 // It can be used as a placeholder for an actual plugin, using HTML for the UI.
28 // To show HTML data inside the WebViewPlugin,
29 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake
30 // chrome:// URL as origin.
31
32 class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient,
33 public WebKit::WebFrameClient {
34 public:
35 class Delegate {
36 public:
37 // Bind |frame| to a Javascript object, enabling the delegate to receive
38 // callback methods from Javascript inside the WebFrame.
39 // This method is called from WebFrameClient::didClearWindowObject.
40 virtual void BindWebFrame(WebKit::WebFrame* frame) = 0;
41
42 // Called before the WebViewPlugin is destroyed. The delegate should delete
43 // itself here.
44 virtual void WillDestroyPlugin() = 0;
45
46 // Called upon a context menu event.
47 virtual void ShowContextMenu(const WebKit::WebMouseEvent&) = 0;
48 };
49
50 explicit WebViewPlugin(Delegate* delegate);
51
52 // Convenience method to set up a new WebViewPlugin using |preferences|
53 // and displaying |html_data|. |url| should be a (fake) chrome:// URL; it is
54 // only used for navigation and never actually resolved.
55 static WebViewPlugin* Create(Delegate* delegate,
56 const WebPreferences& preferences,
57 const std::string& html_data,
58 const GURL& url);
59
60 WebKit::WebView* web_view() { return web_view_; }
61
62 WebKit::WebPluginContainer* container() { return container_; }
63
64 // When loading a plug-in document (i.e. a full page plug-in not embedded in
65 // another page), we save all data that has been received, and replay it with
66 // this method on the actual plug-in.
67 void ReplayReceivedData(WebKit::WebPlugin* plugin);
68
69 // WebPlugin methods:
70 virtual bool initialize(WebKit::WebPluginContainer*);
71 virtual void destroy();
72
73 virtual NPObject* scriptableObject() { return NULL; }
74
75 virtual void paint(WebKit::WebCanvas* canvas, const WebKit::WebRect& rect);
76
77 // Coordinates are relative to the containing window.
78 virtual void updateGeometry(
79 const WebKit::WebRect& frame_rect, const WebKit::WebRect& clip_rect,
80 const WebKit::WebVector<WebKit::WebRect>& cut_out_rects, bool is_visible);
81
82 virtual void updateFocus(bool) { }
83 virtual void updateVisibility(bool) { }
84
85 virtual bool acceptsInputEvents() { return true; }
86 virtual bool handleInputEvent(const WebKit::WebInputEvent& event,
87 WebKit::WebCursorInfo& cursor_info);
88
89 virtual void didReceiveResponse(const WebKit::WebURLResponse& response);
90 virtual void didReceiveData(const char* data, int data_length);
91 virtual void didFinishLoading();
92 virtual void didFailLoading(const WebKit::WebURLError& error);
93
94 // Called in response to WebPluginContainer::loadFrameRequest
95 virtual void didFinishLoadingFrameRequest(
96 const WebKit::WebURL& url, void* notifyData) { }
97 virtual void didFailLoadingFrameRequest(const WebKit::WebURL& url,
98 void* notify_data,
99 const WebKit::WebURLError& error) { }
100
101 // WebViewClient methods:
102 virtual bool acceptsLoadDrops() { return false; }
103
104 virtual void setToolTipText(const WebKit::WebString&,
105 WebKit::WebTextDirection);
106
107 virtual void startDragging(const WebKit::WebDragData& drag_data,
108 WebKit::WebDragOperationsMask mask,
109 const WebKit::WebImage& image,
110 const WebKit::WebPoint& point);
111
112 // WebWidgetClient methods:
113 virtual void didInvalidateRect(const WebKit::WebRect&);
114 virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor);
115
116 // WebFrameClient methods:
117 virtual void didClearWindowObject(WebKit::WebFrame* frame);
118
119 virtual bool canHandleRequest(WebKit::WebFrame* frame,
120 const WebKit::WebURLRequest& request);
121
122 virtual WebKit::WebURLError cancelledError(
123 WebKit::WebFrame* frame, const WebKit::WebURLRequest& request);
124
125 private:
126 friend class DeleteTask<WebViewPlugin>;
127 virtual ~WebViewPlugin();
128
129 Delegate* delegate_;
130 WebKit::WebCursorInfo current_cursor_;
131 WebKit::WebPluginContainer* container_;
132 WebKit::WebView* web_view_;
133 gfx::Rect rect_;
134
135 WebKit::WebURLResponse response_;
136 std::list<std::string> data_;
137 bool finished_loading_;
138 scoped_ptr<WebKit::WebURLError> error_;
139 WebKit::WebString old_title_;
140 };
141
142 #endif // WEBKIT_GLUE_PLUGINS_WEBVIEW_PLUGIN_H_
OLDNEW
« no previous file with comments | « webkit/glue/plugins/webplugininfo.cc ('k') | webkit/glue/plugins/webview_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698