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

Unified Diff: content/renderer/browser_plugin/browser_plugin_impl.h

Issue 11826005: Browser Plugin: Implement BrowserPluginObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up bindings API Created 7 years, 10 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_impl.h
diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin_impl.h
similarity index 86%
rename from content/renderer/browser_plugin/browser_plugin.h
rename to content/renderer/browser_plugin/browser_plugin_impl.h
index 3e63f1179496355fd8433c0fee9b282653eb6214..18a0032617553d6507907c58f702355153b36dbc 100644
--- a/content/renderer/browser_plugin/browser_plugin.h
+++ b/content/renderer/browser_plugin/browser_plugin_impl.h
@@ -2,22 +2,23 @@
// 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_BROWSER_PLUGIN_H_
-#define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
-
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
+#ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_IMPL_H_
+#define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_IMPL_H_
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
#include "base/process_util.h"
#include "base/sequenced_task_runner_helpers.h"
#if defined(OS_WIN)
#include "base/shared_memory.h"
#endif
+#include "content/public/renderer/browser_plugin/browser_plugin.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"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
struct BrowserPluginHostMsg_AutoSize_Params;
struct BrowserPluginHostMsg_ResizeGuest_Params;
@@ -28,27 +29,18 @@ namespace content {
class BrowserPluginCompositingHelper;
class BrowserPluginManager;
+class BrowserPluginObserver;
class MockBrowserPlugin;
-class CONTENT_EXPORT BrowserPlugin :
- NON_EXPORTED_BASE(public WebKit::WebPlugin) {
+class CONTENT_EXPORT BrowserPluginImpl :
+ NON_EXPORTED_BASE(public WebKit::WebPlugin),
+ public BrowserPlugin {
public:
RenderViewImpl* render_view() const { return render_view_.get(); }
int render_view_routing_id() const { return render_view_routing_id_; }
bool OnMessageReceived(const IPC::Message& msg);
- // Update Browser Plugin's DOM Node attribute |attribute_name| with the value
- // |attribute_value|.
- void UpdateDOMAttribute(const std::string& attribute_name,
- const std::string& attribute_value);
- // Remove the DOM Node attribute with the name |attribute_name|.
- void RemoveDOMAttribute(const std::string& attribute_name);
- // Get Browser Plugin's DOM Node attribute |attribute_name|'s value.
- std::string GetDOMAttributeValue(const std::string& attribute_name) const;
- // Checks if the attribute |attribute_name| exists in the DOM.
- bool HasDOMAttribute(const std::string& attribute_name) const;
-
// Get the name attribute value.
std::string GetNameAttribute() const;
// Parse the name attribute value.
@@ -129,6 +121,28 @@ class CONTENT_EXPORT BrowserPlugin :
gfx::Point ToLocalCoordinates(const gfx::Point& point) const;
+ // BrowserPlugin implementation.
+ virtual void AddMethodBinding(
+ BrowserPluginMethodBinding* method_binding) OVERRIDE;
+ virtual void AddPropertyBinding(
+ BrowserPluginPropertyBinding* method_binding) OVERRIDE;
+ virtual RenderView* GetRenderView() const OVERRIDE;
+ virtual WebKit::WebPluginContainer* GetContainer() const OVERRIDE;
+ virtual void TriggerEvent(
+ const std::string& event_name,
+ std::map<std::string, base::Value*>* props) OVERRIDE;
+ virtual void UpdateDOMAttribute(const std::string& attribute_name,
+ const std::string& attribute_value) OVERRIDE;
+ virtual void RemoveDOMAttribute(const std::string& attribute_name) OVERRIDE;
+ virtual std::string GetDOMAttributeValue(
+ const std::string& attribute_name) const OVERRIDE;
+ virtual bool HasDOMAttribute(
+ const std::string& attribute_name) const OVERRIDE;
+ virtual bool HasNavigated() const OVERRIDE;
+
+ // IPC::Sender implementation.
+ virtual bool Send(IPC::Message* message) OVERRIDE;
+
// WebKit::WebPlugin implementation.
virtual WebKit::WebPluginContainer* container() const OVERRIDE;
virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE;
@@ -168,26 +182,32 @@ class CONTENT_EXPORT BrowserPlugin :
void* notify_data,
const WebKit::WebURLError& error) OVERRIDE;
private:
- friend class base::DeleteHelper<BrowserPlugin>;
+ friend class base::DeleteHelper<BrowserPluginImpl>;
// Only the manager is allowed to create a BrowserPlugin.
friend class BrowserPluginManagerImpl;
+ friend class BrowserPluginObserver;
friend class MockBrowserPluginManager;
// For unit/integration tests.
friend class MockBrowserPlugin;
- // A BrowserPlugin object is a controller that represents an instance of a
+ // A BrowserPluginImpl object is a controller that represents an instance of a
// browser plugin within the embedder renderer process. Each BrowserPlugin
- // within a process has a unique instance_id that is used to route messages
+ // within a process has a unique |instance_id| that is used to route messages
// to it. It takes in a RenderViewImpl that it's associated with along
// with the frame within which it lives and the initial attributes assigned
// to it on creation.
- BrowserPlugin(
+ BrowserPluginImpl(
RenderViewImpl* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params);
- virtual ~BrowserPlugin();
+ virtual ~BrowserPluginImpl();
+
+ // Add and remove observers for filtering IPC messages. Clients must be sure
+ // to remove the observer before they go away.
+ void AddObserver(BrowserPluginObserver* observer);
+ void RemoveObserver(BrowserPluginObserver* observer);
int width() const { return plugin_rect_.width(); }
int height() const { return plugin_rect_.height(); }
@@ -211,11 +231,6 @@ class CONTENT_EXPORT BrowserPlugin :
// and sets them appropriately.
void ParseAttributes();
- // Triggers the event-listeners for |event_name|. Note that the function
- // frees all the values in |props|.
- void TriggerEvent(const std::string& event_name,
- std::map<std::string, base::Value*>* props);
-
// Creates and maps a shared damage buffer.
virtual base::SharedMemory* CreateDamageBuffer(
const size_t size,
@@ -267,6 +282,7 @@ class CONTENT_EXPORT BrowserPlugin :
std::string mailbox_name,
int gpu_route_id,
int gpu_host_id);
+ void OnForwardMessage(int instance_id, const IPC::Message& msg);
void OnGuestContentWindowReady(int instance_id,
int content_window_routing_id);
void OnGuestGone(int instance_id, int process_id, int status);
@@ -333,6 +349,9 @@ class CONTENT_EXPORT BrowserPlugin :
// avoid accessing the RenderViewImpl.
scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
+ // A list of observers that filter messages. Weak references.
+ ObserverList<BrowserPluginObserver> observers_;
+
// Important: Do not add more history state here.
// We strongly discourage storing additional history state (such as page IDs)
// in the embedder process, at the risk of having incorrect information that
@@ -350,9 +369,9 @@ class CONTENT_EXPORT BrowserPlugin :
bool compositing_enabled_;
scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_;
- DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginImpl);
};
} // namespace content
-#endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
+#endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698