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 { | |
Charlie Reis
2012/08/01 23:20:51
I'm not familiar with plugin classes, but I notice
Fady Samuel
2012/08/02 18:32:47
Pepper does the same thing: see webkit/plugins/ppa
Charlie Reis
2012/08/03 18:06:02
Agreed. Talked with Darin and this is just how pl
| |
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 void UpdateRect(int message_id, | |
38 const BrowserPluginMsg_UpdateRect_Params& params); | |
39 // Inform the BrowserPlugin that its guest has crashed. | |
40 void GuestCrashed(); | |
41 // Indicates whether there are any Javascript listeners attached to a | |
42 // provided event_name. | |
43 bool HasListeners(const std::string& event_name); | |
44 // Informs the BrowserPlugin that the guest has navigated to a new URL. | |
45 void UpdateURL(const GURL& url); | |
Charlie Reis
2012/08/01 23:20:51
I think I'm partly confused by this because it mat
Fady Samuel
2012/08/02 18:32:47
Yes, that would be far less confusing. Done.
| |
46 // Tells the BrowserPlugin to advance the focus to the next (or previous) | |
47 // element. | |
48 void AdvanceFocus(bool reverse); | |
49 // Tell the BrowserPlugin to send out a postMessage to its guest. | |
50 void PostMessage(const string16& message, | |
51 const string16& target_origin); | |
52 // Add a custom event listener to this BrowserPlugin instance. | |
53 bool AddEventListener(const std::string& event_name, | |
54 v8::Local<v8::Function> function); | |
Charlie Reis
2012/08/01 23:20:51
I'm surprised to see a V8 dependency here. Maybe
Fady Samuel
2012/08/02 18:32:47
I honestly don't know :P Pepper does much of the s
Charlie Reis
2012/08/03 18:06:02
Ok, don't worry about it.
| |
55 // Add a custom event listener from this BrowserPlugin instance. | |
Charlie Reis
2012/08/01 23:20:51
s/Add/Remove/
Fady Samuel
2012/08/02 18:32:47
Done.
| |
56 bool RemoveEventListener(const std::string& event_name, | |
57 v8::Local<v8::Function> function); | |
58 // WebKit::WebPlugin implementation. | |
Charlie Reis
2012/08/01 23:20:51
Please use blank lines between unrelated declarati
Fady Samuel
2012/08/02 18:32:47
Done.
| |
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 BrowserPlugin( | |
Charlie Reis
2012/08/01 23:20:51
Please clarify what these parameters refer to. Em
Fady Samuel
2012/08/02 18:32:47
Done.
| |
100 int id, | |
101 RenderViewImpl* render_view, | |
102 int routing_id, | |
103 WebKit::WebFrame* frame, | |
104 const WebKit::WebPluginParams& params); | |
105 | |
106 virtual ~BrowserPlugin(); | |
107 | |
108 int width() const { return plugin_rect_.width(); } | |
109 int height() const { return plugin_rect_.height(); } | |
110 | |
111 // Parses the source URL of the browser plugin from the element's attributes | |
112 // and outputs them. | |
113 void ParseSrcAttribute(const WebKit::WebPluginParams& params, | |
114 std::string* src); | |
115 | |
116 virtual TransportDIB* CreateTransportDIB(size_t size); | |
117 virtual void FreeTransportDIB(TransportDIB* dib); | |
118 | |
119 void RemoveEventListeners(); | |
120 | |
121 int instance_id_; | |
122 RenderViewImpl* render_view_; | |
123 int routing_id_; | |
124 WebKit::WebPluginContainer* container_; | |
125 scoped_ptr<BrowserPluginBindings> bindings_; | |
126 scoped_ptr<BrowserPluginBackingStore> backing_store_; | |
127 TransportDIB* damage_buffer_; | |
128 gfx::Rect plugin_rect_; | |
129 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | |
130 SkBitmap* sad_guest_; | |
131 bool guest_crashed_; | |
132 bool resize_pending_; | |
133 long long parent_frame_; | |
134 std::string src_; | |
135 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; | |
136 typedef std::map<std::string, EventListeners> EventListenerMap; | |
137 EventListenerMap event_listener_map_; | |
138 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | |
139 }; | |
140 | |
141 } // namespace browser_plugin | |
142 } // namespace content | |
143 | |
144 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_H_ | |
OLD | NEW |