Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / renderer / render_frame_observer.cc
blob19d77d01f0e0aeed354beff38cf40dbd708a1d6c
1 // Copyright 2013 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.
5 #include "content/public/renderer/render_frame_observer.h"
7 #include "content/renderer/render_frame_impl.h"
9 using blink::WebFrame;
11 namespace content {
13 RenderFrameObserver::RenderFrameObserver(RenderFrame* render_frame)
14 : render_frame_(render_frame),
15 routing_id_(MSG_ROUTING_NONE) {
16 // |render_frame| can be NULL on unit testing.
17 if (render_frame) {
18 RenderFrameImpl* impl = static_cast<RenderFrameImpl*>(render_frame);
19 routing_id_ = impl->GetRoutingID();
20 DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
21 impl->AddObserver(this);
25 RenderFrameObserver::~RenderFrameObserver() {
26 if (render_frame_) {
27 RenderFrameImpl* impl = static_cast<RenderFrameImpl*>(render_frame_);
28 impl->RemoveObserver(this);
32 void RenderFrameObserver::OnDestruct() {
33 delete this;
36 bool RenderFrameObserver::OnMessageReceived(const IPC::Message& message) {
37 return false;
40 bool RenderFrameObserver::Send(IPC::Message* message) {
41 if (render_frame_)
42 return render_frame_->Send(message);
44 delete message;
45 return false;
48 RenderFrame* RenderFrameObserver::render_frame() const {
49 return render_frame_;
52 void RenderFrameObserver::RenderFrameGone() {
53 render_frame_ = NULL;
56 } // namespace content