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

Unified 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 leaky Persistents in BrowserPlugin Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/browser_plugin/browser_plugin.h
diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h
new file mode 100644
index 0000000000000000000000000000000000000000..8da92599649ffb97206190aad4f623daedf47380
--- /dev/null
+++ b/content/renderer/browser_plugin/browser_plugin.h
@@ -0,0 +1,144 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_H_
+#define CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_H_
+
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/sequenced_task_runner_helpers.h"
+#include "content/renderer/browser_plugin/browser_plugin_backing_store.h"
+#include "content/renderer/browser_plugin/browser_plugin_bindings.h"
+#include "content/renderer/render_view_impl.h"
+
+struct BrowserPluginMsg_UpdateRect_Params;
+
+namespace content {
+namespace browser_plugin {
+
+class BrowserPluginManager;
+class MockBrowserPlugin;
+
+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
+ public:
+ // Called only by tests to clean up before we blow away the MockRenderProcess.
+ void Cleanup();
+
+ // Get the src attribute value of the BrowserPlugin instance if the guest
+ // has not crashed.
+ std::string GetSrcAttribute() const;
+ // Set the src attribute value of the BrowserPlugin instance and reset
+ // the guest_crashed_ flag.
+ void SetSrcAttribute(const std::string& src);
+ // Inform the BrowserPlugin to update its backing store with the pixels in
+ // its damage buffer.
+ void UpdateRect(int message_id,
+ const BrowserPluginMsg_UpdateRect_Params& params);
+ // Inform the BrowserPlugin that its guest has crashed.
+ void GuestCrashed();
+ // Indicates whether there are any Javascript listeners attached to a
+ // provided event_name.
+ bool HasListeners(const std::string& event_name);
+ // Informs the BrowserPlugin that the guest has navigated to a new URL.
+ 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.
+ // Tells the BrowserPlugin to advance the focus to the next (or previous)
+ // element.
+ void AdvanceFocus(bool reverse);
+ // Tell the BrowserPlugin to send out a postMessage to its guest.
+ void PostMessage(const string16& message,
+ const string16& target_origin);
+ // Add a custom event listener to this BrowserPlugin instance.
+ bool AddEventListener(const std::string& event_name,
+ 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.
+ // 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.
+ bool RemoveEventListener(const std::string& event_name,
+ v8::Local<v8::Function> function);
+ // 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.
+ virtual WebKit::WebPluginContainer* container() const OVERRIDE;
+ virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE;
+ virtual void destroy() OVERRIDE;
+ virtual NPObject* scriptableObject() OVERRIDE;
+ virtual bool supportsKeyboardFocus() const OVERRIDE;
+ virtual void paint(
+ WebKit::WebCanvas* canvas,
+ const WebKit::WebRect& rect) OVERRIDE;
+ virtual void updateGeometry(
+ const WebKit::WebRect& frame_rect,
+ const WebKit::WebRect& clip_rect,
+ const WebKit::WebVector<WebKit::WebRect>& cut_outs_rects,
+ bool is_visible) OVERRIDE;
+ virtual void updateFocus(bool focused) OVERRIDE;
+ virtual void updateVisibility(bool visible) OVERRIDE;
+ virtual bool acceptsInputEvents() OVERRIDE;
+ virtual bool handleInputEvent(
+ const WebKit::WebInputEvent& event,
+ WebKit::WebCursorInfo& cursor_info) OVERRIDE;
+ virtual void didReceiveResponse(
+ const WebKit::WebURLResponse& response) OVERRIDE;
+ virtual void didReceiveData(const char* data, int data_length) OVERRIDE;
+ virtual void didFinishLoading() OVERRIDE;
+ virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE;
+ virtual void didFinishLoadingFrameRequest(
+ const WebKit::WebURL& url,
+ void* notify_data) OVERRIDE;
+ virtual void didFailLoadingFrameRequest(
+ const WebKit::WebURL& url,
+ void* notify_data,
+ const WebKit::WebURLError& error) OVERRIDE;
+ protected:
+ friend class base::DeleteHelper<BrowserPlugin>;
+ // Only the manager is allowed to create a BrowserPlugin.
+ friend class BrowserPluginManagerImpl;
+ friend class MockBrowserPluginManager;
+
+ // For unit/integration tests.
+ friend class MockBrowserPlugin;
+
+ 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.
+ int id,
+ RenderViewImpl* render_view,
+ int routing_id,
+ WebKit::WebFrame* frame,
+ const WebKit::WebPluginParams& params);
+
+ virtual ~BrowserPlugin();
+
+ int width() const { return plugin_rect_.width(); }
+ int height() const { return plugin_rect_.height(); }
+
+ // Parses the source URL of the browser plugin from the element's attributes
+ // and outputs them.
+ void ParseSrcAttribute(const WebKit::WebPluginParams& params,
+ std::string* src);
+
+ virtual TransportDIB* CreateTransportDIB(size_t size);
+ virtual void FreeTransportDIB(TransportDIB* dib);
+
+ void RemoveEventListeners();
+
+ int instance_id_;
+ RenderViewImpl* render_view_;
+ int routing_id_;
+ WebKit::WebPluginContainer* container_;
+ scoped_ptr<BrowserPluginBindings> bindings_;
+ scoped_ptr<BrowserPluginBackingStore> backing_store_;
+ TransportDIB* damage_buffer_;
+ gfx::Rect plugin_rect_;
+ // Bitmap for crashed plugin. Lazily initialized, non-owning pointer.
+ SkBitmap* sad_guest_;
+ bool guest_crashed_;
+ bool resize_pending_;
+ long long parent_frame_;
+ std::string src_;
+ typedef std::vector<v8::Persistent<v8::Function> > EventListeners;
+ typedef std::map<std::string, EventListeners> EventListenerMap;
+ EventListenerMap event_listener_map_;
+ DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
+};
+
+} // namespace browser_plugin
+} // namespace content
+
+#endif // CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_H_

Powered by Google App Engine
This is Rietveld 408576698