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

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

Issue 1124173008: Plugin Power Saver: Unthrottle dynamically sized plugins correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 namespace blink { 19 namespace blink {
20 class WebMouseEvent; 20 class WebMouseEvent;
21 } 21 }
22 22
23 namespace content { 23 namespace content {
24 class RenderView; 24 class RenderView;
25 struct WebPreferences; 25 struct WebPreferences;
26 } 26 }
27 27
28 namespace gfx {
29 class Size;
30 }
31
28 // This class implements the WebPlugin interface by forwarding drawing and 32 // This class implements the WebPlugin interface by forwarding drawing and
29 // handling input events to a WebView. 33 // handling input events to a WebView.
30 // It can be used as a placeholder for an actual plugin, using HTML for the UI. 34 // It can be used as a placeholder for an actual plugin, using HTML for the UI.
31 // To show HTML data inside the WebViewPlugin, 35 // To show HTML data inside the WebViewPlugin,
32 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake 36 // call web_view->mainFrame()->loadHTMLString() with the HTML data and a fake
33 // chrome:// URL as origin. 37 // chrome:// URL as origin.
34 38
35 class WebViewPlugin : public blink::WebPlugin, 39 class WebViewPlugin : public blink::WebPlugin,
36 public blink::WebViewClient, 40 public blink::WebViewClient,
37 public blink::WebFrameClient { 41 public blink::WebFrameClient {
38 public: 42 public:
39 class Delegate { 43 class Delegate {
40 public: 44 public:
41 // Bind |frame| to a Javascript object, enabling the delegate to receive 45 // Bind |frame| to a Javascript object, enabling the delegate to receive
42 // callback methods from Javascript inside the WebFrame. 46 // callback methods from Javascript inside the WebFrame.
43 // This method is called from WebFrameClient::didClearWindowObject. 47 // This method is called from WebFrameClient::didClearWindowObject.
44 virtual void BindWebFrame(blink::WebFrame* frame) = 0; 48 virtual void BindWebFrame(blink::WebFrame* frame) = 0;
45 49
46 // Called upon a context menu event. 50 // Called upon a context menu event.
47 virtual void ShowContextMenu(const blink::WebMouseEvent&) = 0; 51 virtual void ShowContextMenu(const blink::WebMouseEvent&) = 0;
48 52
49 // Called when the WebViewPlugin is destroyed. 53 // Called when the WebViewPlugin is destroyed.
50 virtual void PluginDestroyed() = 0; 54 virtual void PluginDestroyed() = 0;
51 55
52 // Called to enable JavaScript pass-through to a throttled plugin, which is 56 // Called to enable JavaScript pass-through to a throttled plugin, which is
53 // loaded but idle. Doesn't work for blocked plugins, which is not loaded. 57 // loaded but idle. Doesn't work for blocked plugins, which is not loaded.
54 virtual v8::Local<v8::Object> GetV8ScriptableObject(v8::Isolate*) const = 0; 58 virtual v8::Local<v8::Object> GetV8ScriptableObject(v8::Isolate*) const = 0;
59
60 // Called when the unobscured size of the plugin is updated.
61 virtual void OnUnobscuredSizeUpdate(const gfx::Size& unobscured_size) {}
55 }; 62 };
56 63
57 // Convenience method to set up a new WebViewPlugin using |preferences| 64 // Convenience method to set up a new WebViewPlugin using |preferences|
58 // and displaying |html_data|. |url| should be a (fake) data:text/html URL; 65 // and displaying |html_data|. |url| should be a (fake) data:text/html URL;
59 // it is only used for navigation and never actually resolved. 66 // it is only used for navigation and never actually resolved.
60 static WebViewPlugin* Create(Delegate* delegate, 67 static WebViewPlugin* Create(Delegate* delegate,
61 const content::WebPreferences& preferences, 68 const content::WebPreferences& preferences,
62 const std::string& html_data, 69 const std::string& html_data,
63 const GURL& url); 70 const GURL& url);
64 71
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 170
164 blink::WebURLResponse response_; 171 blink::WebURLResponse response_;
165 std::list<std::string> data_; 172 std::list<std::string> data_;
166 bool finished_loading_; 173 bool finished_loading_;
167 scoped_ptr<blink::WebURLError> error_; 174 scoped_ptr<blink::WebURLError> error_;
168 blink::WebString old_title_; 175 blink::WebString old_title_;
169 bool focused_; 176 bool focused_;
170 }; 177 };
171 178
172 #endif // COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_ 179 #endif // COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_
OLDNEW
« no previous file with comments | « components/plugins/renderer/loadable_plugin_placeholder.cc ('k') | components/plugins/renderer/webview_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698