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