Chromium Code Reviews| 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..c1fe73b4e8c5977ae66b9c8a627f8d4e19c76eba |
| --- /dev/null |
| +++ b/content/public/renderer/browser_plugin/browser_plugin_observer.cc |
| @@ -0,0 +1,54 @@ |
| +// 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) { |
| + if (browser_plugin) { |
|
sadrul
2013/01/09 15:21:54
Once a BPO is created, it doesn't look like |brows
Fady Samuel
2013/01/09 17:41:24
It should never be null. Changed to a CHECK.
|
| + 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; |
|
sadrul
2013/01/09 15:21:54
Or perhaps allow setting the |browser_plugin_| of
Fady Samuel
2013/01/09 17:41:24
I'd rather not, a BrowserPluginObserver can create
sadrul
2013/01/09 17:58:07
Sounds good.
|
| +} |
| + |
| +} // namespace content |