Home | History | Annotate | Download | only in renderer
      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 
     14 namespace content {
     15 
     16 class RendererPpapiHost;
     17 class RenderFrame;
     18 class RenderFrameImpl;
     19 
     20 // Base class for objects that want to filter incoming IPCs, and also get
     21 // notified of changes to the frame.
     22 class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener,
     23                                            public IPC::Sender {
     24  public:
     25   // By default, observers will be deleted when the RenderFrame goes away.  If
     26   // they want to outlive it, they can override this function.
     27   virtual void OnDestruct();
     28 
     29   // Called when a Pepper plugin is created.
     30   virtual void DidCreatePepperPlugin(RendererPpapiHost* host) {}
     31 
     32   // IPC::Listener implementation.
     33   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
     34 
     35   // IPC::Sender implementation.
     36   virtual bool Send(IPC::Message* message) OVERRIDE;
     37 
     38   RenderFrame* render_frame() const;
     39   int routing_id() const { return routing_id_; }
     40 
     41  protected:
     42   explicit RenderFrameObserver(RenderFrame* render_frame);
     43   virtual ~RenderFrameObserver();
     44 
     45  private:
     46   friend class RenderFrameImpl;
     47 
     48   // This is called by the RenderFrame when it's going away so that this object
     49   // can null out its pointer.
     50   void RenderFrameGone();
     51 
     52   RenderFrame* render_frame_;
     53   // The routing ID of the associated RenderFrame.
     54   int routing_id_;
     55 
     56   DISALLOW_COPY_AND_ASSIGN(RenderFrameObserver);
     57 };
     58 
     59 }  // namespace content
     60 
     61 #endif  // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_OBSERVER_H_
     62