| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_RENDER_VIEW_OBSERVER_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_VIEW_OBSERVER_H_ |
| 6 #define CONTENT_RENDERER_RENDER_VIEW_OBSERVER_H_ | 6 #define CONTENT_RENDERER_RENDER_VIEW_OBSERVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
| 11 | 11 |
| 12 class RenderView; | 12 class RenderView; |
| 13 | 13 |
| 14 namespace WebKit { | 14 namespace WebKit { |
| 15 class WebFrame; | 15 class WebFrame; |
| 16 class WebMouseEvent; | 16 class WebMouseEvent; |
| 17 class WebString; |
| 18 class WebTextCheckingCompletion; |
| 17 struct WebURLError; | 19 struct WebURLError; |
| 18 } | 20 } |
| 19 | 21 |
| 20 // Base class for objects that want to filter incoming IPCs, and also get | 22 // Base class for objects that want to filter incoming IPCs, and also get |
| 21 // notified of changes to the frame. | 23 // notified of changes to the frame. |
| 22 class RenderViewObserver : public IPC::Channel::Listener, | 24 class RenderViewObserver : public IPC::Channel::Listener, |
| 23 public IPC::Message::Sender { | 25 public IPC::Message::Sender { |
| 24 public: | 26 public: |
| 25 // By default, observers will be deleted when the RenderView goes away. If | 27 // By default, observers will be deleted when the RenderView goes away. If |
| 26 // they want to outlive it, they can override this function. | 28 // they want to outlive it, they can override this function. |
| 27 virtual void OnDestruct(); | 29 virtual void OnDestruct(); |
| 28 | 30 |
| 29 // These match the WebKit API notifications. | 31 // These match the WebKit API notifications. |
| 30 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) {} | 32 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) {} |
| 31 virtual void DidFailLoad(WebKit::WebFrame* frame, | 33 virtual void DidFailLoad(WebKit::WebFrame* frame, |
| 32 const WebKit::WebURLError& error) {} | 34 const WebKit::WebURLError& error) {} |
| 33 virtual void DidFinishLoad(WebKit::WebFrame* frame) {} | 35 virtual void DidFinishLoad(WebKit::WebFrame* frame) {} |
| 34 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) {} | 36 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) {} |
| 35 virtual void DidFailProvisionalLoad(WebKit::WebFrame* frame, | 37 virtual void DidFailProvisionalLoad(WebKit::WebFrame* frame, |
| 36 const WebKit::WebURLError& error) {} | 38 const WebKit::WebURLError& error) {} |
| 37 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, | 39 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, |
| 38 bool is_new_navigation) {} | 40 bool is_new_navigation) {} |
| 39 virtual void FrameDetached(WebKit::WebFrame* frame) {} | 41 virtual void FrameDetached(WebKit::WebFrame* frame) {} |
| 40 virtual void FrameWillClose(WebKit::WebFrame* frame) {} | 42 virtual void FrameWillClose(WebKit::WebFrame* frame) {} |
| 41 | 43 |
| 44 virtual void printPage(WebKit::WebFrame* frame) {} |
| 45 virtual void RequestTextChecking( |
| 46 const WebKit::WebString& text, |
| 47 int document_tag, |
| 48 WebKit::WebTextCheckingCompletion* completion) {} |
| 49 |
| 42 // These match the RenderView methods below. | 50 // These match the RenderView methods below. |
| 43 virtual void FrameTranslated(WebKit::WebFrame* frame) {} | 51 virtual void FrameTranslated(WebKit::WebFrame* frame) {} |
| 44 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {} | 52 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {} |
| 45 virtual void PageCaptured(const string16& page_text) {} | 53 virtual void PageCaptured(const string16& page_text) {} |
| 46 | 54 |
| 47 protected: | 55 protected: |
| 48 RenderViewObserver(RenderView* render_view); | 56 explicit RenderViewObserver(RenderView* render_view); |
| 49 virtual ~RenderViewObserver(); | 57 virtual ~RenderViewObserver(); |
| 50 | 58 |
| 51 // IPC::Channel::Listener implementation. | 59 // IPC::Channel::Listener implementation. |
| 52 virtual bool OnMessageReceived(const IPC::Message& message); | 60 virtual bool OnMessageReceived(const IPC::Message& message); |
| 53 | 61 |
| 54 // IPC::Message::Sender implementation. | 62 // IPC::Message::Sender implementation. |
| 55 virtual bool Send(IPC::Message* message); | 63 virtual bool Send(IPC::Message* message); |
| 56 | 64 |
| 57 RenderView* render_view() { return render_view_; } | 65 RenderView* render_view() { return render_view_; } |
| 58 int routing_id() { return routing_id_; } | 66 int routing_id() { return routing_id_; } |
| 59 | 67 |
| 60 private: | 68 private: |
| 61 friend class RenderView; | 69 friend class RenderView; |
| 62 | 70 |
| 63 void set_render_view(RenderView* rv) { render_view_ = rv; } | 71 void set_render_view(RenderView* rv) { render_view_ = rv; } |
| 64 | 72 |
| 65 RenderView* render_view_; | 73 RenderView* render_view_; |
| 66 // The routing ID of the associated RenderView. | 74 // The routing ID of the associated RenderView. |
| 67 int routing_id_; | 75 int routing_id_; |
| 68 | 76 |
| 69 DISALLOW_COPY_AND_ASSIGN(RenderViewObserver); | 77 DISALLOW_COPY_AND_ASSIGN(RenderViewObserver); |
| 70 }; | 78 }; |
| 71 | 79 |
| 72 #endif // CONTENT_RENDERER_RENDER_VIEW_OBSERVER_H_ | 80 #endif // CONTENT_RENDERER_RENDER_VIEW_OBSERVER_H_ |
| OLD | NEW |