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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.h

Issue 10830072: Browser Plugin: New Implementation (Renderer Side) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed according to comments by creis@. Moved postMessage stuff out for another cl Created 8 years, 4 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
(Empty)
1 // Copyright (c) 2012 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 CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_H_
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_H_
7
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/sequenced_task_runner_helpers.h"
12 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h"
13 #include "content/renderer/browser_plugin/browser_plugin_bindings.h"
14 #include "content/renderer/render_view_impl.h"
15
16 struct BrowserPluginMsg_UpdateRect_Params;
17
18 namespace content {
19 namespace browser_plugin {
20
21 class BrowserPluginManager;
22 class MockBrowserPlugin;
23
24 class CONTENT_EXPORT BrowserPlugin : public WebKit::WebPlugin {
25 public:
26 // Called only by tests to clean up before we blow away the MockRenderProcess.
27 void Cleanup();
28
29 // Get the src attribute value of the BrowserPlugin instance if the guest
30 // has not crashed.
31 std::string GetSrcAttribute() const;
32 // Set the src attribute value of the BrowserPlugin instance and reset
33 // the guest_crashed_ flag.
34 void SetSrcAttribute(const std::string& src);
35
36 // Inform the BrowserPlugin to update its backing store with the pixels in
37 // its damage buffer.
38 void UpdateRect(int message_id,
39 const BrowserPluginMsg_UpdateRect_Params& params);
40 // Inform the BrowserPlugin that its guest has crashed.
41 void GuestCrashed();
42 // Informs the BrowserPlugin that the guest has navigated to a new URL.
43 void DidNavigate(const GURL& url);
44 // Tells the BrowserPlugin to advance the focus to the next (or previous)
45 // element.
46 void AdvanceFocus(bool reverse);
47
48 // Indicates whether there are any Javascript listeners attached to a
49 // provided event_name.
50 bool HasListeners(const std::string& event_name);
51 // Add a custom event listener to this BrowserPlugin instance.
52 bool AddEventListener(const std::string& event_name,
53 v8::Local<v8::Function> function);
54 // Remove a custom event listener from this BrowserPlugin instance.
55 bool RemoveEventListener(const std::string& event_name,
56 v8::Local<v8::Function> function);
57
58 // WebKit::WebPlugin implementation.
59 virtual WebKit::WebPluginContainer* container() const OVERRIDE;
60 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE;
61 virtual void destroy() OVERRIDE;
62 virtual NPObject* scriptableObject() OVERRIDE;
63 virtual bool supportsKeyboardFocus() const OVERRIDE;
64 virtual void paint(
65 WebKit::WebCanvas* canvas,
66 const WebKit::WebRect& rect) OVERRIDE;
67 virtual void updateGeometry(
68 const WebKit::WebRect& frame_rect,
69 const WebKit::WebRect& clip_rect,
70 const WebKit::WebVector<WebKit::WebRect>& cut_outs_rects,
71 bool is_visible) OVERRIDE;
72 virtual void updateFocus(bool focused) OVERRIDE;
73 virtual void updateVisibility(bool visible) OVERRIDE;
74 virtual bool acceptsInputEvents() OVERRIDE;
75 virtual bool handleInputEvent(
76 const WebKit::WebInputEvent& event,
77 WebKit::WebCursorInfo& cursor_info) OVERRIDE;
78 virtual void didReceiveResponse(
79 const WebKit::WebURLResponse& response) OVERRIDE;
80 virtual void didReceiveData(const char* data, int data_length) OVERRIDE;
81 virtual void didFinishLoading() OVERRIDE;
82 virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE;
83 virtual void didFinishLoadingFrameRequest(
84 const WebKit::WebURL& url,
85 void* notify_data) OVERRIDE;
86 virtual void didFailLoadingFrameRequest(
87 const WebKit::WebURL& url,
88 void* notify_data,
89 const WebKit::WebURLError& error) OVERRIDE;
90 protected:
91 friend class base::DeleteHelper<BrowserPlugin>;
92 // Only the manager is allowed to create a BrowserPlugin.
93 friend class BrowserPluginManagerImpl;
94 friend class MockBrowserPluginManager;
95
96 // For unit/integration tests.
97 friend class MockBrowserPlugin;
98
99 // A BrowserPlugin object is a controller that represents an instance of a
100 // browser plugin within the embedder renderer process. Each BrowserPlugin
101 // within a process has a unique instance_id that is used to route messages
102 // to it. It takes in a RenderViewImpl that it's associated with along
103 // with the frame within which it lives and the initial attributes assigned
104 // to it on creation.
105 BrowserPlugin(
106 int instance_id,
107 RenderViewImpl* render_view,
108 WebKit::WebFrame* frame,
109 const WebKit::WebPluginParams& params);
110
111 virtual ~BrowserPlugin();
112
113 int width() const { return plugin_rect_.width(); }
114 int height() const { return plugin_rect_.height(); }
115
116 // Virtual to allow for mocking in tests.
117 virtual float GetDeviceScaleFactor() const;
118
119 // Parses the source URL of the browser plugin from the element's attributes
120 // and outputs them.
121 bool ParseSrcAttribute(const WebKit::WebPluginParams& params,
122 std::string* src);
123
124 // Cleanup event listener state to free v8 resources when a BrowserPlugin
125 // is destroyed.
126 void RemoveEventListeners();
127
128 int instance_id_;
129 RenderViewImpl* render_view_;
130 WebKit::WebPluginContainer* container_;
131 scoped_ptr<BrowserPluginBindings> bindings_;
132 scoped_ptr<BrowserPluginBackingStore> backing_store_;
133 TransportDIB* damage_buffer_;
134 gfx::Rect plugin_rect_;
135 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer.
136 SkBitmap* sad_guest_;
137 bool guest_crashed_;
138 bool resize_pending_;
139 long long parent_frame_;
140 std::string src_;
141 typedef std::vector<v8::Persistent<v8::Function> > EventListeners;
142 typedef std::map<std::string, EventListeners> EventListenerMap;
143 EventListenerMap event_listener_map_;
144 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
145 };
146
147 } // namespace browser_plugin
148 } // namespace content
149
150 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698