Chromium Code Reviews| 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 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.
| |
| 17 BrowserPluginImpl* impl = static_cast<BrowserPluginImpl*>(browser_plugin); | |
| 18 instance_id_ = impl->instance_id(); | |
| 19 impl->AddObserver(this); | |
| 20 } | |
| 21 } | |
| 22 | |
| 23 BrowserPluginObserver::~BrowserPluginObserver() { | |
| 24 if (browser_plugin_) { | |
| 25 BrowserPluginImpl* impl = static_cast<BrowserPluginImpl*>(browser_plugin_); | |
| 26 impl->RemoveObserver(this); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 void BrowserPluginObserver::OnDestruct() { | |
| 31 delete this; | |
| 32 } | |
| 33 | |
| 34 bool BrowserPluginObserver::OnMessageReceived(const IPC::Message& message) { | |
| 35 return false; | |
| 36 } | |
| 37 | |
| 38 bool BrowserPluginObserver::Send(IPC::Message* message) { | |
| 39 if (browser_plugin_) | |
| 40 return browser_plugin_->Send(message); | |
| 41 | |
| 42 delete message; | |
| 43 return false; | |
| 44 } | |
| 45 | |
| 46 BrowserPlugin* BrowserPluginObserver::browser_plugin() const { | |
| 47 return browser_plugin_; | |
| 48 } | |
| 49 | |
| 50 void BrowserPluginObserver::BrowserPluginGone() { | |
| 51 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.
| |
| 52 } | |
| 53 | |
| 54 } // namespace content | |
| OLD | NEW |