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

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: Merge with ToT 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 87%
rename from content/renderer/browser_plugin/browser_plugin.h
rename to content/renderer/browser_plugin/browser_plugin_impl.h
index 14ea94980377ea2fb35fd82578198be17797745c..a0973445bc987a122c9aff0615ecf6a527f390ac 100644
--- a/content/renderer/browser_plugin/browser_plugin.h
+++ b/content/renderer/browser_plugin/browser_plugin_impl.h
@@ -2,23 +2,24 @@
// 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/common/browser_plugin_message_enums.h"
+#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;
@@ -29,27 +30,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.
@@ -139,6 +131,28 @@ class CONTENT_EXPORT BrowserPlugin :
void OnEmbedderDecidedPermission(int request_id, bool allow);
+ // BrowserPlugin implementation.
+ virtual RenderView* GetRenderView() const OVERRIDE;
+ virtual WebKit::WebPluginContainer* GetContainer() const OVERRIDE;
+ virtual void AddMethodBinding(
+ BrowserPluginMethodBinding* method_binding) OVERRIDE;
+ virtual void AddPropertyBinding(
+ BrowserPluginPropertyBinding* method_binding) 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;
@@ -178,26 +192,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(); }
@@ -221,11 +241,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,
@@ -299,6 +314,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);
@@ -371,7 +387,7 @@ class CONTENT_EXPORT BrowserPlugin :
PendingPermissionRequests;
PendingPermissionRequests pending_permission_requests_;
- typedef std::pair<int, base::WeakPtr<BrowserPlugin> >
+ typedef std::pair<int, base::WeakPtr<BrowserPluginImpl> >
AliveV8PermissionRequestItem;
std::map<int, AliveV8PermissionRequestItem*>
alive_v8_permission_request_objects_;
@@ -381,6 +397,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
@@ -400,11 +419,11 @@ class CONTENT_EXPORT BrowserPlugin :
// Weak factory used in v8 |MakeWeak| callback, since the v8 callback might
// get called after BrowserPlugin has been destroyed.
- base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_;
+ base::WeakPtrFactory<BrowserPluginImpl> weak_ptr_factory_;
- 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_
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin_browsertest.cc ('k') | content/renderer/browser_plugin/browser_plugin_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698