render_frame_observer.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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. 4 5#ifndef CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_ 6#define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_ 7 8#include "base/basictypes.h" 9#include "base/compiler_specific.h" 10#include "content/common/content_export.h" 11#include "ipc/ipc_listener.h" 12#include "ipc/ipc_sender.h" 13 14namespace blink { 15class WebFrame; 16struct WebURLError; 17} 18 19namespace content { 20 21class RendererPpapiHost; 22class RenderFrame; 23class RenderFrameImpl; 24 25// Base class for objects that want to filter incoming IPCs, and also get 26// notified of changes to the frame. 27class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener, 28 public IPC::Sender { 29 public: 30 // By default, observers will be deleted when the RenderFrame goes away. If 31 // they want to outlive it, they can override this function. 32 virtual void OnDestruct(); 33 34 // Called when a Pepper plugin is created. 35 virtual void DidCreatePepperPlugin(RendererPpapiHost* host) {} 36 37 // Called when a load is explicitly stopped by the user or browser. 38 virtual void OnStop() {} 39 40 // These match the Blink API notifications 41 virtual void DidCommitProvisionalLoad(bool is_new_navigation) {} 42 virtual void DidStartProvisionalLoad() {} 43 virtual void DidFailProvisionalLoad(const blink::WebURLError& error) {} 44 virtual void DidFinishLoad() {} 45 46 // IPC::Listener implementation. 47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 48 49 // IPC::Sender implementation. 50 virtual bool Send(IPC::Message* message) OVERRIDE; 51 52 RenderFrame* render_frame() const; 53 int routing_id() const { return routing_id_; } 54 55 protected: 56 explicit RenderFrameObserver(RenderFrame* render_frame); 57 virtual ~RenderFrameObserver(); 58 59 private: 60 friend class RenderFrameImpl; 61 62 // This is called by the RenderFrame when it's going away so that this object 63 // can null out its pointer. 64 void RenderFrameGone(); 65 66 RenderFrame* render_frame_; 67 // The routing ID of the associated RenderFrame. 68 int routing_id_; 69 70 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserver); 71}; 72 73} // namespace content 74 75#endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_ 76