OLD | NEW |
---|---|
(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 // Inform the BrowserPlugin to update its backing store with the pixels in | |
36 // its damage buffer. | |
37 | |
Charlie Reis
2012/08/03 18:06:02
This blank line should be above the comment. :)
Fady Samuel
2012/08/03 19:34:43
This is fixed already :-)
| |
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 // Tell the BrowserPlugin to send out a postMessage to its guest. | |
48 void PostMessage(const string16& message, | |
49 const string16& target_origin); | |
50 | |
51 // Indicates whether there are any Javascript listeners attached to a | |
52 // provided event_name. | |
53 bool HasListeners(const std::string& event_name); | |
54 // Add a custom event listener to this BrowserPlugin instance. | |
55 bool AddEventListener(const std::string& event_name, | |
56 v8::Local<v8::Function> function); | |
57 // Remove a custom event listener from this BrowserPlugin instance. | |
58 bool RemoveEventListener(const std::string& event_name, | |
59 v8::Local<v8::Function> function); | |
60 | |
61 // WebKit::WebPlugin implementation. | |
62 virtual WebKit::WebPluginContainer* container() const OVERRIDE; | |
63 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; | |
64 virtual void destroy() OVERRIDE; | |
65 virtual NPObject* scriptableObject() OVERRIDE; | |
66 virtual bool supportsKeyboardFocus() const OVERRIDE; | |
67 virtual void paint( | |
68 WebKit::WebCanvas* canvas, | |
69 const WebKit::WebRect& rect) OVERRIDE; | |
70 virtual void updateGeometry( | |
71 const WebKit::WebRect& frame_rect, | |
72 const WebKit::WebRect& clip_rect, | |
73 const WebKit::WebVector<WebKit::WebRect>& cut_outs_rects, | |
74 bool is_visible) OVERRIDE; | |
75 virtual void updateFocus(bool focused) OVERRIDE; | |
76 virtual void updateVisibility(bool visible) OVERRIDE; | |
77 virtual bool acceptsInputEvents() OVERRIDE; | |
78 virtual bool handleInputEvent( | |
79 const WebKit::WebInputEvent& event, | |
80 WebKit::WebCursorInfo& cursor_info) OVERRIDE; | |
81 virtual void didReceiveResponse( | |
82 const WebKit::WebURLResponse& response) OVERRIDE; | |
83 virtual void didReceiveData(const char* data, int data_length) OVERRIDE; | |
84 virtual void didFinishLoading() OVERRIDE; | |
85 virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE; | |
86 virtual void didFinishLoadingFrameRequest( | |
87 const WebKit::WebURL& url, | |
88 void* notify_data) OVERRIDE; | |
89 virtual void didFailLoadingFrameRequest( | |
90 const WebKit::WebURL& url, | |
91 void* notify_data, | |
92 const WebKit::WebURLError& error) OVERRIDE; | |
93 protected: | |
94 friend class base::DeleteHelper<BrowserPlugin>; | |
95 // Only the manager is allowed to create a BrowserPlugin. | |
96 friend class BrowserPluginManagerImpl; | |
97 friend class MockBrowserPluginManager; | |
98 | |
99 // For unit/integration tests. | |
100 friend class MockBrowserPlugin; | |
101 | |
102 // A BrowserPlugin object is a controller that represents an instance of a | |
103 // browser plugin within the embedder renderer process. Each BrowserPlugin | |
104 // within a process has a unique instance_id that is used to route messages | |
105 // to it. It takes in a RenderViewImpl that it's associated with along | |
106 // with the frame within which it lives and the initial attributes assigned | |
107 // to it on creation. | |
Charlie Reis
2012/08/03 18:06:02
Much better. Whose routing_id is passed in, thoug
Fady Samuel
2012/08/03 19:34:43
This routing_id is completely unnecessary. It orig
| |
108 BrowserPlugin( | |
109 int instance_id, | |
110 RenderViewImpl* render_view, | |
111 int routing_id, | |
112 WebKit::WebFrame* frame, | |
113 const WebKit::WebPluginParams& params); | |
114 | |
115 virtual ~BrowserPlugin(); | |
116 | |
117 int width() const { return plugin_rect_.width(); } | |
118 int height() const { return plugin_rect_.height(); } | |
119 | |
120 // Parses the source URL of the browser plugin from the element's attributes | |
121 // and outputs them. | |
122 bool ParseSrcAttribute(const WebKit::WebPluginParams& params, | |
123 std::string* src); | |
124 | |
125 // Cleanup event listener state to free v8 resources when a BrowserPlugin | |
126 // is destroyed. | |
127 void RemoveEventListeners(); | |
128 | |
129 int instance_id_; | |
130 RenderViewImpl* render_view_; | |
131 int routing_id_; | |
132 WebKit::WebPluginContainer* container_; | |
133 scoped_ptr<BrowserPluginBindings> bindings_; | |
134 scoped_ptr<BrowserPluginBackingStore> backing_store_; | |
135 TransportDIB* damage_buffer_; | |
136 gfx::Rect plugin_rect_; | |
137 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | |
138 SkBitmap* sad_guest_; | |
139 bool guest_crashed_; | |
140 bool resize_pending_; | |
141 long long parent_frame_; | |
142 std::string src_; | |
143 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; | |
144 typedef std::map<std::string, EventListeners> EventListenerMap; | |
145 EventListenerMap event_listener_map_; | |
146 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | |
147 }; | |
148 | |
149 } // namespace browser_plugin | |
150 } // namespace content | |
151 | |
152 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_H_ | |
OLD | NEW |