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/kill.h" | 8 #include "base/process/kill.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 // RenderViewHost the observer cares about. | 41 // RenderViewHost the observer cares about. |
42 // | 42 // |
43 // Usually, observers should only care about the current RenderViewHost as | 43 // Usually, observers should only care about the current RenderViewHost as |
44 // returned by GetRenderViewHost(). | 44 // returned by GetRenderViewHost(). |
45 // | 45 // |
46 // TODO(creis, jochen): Hide the fact that there are several RenderViewHosts | 46 // TODO(creis, jochen): Hide the fact that there are several RenderViewHosts |
47 // from the WebContentsObserver API. http://crbug.com/173325 | 47 // from the WebContentsObserver API. http://crbug.com/173325 |
48 class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, | 48 class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, |
49 public IPC::Sender { | 49 public IPC::Sender { |
50 public: | 50 public: |
51 // Called when a RenderFrameHost associated with this WebContents is created. | 51 // Called when a RenderFrame for |render_frame_host| is created in the |
52 // renderer process. Use |RenderFrameDeleted| to listen for when this | |
53 // RenderFrame goes away. | |
52 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) {} | 54 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) {} |
53 | 55 |
54 // Called whenever a RenderFrameHost associated with this WebContents is | 56 // Called when a RenderFrame for |render_frame_host| is deleted or the |
55 // deleted. | 57 // renderer process in which it runs it has died. Use |RenderFrameCreated| to |
58 // listen for when RenderFrame objects are created. | |
56 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) {} | 59 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) {} |
57 | 60 |
61 // This method is invoked whenever one of the current frames of a WebContents | |
62 // swaps its RenderFrameHost with another one; for example because that frame | |
63 // navigated and the new content is in a different process. The | |
64 // RenderFrameHost that has been replaced is in |old_host|, which can be | |
65 // nullptr if the old RenderFrameHost was shut down or a new frame has been | |
66 // created and no old RenderFrameHost exists. | |
67 // | |
68 // This method, in combination with |FrameDeleted|, is appropriate for | |
69 // observers wishing to track the set of current RenderFrameHosts -- i.e., | |
70 // those hosts that would be visited by calling WebContents::ForEachFrame. | |
71 virtual void RenderFrameHostChanged(RenderFrameHost* old_host, | |
72 RenderFrameHost* new_host) {} | |
73 | |
74 // This method is invoked when a subframe associated with a WebContents is | |
75 // deleted or the WebContents is destroyed and the top-level frame is deleted. | |
76 // Use |RenderFrameHostChanged| to listen for when RenderFrameHost object is | |
Charlie Reis
2015/01/22 00:50:34
nit: when a
| |
77 // made the current host for a frame. | |
78 virtual void FrameDeleted(RenderFrameHost* render_frame_host) {} | |
79 | |
58 // This is called when a RVH is created for a WebContents, but not if it's an | 80 // This is called when a RVH is created for a WebContents, but not if it's an |
59 // interstitial. | 81 // interstitial. |
60 virtual void RenderViewCreated(RenderViewHost* render_view_host) {} | 82 virtual void RenderViewCreated(RenderViewHost* render_view_host) {} |
61 | 83 |
62 // Called for every RenderFrameHost that's created for an interstitial. | 84 // Called for every RenderFrameHost that's created for an interstitial. |
63 virtual void RenderFrameForInterstitialPageCreated( | 85 virtual void RenderFrameForInterstitialPageCreated( |
64 RenderFrameHost* render_frame_host) {} | 86 RenderFrameHost* render_frame_host) {} |
65 | 87 |
66 // This method is invoked when the RenderView of the current RenderViewHost | 88 // This method is invoked when the RenderView of the current RenderViewHost |
67 // is ready, e.g. because we recreated it after a crash. | 89 // is ready, e.g. because we recreated it after a crash. |
(...skipping 14 matching lines...) Expand all Loading... | |
82 // RenderProcessHostObserver::RenderProcessExited(). | 104 // RenderProcessHostObserver::RenderProcessExited(). |
83 virtual void RenderProcessGone(base::TerminationStatus status) {} | 105 virtual void RenderProcessGone(base::TerminationStatus status) {} |
84 | 106 |
85 // This method is invoked when a WebContents swaps its visible RenderViewHost | 107 // This method is invoked when a WebContents swaps its visible RenderViewHost |
86 // with another one, possibly changing processes. The RenderViewHost that has | 108 // with another one, possibly changing processes. The RenderViewHost that has |
87 // been replaced is in |old_host|, which is nullptr if the old RVH was shut | 109 // been replaced is in |old_host|, which is nullptr if the old RVH was shut |
88 // down. | 110 // down. |
89 virtual void RenderViewHostChanged(RenderViewHost* old_host, | 111 virtual void RenderViewHostChanged(RenderViewHost* old_host, |
90 RenderViewHost* new_host) {} | 112 RenderViewHost* new_host) {} |
91 | 113 |
92 // This method is invoked whenever one of the current frames of a WebContents | |
93 // swaps its RenderFrameHost with another one; for example because that frame | |
94 // navigated and the new content is in a different process. The | |
95 // RenderFrameHost that has been replaced is in |old_host|, which can be | |
96 // nullptr if the old RFH was shut down. | |
97 // | |
98 // This method, in combination with RenderFrameDeleted, is appropriate for | |
99 // observers wishing to track the set of active RenderFrameHosts -- i.e., | |
100 // those hosts that would be visited by calling WebContents::ForEachFrame. | |
101 virtual void RenderFrameHostChanged(RenderFrameHost* old_host, | |
102 RenderFrameHost* new_host) {} | |
103 | |
104 // This method is invoked after the WebContents decides which RenderFrameHost | 114 // This method is invoked after the WebContents decides which RenderFrameHost |
105 // to use for the next browser-initiated navigation, but before the navigation | 115 // to use for the next browser-initiated navigation, but before the navigation |
106 // starts. It is not called for most renderer-initiated navigations, and it | 116 // starts. It is not called for most renderer-initiated navigations, and it |
107 // does not guarantee that the navigation will commit (e.g., 204s, downloads). | 117 // does not guarantee that the navigation will commit (e.g., 204s, downloads). |
108 // | 118 // |
109 // DEPRECATED. This method is difficult to use correctly and should be | 119 // DEPRECATED. This method is difficult to use correctly and should be |
110 // removed. TODO(creis): Remove in http://crbug.com/424641. | 120 // removed. TODO(creis): Remove in http://crbug.com/424641. |
111 virtual void AboutToNavigateRenderFrame(RenderFrameHost* render_frame_host) {} | 121 virtual void AboutToNavigateRenderFrame(RenderFrameHost* render_frame_host) {} |
112 | 122 |
113 // This method is invoked after the browser process starts a navigation to a | 123 // This method is invoked after the browser process starts a navigation to a |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 // an action in the observed WebContents, e.g. a link with target=_blank was | 230 // an action in the observed WebContents, e.g. a link with target=_blank was |
221 // clicked. The |source_render_frame_host| is the frame in which the action | 231 // clicked. The |source_render_frame_host| is the frame in which the action |
222 // took place. | 232 // took place. |
223 virtual void DidOpenRequestedURL(WebContents* new_contents, | 233 virtual void DidOpenRequestedURL(WebContents* new_contents, |
224 RenderFrameHost* source_render_frame_host, | 234 RenderFrameHost* source_render_frame_host, |
225 const GURL& url, | 235 const GURL& url, |
226 const Referrer& referrer, | 236 const Referrer& referrer, |
227 WindowOpenDisposition disposition, | 237 WindowOpenDisposition disposition, |
228 ui::PageTransition transition) {} | 238 ui::PageTransition transition) {} |
229 | 239 |
230 virtual void FrameDetached(RenderFrameHost* render_frame_host) {} | 240 // This method is invoked when the renderer process has completed its first |
231 | 241 // paint after a non-empty layout. |
232 // This method is invoked when the renderer has completed its first paint | |
233 // after a non-empty layout. | |
234 virtual void DidFirstVisuallyNonEmptyPaint() {} | 242 virtual void DidFirstVisuallyNonEmptyPaint() {} |
235 | 243 |
236 // These two methods correspond to the points in time when the spinner of the | 244 // These two methods correspond to the points in time when the spinner of the |
237 // tab starts and stops spinning. | 245 // tab starts and stops spinning. |
238 virtual void DidStartLoading(RenderViewHost* render_view_host) {} | 246 virtual void DidStartLoading(RenderViewHost* render_view_host) {} |
239 virtual void DidStopLoading(RenderViewHost* render_view_host) {} | 247 virtual void DidStopLoading(RenderViewHost* render_view_host) {} |
240 | 248 |
241 // When WebContents::Stop() is called, the WebContents stops loading and then | 249 // When WebContents::Stop() is called, the WebContents stops loading and then |
242 // invokes this method. If there are ongoing navigations, their respective | 250 // invokes this method. If there are ongoing navigations, their respective |
243 // failure methods will also be invoked. | 251 // failure methods will also be invoked. |
(...skipping 13 matching lines...) Expand all Loading... | |
257 // This methods is invoked when the title of the WebContents is set. If the | 265 // This methods is invoked when the title of the WebContents is set. If the |
258 // title was explicitly set, |explicit_set| is true, otherwise the title was | 266 // title was explicitly set, |explicit_set| is true, otherwise the title was |
259 // synthesized and |explicit_set| is false. | 267 // synthesized and |explicit_set| is false. |
260 virtual void TitleWasSet(NavigationEntry* entry, bool explicit_set) {} | 268 virtual void TitleWasSet(NavigationEntry* entry, bool explicit_set) {} |
261 | 269 |
262 virtual void AppCacheAccessed(const GURL& manifest_url, | 270 virtual void AppCacheAccessed(const GURL& manifest_url, |
263 bool blocked_by_policy) {} | 271 bool blocked_by_policy) {} |
264 | 272 |
265 // Notification that a plugin has crashed. | 273 // Notification that a plugin has crashed. |
266 // |plugin_pid| is the process ID identifying the plugin process. Note that | 274 // |plugin_pid| is the process ID identifying the plugin process. Note that |
267 // this ID is supplied by the renderer, so should not be trusted. Besides, the | 275 // this ID is supplied by the renderer process, so should not be trusted. |
268 // corresponding process has probably died at this point. The ID may even have | 276 // Besides, the corresponding process has probably died at this point. The ID |
269 // been reused by a new process. | 277 // may even have been reused by a new process. |
270 virtual void PluginCrashed(const base::FilePath& plugin_path, | 278 virtual void PluginCrashed(const base::FilePath& plugin_path, |
271 base::ProcessId plugin_pid) {} | 279 base::ProcessId plugin_pid) {} |
272 | 280 |
273 // Notification that the given plugin has hung or become unhung. This | 281 // Notification that the given plugin has hung or become unhung. This |
274 // notification is only for Pepper plugins. | 282 // notification is only for Pepper plugins. |
275 // | 283 // |
276 // The plugin_child_id is the unique child process ID from the plugin. Note | 284 // The plugin_child_id is the unique child process ID from the plugin. Note |
277 // that this ID is supplied by the renderer, so should be validated before | 285 // that this ID is supplied by the renderer process, so should be validated |
278 // it's used for anything in case there's an exploited renderer. | 286 // before it's used for anything in case there's an exploited renderer |
287 // process. | |
279 virtual void PluginHungStatusChanged(int plugin_child_id, | 288 virtual void PluginHungStatusChanged(int plugin_child_id, |
280 const base::FilePath& plugin_path, | 289 const base::FilePath& plugin_path, |
281 bool is_hung) {} | 290 bool is_hung) {} |
282 | 291 |
283 // Invoked when WebContents::Clone() was used to clone a WebContents. | 292 // Invoked when WebContents::Clone() was used to clone a WebContents. |
284 virtual void DidCloneToNewWebContents(WebContents* old_web_contents, | 293 virtual void DidCloneToNewWebContents(WebContents* old_web_contents, |
285 WebContents* new_web_contents) {} | 294 WebContents* new_web_contents) {} |
286 | 295 |
287 // Invoked when the WebContents is being destroyed. Gives subclasses a chance | 296 // Invoked when the WebContents is being destroyed. Gives subclasses a chance |
288 // to cleanup. After the whole loop over all WebContentsObservers has been | 297 // to cleanup. After the whole loop over all WebContentsObservers has been |
289 // finished, web_contents() returns nullptr. | 298 // finished, web_contents() returns nullptr. |
290 virtual void WebContentsDestroyed() {} | 299 virtual void WebContentsDestroyed() {} |
291 | 300 |
292 // Called when the user agent override for a WebContents has been changed. | 301 // Called when the user agent override for a WebContents has been changed. |
293 virtual void UserAgentOverrideSet(const std::string& user_agent) {} | 302 virtual void UserAgentOverrideSet(const std::string& user_agent) {} |
294 | 303 |
295 // Invoked when new FaviconURL candidates are received from the renderer. | 304 // Invoked when new FaviconURL candidates are received from the renderer |
305 // process. | |
296 virtual void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates) {} | 306 virtual void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates) {} |
297 | 307 |
298 // Invoked when a pepper plugin creates and shows or destroys a fullscreen | 308 // Invoked when a pepper plugin creates and shows or destroys a fullscreen |
299 // render widget. | 309 // RenderWidget. |
300 virtual void DidShowFullscreenWidget(int routing_id) {} | 310 virtual void DidShowFullscreenWidget(int routing_id) {} |
301 virtual void DidDestroyFullscreenWidget(int routing_id) {} | 311 virtual void DidDestroyFullscreenWidget(int routing_id) {} |
302 | 312 |
303 // Invoked when the renderer has toggled the tab into/out of fullscreen mode. | 313 // Invoked when the renderer process has toggled the tab into/out of |
314 // fullscreen mode. | |
304 virtual void DidToggleFullscreenModeForTab(bool entered_fullscreen) {} | 315 virtual void DidToggleFullscreenModeForTab(bool entered_fullscreen) {} |
305 | 316 |
306 // Invoked when an interstitial page is attached or detached. | 317 // Invoked when an interstitial page is attached or detached. |
307 virtual void DidAttachInterstitialPage() {} | 318 virtual void DidAttachInterstitialPage() {} |
308 virtual void DidDetachInterstitialPage() {} | 319 virtual void DidDetachInterstitialPage() {} |
309 | 320 |
310 // Invoked before a form repost warning is shown. | 321 // Invoked before a form repost warning is shown. |
311 virtual void BeforeFormRepostWarningShow() {} | 322 virtual void BeforeFormRepostWarningShow() {} |
312 | 323 |
313 // Invoked when the beforeunload handler fires. The time is from the renderer. | 324 // Invoked when the beforeunload handler fires. The time is from the renderer |
325 // process. | |
314 virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) {} | 326 virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) {} |
315 | 327 |
316 // Invoked when a user cancels a before unload dialog. | 328 // Invoked when a user cancels a before unload dialog. |
317 virtual void BeforeUnloadDialogCancelled() {} | 329 virtual void BeforeUnloadDialogCancelled() {} |
318 | 330 |
319 // Invoked when an accessibility event is received from the renderer. | 331 // Invoked when an accessibility event is received from the renderer process. |
320 virtual void AccessibilityEventReceived( | 332 virtual void AccessibilityEventReceived( |
321 const std::vector<AXEventNotificationDetails>& details) {} | 333 const std::vector<AXEventNotificationDetails>& details) {} |
322 | 334 |
323 // Invoked when theme color is changed to |theme_color|. | 335 // Invoked when theme color is changed to |theme_color|. |
324 virtual void DidChangeThemeColor(SkColor theme_color) {} | 336 virtual void DidChangeThemeColor(SkColor theme_color) {} |
325 | 337 |
326 // Invoked if an IPC message is coming from a specific RenderFrameHost. | 338 // Invoked if an IPC message is coming from a specific RenderFrameHost. |
327 virtual bool OnMessageReceived(const IPC::Message& message, | 339 virtual bool OnMessageReceived(const IPC::Message& message, |
328 RenderFrameHost* render_frame_host); | 340 RenderFrameHost* render_frame_host); |
329 | 341 |
(...skipping 27 matching lines...) Expand all Loading... | |
357 void ResetWebContents(); | 369 void ResetWebContents(); |
358 | 370 |
359 WebContentsImpl* web_contents_; | 371 WebContentsImpl* web_contents_; |
360 | 372 |
361 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); | 373 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); |
362 }; | 374 }; |
363 | 375 |
364 } // namespace content | 376 } // namespace content |
365 | 377 |
366 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ | 378 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |