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_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ |
7 | 7 |
8 #include "ipc/ipc_channel.h" | 8 #include "ipc/ipc_channel.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
10 | 10 |
| 11 class GURL; |
11 class RenderViewHost; | 12 class RenderViewHost; |
12 struct ViewMsg_Navigate_Params; | |
13 | 13 |
14 // An observer API implemented by classes which want to filter IPC messages from | 14 // An observer API implemented by classes which want to filter IPC messages from |
15 // RenderViewHost. | 15 // RenderViewHost. |
16 class CONTENT_EXPORT RenderViewHostObserver : public IPC::Channel::Listener, | 16 class CONTENT_EXPORT RenderViewHostObserver : public IPC::Channel::Listener, |
17 public IPC::Message::Sender { | 17 public IPC::Message::Sender { |
18 public: | 18 public: |
19 | 19 |
20 protected: | 20 protected: |
21 explicit RenderViewHostObserver(RenderViewHost* render_view_host); | 21 explicit RenderViewHostObserver(RenderViewHost* render_view_host); |
22 | 22 |
23 virtual ~RenderViewHostObserver(); | 23 virtual ~RenderViewHostObserver(); |
24 | 24 |
25 // Invoked after the RenderViewHost is created in the renderer process. After | 25 // Invoked after the RenderViewHost is created in the renderer process. After |
26 // this point, messages can be sent to it (or to observers in the renderer). | 26 // this point, messages can be sent to it (or to observers in the renderer). |
27 virtual void RenderViewHostInitialized(); | 27 virtual void RenderViewHostInitialized(); |
28 | 28 |
29 // Invoked when the RenderViewHost is being destroyed. Gives subclasses a | 29 // Invoked when the RenderViewHost is being destroyed. Gives subclasses a |
30 // chance to cleanup. The base implementation will delete the object. | 30 // chance to cleanup. The base implementation will delete the object. |
31 // |render_view_host| is passed as an argument since render_view_host() will | 31 // |render_view_host| is passed as an argument since render_view_host() will |
32 // return NULL once this method enters. | 32 // return NULL once this method enters. |
33 virtual void RenderViewHostDestroyed(RenderViewHost* render_view_host); | 33 virtual void RenderViewHostDestroyed(RenderViewHost* render_view_host); |
34 | 34 |
35 // Notifies that a navigation is starting. | 35 // Notifies that a navigation is starting. |
36 virtual void Navigate(const ViewMsg_Navigate_Params& params); | 36 virtual void Navigate(const GURL& url); |
37 | 37 |
38 // IPC::Channel::Listener implementation. | 38 // IPC::Channel::Listener implementation. |
39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
40 | 40 |
41 // IPC::Message::Sender implementation. | 41 // IPC::Message::Sender implementation. |
42 virtual bool Send(IPC::Message* message) OVERRIDE; | 42 virtual bool Send(IPC::Message* message) OVERRIDE; |
43 | 43 |
44 RenderViewHost* render_view_host() const { return render_view_host_; } | 44 RenderViewHost* render_view_host() const { return render_view_host_; } |
45 int routing_id() { return routing_id_; } | 45 int routing_id() { return routing_id_; } |
46 | 46 |
47 private: | 47 private: |
48 friend class RenderViewHost; | 48 friend class RenderViewHost; |
49 | 49 |
50 // Invoked from RenderViewHost. Invokes RenderViewHostDestroyed and NULL out | 50 // Invoked from RenderViewHost. Invokes RenderViewHostDestroyed and NULL out |
51 // |render_view_host_|. | 51 // |render_view_host_|. |
52 void RenderViewHostDestruction(); | 52 void RenderViewHostDestruction(); |
53 | 53 |
54 RenderViewHost* render_view_host_; | 54 RenderViewHost* render_view_host_; |
55 | 55 |
56 // The routing ID of the associated RenderViewHost. | 56 // The routing ID of the associated RenderViewHost. |
57 int routing_id_; | 57 int routing_id_; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(RenderViewHostObserver); | 59 DISALLOW_COPY_AND_ASSIGN(RenderViewHostObserver); |
60 }; | 60 }; |
61 | 61 |
62 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ | 62 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_OBSERVER_H_ |
OLD | NEW |