| 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_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
| 11 #include "content/public/common/page_transition_types.h" | 11 #include "content/public/common/page_transition_types.h" |
| 12 #include "ipc/ipc_channel.h" | 12 #include "ipc/ipc_listener.h" |
| 13 #include "ipc/ipc_sender.h" |
| 13 #include "webkit/glue/window_open_disposition.h" | 14 #include "webkit/glue/window_open_disposition.h" |
| 14 | 15 |
| 15 class WebContentsImpl; | 16 class WebContentsImpl; |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class RenderViewHost; | 20 class RenderViewHost; |
| 20 class WebContents; | 21 class WebContents; |
| 21 struct FrameNavigateParams; | 22 struct FrameNavigateParams; |
| 22 struct LoadCommittedDetails; | 23 struct LoadCommittedDetails; |
| 23 struct Referrer; | 24 struct Referrer; |
| 24 | 25 |
| 25 // An observer API implemented by classes which are interested in various page | 26 // An observer API implemented by classes which are interested in various page |
| 26 // load events from WebContents. They also get a chance to filter IPC messages. | 27 // load events from WebContents. They also get a chance to filter IPC messages. |
| 27 class CONTENT_EXPORT WebContentsObserver : public IPC::Channel::Listener, | 28 class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, |
| 28 public IPC::Message::Sender { | 29 public IPC::Sender { |
| 29 public: | 30 public: |
| 30 // Only one of the two methods below will be called when a RVH is created for | 31 // Only one of the two methods below will be called when a RVH is created for |
| 31 // a WebContents, depending on whether it's for an interstitial or not. | 32 // a WebContents, depending on whether it's for an interstitial or not. |
| 32 virtual void RenderViewCreated(RenderViewHost* render_view_host) {} | 33 virtual void RenderViewCreated(RenderViewHost* render_view_host) {} |
| 33 virtual void RenderViewForInterstitialPageCreated( | 34 virtual void RenderViewForInterstitialPageCreated( |
| 34 RenderViewHost* render_view_host) {} | 35 RenderViewHost* render_view_host) {} |
| 35 virtual void RenderViewDeleted(RenderViewHost* render_view_host) {} | 36 virtual void RenderViewDeleted(RenderViewHost* render_view_host) {} |
| 36 virtual void RenderViewReady() {} | 37 virtual void RenderViewReady() {} |
| 37 virtual void RenderViewGone(base::TerminationStatus status) {} | 38 virtual void RenderViewGone(base::TerminationStatus status) {} |
| 38 virtual void NavigateToPendingEntry( | 39 virtual void NavigateToPendingEntry( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // it's used for anything in case there's an exploited renderer. | 113 // it's used for anything in case there's an exploited renderer. |
| 113 virtual void PluginHungStatusChanged(int plugin_child_id, | 114 virtual void PluginHungStatusChanged(int plugin_child_id, |
| 114 const FilePath& plugin_path, | 115 const FilePath& plugin_path, |
| 115 bool is_hung) {} | 116 bool is_hung) {} |
| 116 | 117 |
| 117 // Invoked when the WebContents is being destroyed. Gives subclasses a chance | 118 // Invoked when the WebContents is being destroyed. Gives subclasses a chance |
| 118 // to cleanup. At the time this is invoked |web_contents()| returns NULL. | 119 // to cleanup. At the time this is invoked |web_contents()| returns NULL. |
| 119 // It is safe to delete 'this' from here. | 120 // It is safe to delete 'this' from here. |
| 120 virtual void WebContentsDestroyed(WebContents* web_contents) {} | 121 virtual void WebContentsDestroyed(WebContents* web_contents) {} |
| 121 | 122 |
| 122 // IPC::Channel::Listener implementation. | 123 // IPC::Listener implementation. |
| 123 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 124 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 124 | 125 |
| 125 // IPC::Message::Sender implementation. | 126 // IPC::Sender implementation. |
| 126 virtual bool Send(IPC::Message* message) OVERRIDE; | 127 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 127 int routing_id() const; | 128 int routing_id() const; |
| 128 | 129 |
| 129 protected: | 130 protected: |
| 130 // Use this constructor when the object is tied to a single WebContents for | 131 // Use this constructor when the object is tied to a single WebContents for |
| 131 // its entire lifetime. | 132 // its entire lifetime. |
| 132 explicit WebContentsObserver(WebContents* web_contents); | 133 explicit WebContentsObserver(WebContents* web_contents); |
| 133 | 134 |
| 134 // Use this constructor when the object wants to observe a WebContents for | 135 // Use this constructor when the object wants to observe a WebContents for |
| 135 // part of its lifetime. It can then call Observe() to start and stop | 136 // part of its lifetime. It can then call Observe() to start and stop |
| (...skipping 15 matching lines...) Expand all Loading... |
| 151 void WebContentsImplDestroyed(); | 152 void WebContentsImplDestroyed(); |
| 152 | 153 |
| 153 WebContentsImpl* web_contents_; | 154 WebContentsImpl* web_contents_; |
| 154 | 155 |
| 155 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); | 156 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 } // namespace content | 159 } // namespace content |
| 159 | 160 |
| 160 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ | 161 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |