OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 CHROME_RENDERER_RENDER_VIEW_OBSERVER_H_ |
| 6 #define CHROME_RENDERER_RENDER_VIEW_OBSERVER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "ipc/ipc_channel.h" |
| 11 |
| 12 class RenderView; |
| 13 |
| 14 namespace WebKit { |
| 15 class WebFrame; |
| 16 class WebMouseEvent; |
| 17 } |
| 18 |
| 19 // Base class for objects that want to filter incoming IPCs, and also get |
| 20 // notified of changes to the frame. |
| 21 class RenderViewObserver : public IPC::Channel::Listener, |
| 22 public IPC::Message::Sender { |
| 23 public: |
| 24 // By default, observers will be deleted when the RenderView goes away. If |
| 25 // they want to outlive it, they can override this function. |
| 26 virtual void OnDestruct(); |
| 27 |
| 28 // These match the WebKit API notifications. |
| 29 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) {} |
| 30 virtual void DidFinishLoad(WebKit::WebFrame* frame) {} |
| 31 virtual void FrameDetached(WebKit::WebFrame* frame) {} |
| 32 virtual void FrameWillClose(WebKit::WebFrame* frame) {} |
| 33 |
| 34 // These match the RenderView methods below. |
| 35 virtual void FrameTranslated(WebKit::WebFrame* frame) {} |
| 36 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {} |
| 37 |
| 38 protected: |
| 39 RenderViewObserver(RenderView* render_view); |
| 40 virtual ~RenderViewObserver(); |
| 41 |
| 42 // IPC::Channel::Listener implementation. |
| 43 virtual bool OnMessageReceived(const IPC::Message& message); |
| 44 |
| 45 // IPC::Message::Sender implementation. |
| 46 virtual bool Send(IPC::Message* message); |
| 47 |
| 48 RenderView* render_view() { return render_view_; } |
| 49 int routing_id() { return routing_id_; } |
| 50 |
| 51 private: |
| 52 friend class RenderView; |
| 53 |
| 54 void set_render_view(RenderView* rv) { render_view_ = rv; } |
| 55 |
| 56 RenderView* render_view_; |
| 57 // The routing ID of the associated RenderView. |
| 58 int routing_id_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(RenderViewObserver); |
| 61 }; |
| 62 |
| 63 #endif // CHROME_RENDERER_RENDER_VIEW_OBSERVER_H_ |
OLD | NEW |