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