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

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: Initialize content shell resources 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_BROWSER_PLUGIN_H_
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_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
20 class BrowserPluginManager;
21 class MockBrowserPlugin;
22
23 class CONTENT_EXPORT BrowserPlugin :
24 NON_EXPORTED_BASE(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 void paint(
64 WebKit::WebCanvas* canvas,
65 const WebKit::WebRect& rect) OVERRIDE;
66 virtual void updateGeometry(
67 const WebKit::WebRect& frame_rect,
68 const WebKit::WebRect& clip_rect,
69 const WebKit::WebVector<WebKit::WebRect>& cut_outs_rects,
70 bool is_visible) OVERRIDE;
71 virtual void updateFocus(bool focused) OVERRIDE;
72 virtual void updateVisibility(bool visible) OVERRIDE;
73 virtual bool acceptsInputEvents() OVERRIDE;
74 virtual bool handleInputEvent(
75 const WebKit::WebInputEvent& event,
76 WebKit::WebCursorInfo& cursor_info) OVERRIDE;
77 virtual void didReceiveResponse(
78 const WebKit::WebURLResponse& response) OVERRIDE;
79 virtual void didReceiveData(const char* data, int data_length) OVERRIDE;
80 virtual void didFinishLoading() OVERRIDE;
81 virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE;
82 virtual void didFinishLoadingFrameRequest(
83 const WebKit::WebURL& url,
84 void* notify_data) OVERRIDE;
85 virtual void didFailLoadingFrameRequest(
86 const WebKit::WebURL& url,
87 void* notify_data,
88 const WebKit::WebURLError& error) OVERRIDE;
89 protected:
90 friend class base::DeleteHelper<BrowserPlugin>;
91 // Only the manager is allowed to create a BrowserPlugin.
92 friend class BrowserPluginManagerImpl;
93 friend class MockBrowserPluginManager;
94
95 // For unit/integration tests.
96 friend class MockBrowserPlugin;
97
98 // A BrowserPlugin object is a controller that represents an instance of a
99 // browser plugin within the embedder renderer process. Each BrowserPlugin
100 // within a process has a unique instance_id that is used to route messages
101 // to it. It takes in a RenderViewImpl that it's associated with along
102 // with the frame within which it lives and the initial attributes assigned
103 // to it on creation.
104 BrowserPlugin(
105 int instance_id,
106 RenderViewImpl* render_view,
107 WebKit::WebFrame* frame,
108 const WebKit::WebPluginParams& params);
109
110 virtual ~BrowserPlugin();
111
112 int width() const { return plugin_rect_.width(); }
113 int height() const { return plugin_rect_.height(); }
114
115 // Virtual to allow for mocking in tests.
116 virtual float GetDeviceScaleFactor() const;
117
118 // Parses the source URL of the browser plugin from the element's attributes
119 // and outputs them.
120 bool ParseSrcAttribute(const WebKit::WebPluginParams& params,
121 std::string* src);
122
123 // Cleanup event listener state to free v8 resources when a BrowserPlugin
124 // is destroyed.
125 void RemoveEventListeners();
126
127 int instance_id_;
128 RenderViewImpl* render_view_;
129 WebKit::WebPluginContainer* container_;
130 scoped_ptr<BrowserPluginBindings> bindings_;
131 scoped_ptr<BrowserPluginBackingStore> backing_store_;
132 TransportDIB* damage_buffer_;
133 gfx::Rect plugin_rect_;
134 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer.
135 SkBitmap* sad_guest_;
136 bool guest_crashed_;
137 bool resize_pending_;
138 long long parent_frame_;
139 std::string src_;
140 typedef std::vector<v8::Persistent<v8::Function> > EventListeners;
141 typedef std::map<std::string, EventListeners> EventListenerMap;
142 EventListenerMap event_listener_map_;
143 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
144 };
145
146 } // namespace content
147
148 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
OLDNEW
« no previous file with comments | « content/public/common/content_constants.cc ('k') | content/renderer/browser_plugin/browser_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698