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

Side by Side Diff: components/plugins/renderer/webview_plugin.h

Issue 357203003: Move webpreferences.* from webkit/ to content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_ 5 #ifndef COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_
6 #define COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_ 6 #define COMPONENTS_PLUGINS_RENDERER_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/sequenced_task_runner_helpers.h" 11 #include "base/sequenced_task_runner_helpers.h"
12 #include "third_party/WebKit/public/platform/WebCursorInfo.h" 12 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
13 #include "third_party/WebKit/public/platform/WebString.h" 13 #include "third_party/WebKit/public/platform/WebString.h"
14 #include "third_party/WebKit/public/platform/WebURLResponse.h" 14 #include "third_party/WebKit/public/platform/WebURLResponse.h"
15 #include "third_party/WebKit/public/web/WebFrameClient.h" 15 #include "third_party/WebKit/public/web/WebFrameClient.h"
16 #include "third_party/WebKit/public/web/WebPlugin.h" 16 #include "third_party/WebKit/public/web/WebPlugin.h"
17 #include "third_party/WebKit/public/web/WebViewClient.h" 17 #include "third_party/WebKit/public/web/WebViewClient.h"
18 18
19 struct WebPreferences;
20
21 namespace blink { 19 namespace blink {
22 class WebMouseEvent; 20 class WebMouseEvent;
23 } 21 }
24 22
23 namespace content {
24 struct WebPreferences;
25 }
26
25 // This class implements the WebPlugin interface by forwarding drawing and 27 // This class implements the WebPlugin interface by forwarding drawing and
26 // handling input events to a WebView. 28 // handling input events to a WebView.
27 // It can be used as a placeholder for an actual plugin, using HTML for the UI. 29 // It can be used as a placeholder for an actual plugin, using HTML for the UI.
28 // To show HTML data inside the WebViewPlugin, 30 // To show HTML data inside the WebViewPlugin,
29 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake 31 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake
30 // chrome:// URL as origin. 32 // chrome:// URL as origin.
31 33
32 class WebViewPlugin : public blink::WebPlugin, 34 class WebViewPlugin : public blink::WebPlugin,
33 public blink::WebViewClient, 35 public blink::WebViewClient,
34 public blink::WebFrameClient { 36 public blink::WebFrameClient {
35 public: 37 public:
36 class Delegate { 38 class Delegate {
37 public: 39 public:
38 // Bind |frame| to a Javascript object, enabling the delegate to receive 40 // Bind |frame| to a Javascript object, enabling the delegate to receive
39 // callback methods from Javascript inside the WebFrame. 41 // callback methods from Javascript inside the WebFrame.
40 // This method is called from WebFrameClient::didClearWindowObject. 42 // This method is called from WebFrameClient::didClearWindowObject.
41 virtual void BindWebFrame(blink::WebFrame* frame) = 0; 43 virtual void BindWebFrame(blink::WebFrame* frame) = 0;
42 44
43 // Called upon a context menu event. 45 // Called upon a context menu event.
44 virtual void ShowContextMenu(const blink::WebMouseEvent&) = 0; 46 virtual void ShowContextMenu(const blink::WebMouseEvent&) = 0;
45 47
46 // Called when the WebViewPlugin is destroyed. 48 // Called when the WebViewPlugin is destroyed.
47 virtual void PluginDestroyed() = 0; 49 virtual void PluginDestroyed() = 0;
48 }; 50 };
49 51
50 // Convenience method to set up a new WebViewPlugin using |preferences| 52 // Convenience method to set up a new WebViewPlugin using |preferences|
51 // 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
52 // only used for navigation and never actually resolved. 54 // only used for navigation and never actually resolved.
53 static WebViewPlugin* Create(Delegate* delegate, 55 static WebViewPlugin* Create(Delegate* delegate,
54 const WebPreferences& preferences, 56 const content::WebPreferences& preferences,
55 const std::string& html_data, 57 const std::string& html_data,
56 const GURL& url); 58 const GURL& url);
57 59
58 blink::WebView* web_view() { return web_view_; } 60 blink::WebView* web_view() { return web_view_; }
59 61
60 // When loading a plug-in document (i.e. a full page plug-in not embedded in 62 // When loading a plug-in document (i.e. a full page plug-in not embedded in
61 // another page), we save all data that has been received, and replay it with 63 // another page), we save all data that has been received, and replay it with
62 // this method on the actual plug-in. 64 // this method on the actual plug-in.
63 void ReplayReceivedData(blink::WebPlugin* plugin); 65 void ReplayReceivedData(blink::WebPlugin* plugin);
64 66
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // This method is defined in WebPlugin as well as in WebFrameClient, but with 130 // This method is defined in WebPlugin as well as in WebFrameClient, but with
129 // different parameters. We only care about implementing the WebPlugin 131 // different parameters. We only care about implementing the WebPlugin
130 // version, so we implement this method and call the default in WebFrameClient 132 // version, so we implement this method and call the default in WebFrameClient
131 // (which does nothing) to correctly overload it. 133 // (which does nothing) to correctly overload it.
132 virtual void didReceiveResponse(blink::WebLocalFrame* frame, 134 virtual void didReceiveResponse(blink::WebLocalFrame* frame,
133 unsigned identifier, 135 unsigned identifier,
134 const blink::WebURLResponse& response); 136 const blink::WebURLResponse& response);
135 137
136 private: 138 private:
137 friend class base::DeleteHelper<WebViewPlugin>; 139 friend class base::DeleteHelper<WebViewPlugin>;
138 WebViewPlugin(Delegate* delegate, const WebPreferences& preferences); 140 WebViewPlugin(Delegate* delegate, const content::WebPreferences& preferences);
139 virtual ~WebViewPlugin(); 141 virtual ~WebViewPlugin();
140 142
141 // Manages its own lifetime. 143 // Manages its own lifetime.
142 Delegate* delegate_; 144 Delegate* delegate_;
143 145
144 blink::WebCursorInfo current_cursor_; 146 blink::WebCursorInfo current_cursor_;
145 147
146 // Owns us. 148 // Owns us.
147 blink::WebPluginContainer* container_; 149 blink::WebPluginContainer* container_;
148 150
149 // Owned by us, deleted via |close()|. 151 // Owned by us, deleted via |close()|.
150 blink::WebView* web_view_; 152 blink::WebView* web_view_;
151 153
152 // Owned by us, deleted via |close()|. 154 // Owned by us, deleted via |close()|.
153 blink::WebFrame* web_frame_; 155 blink::WebFrame* web_frame_;
154 gfx::Rect rect_; 156 gfx::Rect rect_;
155 157
156 blink::WebURLResponse response_; 158 blink::WebURLResponse response_;
157 std::list<std::string> data_; 159 std::list<std::string> data_;
158 bool finished_loading_; 160 bool finished_loading_;
159 scoped_ptr<blink::WebURLError> error_; 161 scoped_ptr<blink::WebURLError> error_;
160 blink::WebString old_title_; 162 blink::WebString old_title_;
161 bool focused_; 163 bool focused_;
162 }; 164 };
163 165
164 #endif // COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_ 166 #endif // COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698