OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/public/renderer/browser_plugin/browser_plugin_observer.h" |
| 6 |
| 7 #include "content/public/renderer/browser_plugin/browser_plugin.h" |
| 8 #include "content/renderer/browser_plugin/browser_plugin_impl.h" |
| 9 #include "ipc/ipc_message.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 BrowserPluginObserver::BrowserPluginObserver(BrowserPlugin* browser_plugin) |
| 14 : browser_plugin_(browser_plugin), |
| 15 instance_id_(0) { |
| 16 CHECK(browser_plugin); |
| 17 BrowserPluginImpl* impl = static_cast<BrowserPluginImpl*>(browser_plugin); |
| 18 instance_id_ = impl->instance_id(); |
| 19 impl->AddObserver(this); |
| 20 } |
| 21 |
| 22 BrowserPluginObserver::~BrowserPluginObserver() { |
| 23 if (browser_plugin_) { |
| 24 BrowserPluginImpl* impl = static_cast<BrowserPluginImpl*>(browser_plugin_); |
| 25 impl->RemoveObserver(this); |
| 26 } |
| 27 } |
| 28 |
| 29 void BrowserPluginObserver::OnDestruct() { |
| 30 delete this; |
| 31 } |
| 32 |
| 33 bool BrowserPluginObserver::OnMessageReceived(const IPC::Message& message) { |
| 34 return false; |
| 35 } |
| 36 |
| 37 bool BrowserPluginObserver::Send(IPC::Message* message) { |
| 38 if (browser_plugin_) |
| 39 return browser_plugin_->Send(message); |
| 40 |
| 41 delete message; |
| 42 return false; |
| 43 } |
| 44 |
| 45 BrowserPlugin* BrowserPluginObserver::browser_plugin() const { |
| 46 return browser_plugin_; |
| 47 } |
| 48 |
| 49 void BrowserPluginObserver::BrowserPluginGone() { |
| 50 browser_plugin_ = NULL; |
| 51 } |
| 52 |
| 53 } // namespace content |
OLD | NEW |