Index: content/public/renderer/browser_plugin/browser_plugin_observer.cc |
diff --git a/content/public/renderer/browser_plugin/browser_plugin_observer.cc b/content/public/renderer/browser_plugin/browser_plugin_observer.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9422dab9bf64676cae5ed5fbac0fd2cea548c595 |
--- /dev/null |
+++ b/content/public/renderer/browser_plugin/browser_plugin_observer.cc |
@@ -0,0 +1,53 @@ |
+// 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. |
+ |
+#include "content/public/renderer/browser_plugin/browser_plugin_observer.h" |
+ |
+#include "content/public/renderer/browser_plugin/browser_plugin.h" |
+#include "content/renderer/browser_plugin/browser_plugin_impl.h" |
+#include "ipc/ipc_message.h" |
+ |
+namespace content { |
+ |
+BrowserPluginObserver::BrowserPluginObserver(BrowserPlugin* browser_plugin) |
+ : browser_plugin_(browser_plugin), |
+ instance_id_(0) { |
+ CHECK(browser_plugin); |
+ BrowserPluginImpl* impl = static_cast<BrowserPluginImpl*>(browser_plugin); |
+ instance_id_ = impl->instance_id(); |
+ impl->AddObserver(this); |
+} |
+ |
+BrowserPluginObserver::~BrowserPluginObserver() { |
+ if (browser_plugin_) { |
+ BrowserPluginImpl* impl = static_cast<BrowserPluginImpl*>(browser_plugin_); |
+ impl->RemoveObserver(this); |
+ } |
+} |
+ |
+void BrowserPluginObserver::OnDestruct() { |
+ delete this; |
+} |
+ |
+bool BrowserPluginObserver::OnMessageReceived(const IPC::Message& message) { |
+ return false; |
+} |
+ |
+bool BrowserPluginObserver::Send(IPC::Message* message) { |
+ if (browser_plugin_) |
+ return browser_plugin_->Send(message); |
+ |
+ delete message; |
+ return false; |
+} |
+ |
+BrowserPlugin* BrowserPluginObserver::browser_plugin() const { |
+ return browser_plugin_; |
+} |
+ |
+void BrowserPluginObserver::BrowserPluginGone() { |
+ browser_plugin_ = NULL; |
+} |
+ |
+} // namespace content |