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.
5 #include "content/public/browser/render_view_host_observer.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h"
11 RenderViewHostObserver::RenderViewHostObserver(RenderViewHost
* render_view_host
)
12 : render_view_host_(static_cast<RenderViewHostImpl
*>(render_view_host
)),
13 routing_id_(render_view_host_
->GetRoutingID()) {
14 render_view_host_
->AddObserver(this);
17 RenderViewHostObserver::~RenderViewHostObserver() {
18 if (render_view_host_
)
19 render_view_host_
->RemoveObserver(this);
22 void RenderViewHostObserver::RenderViewHostInitialized() {
25 void RenderViewHostObserver::RenderViewHostDestroyed(RenderViewHost
* rvh
) {
29 void RenderViewHostObserver::Navigate(const GURL
& url
) {
32 bool RenderViewHostObserver::OnMessageReceived(const IPC::Message
& message
) {
36 bool RenderViewHostObserver::Send(IPC::Message
* message
) {
37 if (!render_view_host_
) {
42 return render_view_host_
->Send(message
);
45 RenderViewHost
* RenderViewHostObserver::render_view_host() const {
46 return render_view_host_
;
49 void RenderViewHostObserver::RenderViewHostDestruction() {
50 render_view_host_
->RemoveObserver(this);
51 RenderViewHost
* rvh
= render_view_host_
;
52 render_view_host_
= NULL
;
53 RenderViewHostDestroyed(rvh
);
56 } // namespace content