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

Unified Diff: content/public/renderer/browser_plugin/browser_plugin_observer.cc

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/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..219ed49a5f9068e98dc882fd59c530c566b088f6
--- /dev/null
+++ b/content/public/renderer/browser_plugin/browser_plugin_observer.cc
@@ -0,0 +1,51 @@
+// 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) {
+ CHECK(browser_plugin);
+ BrowserPluginImpl* impl = static_cast<BrowserPluginImpl*>(browser_plugin);
+ 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

Powered by Google App Engine
This is Rietveld 408576698