Chromium Code Reviews| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 // been replaced is in |old_host|, which is nullptr if the old RVH was shut | 115 // been replaced is in |old_host|, which is nullptr if the old RVH was shut |
| 116 // down. | 116 // down. |
| 117 virtual void RenderViewHostChanged(RenderViewHost* old_host, | 117 virtual void RenderViewHostChanged(RenderViewHost* old_host, |
| 118 RenderViewHost* new_host) {} | 118 RenderViewHost* new_host) {} |
| 119 | 119 |
| 120 // Navigation related events ------------------------------------------------ | 120 // Navigation related events ------------------------------------------------ |
| 121 | 121 |
| 122 // Called when a navigation started in the WebContents. |navigation_handle| | 122 // Called when a navigation started in the WebContents. |navigation_handle| |
| 123 // is unique to a specific navigation. The same |navigation_handle| will be | 123 // is unique to a specific navigation. The same |navigation_handle| will be |
| 124 // provided on subsequent calls to | 124 // provided on subsequent calls to |
| 125 // DidRedirect/Commit/FinishNavigation/ReadyToCommitNavigation related to | 125 // DidRedirect/FinishNavigation/ReadyToCommitNavigation related to this |
| 126 // this navigation. | 126 // navigation. |
| 127 // | 127 // |
| 128 // Note that this is fired by navigations in any frame of the WebContents, | 128 // Note that this is fired by navigations in any frame of the WebContents, |
| 129 // not just the main frame. | 129 // not just the main frame. |
| 130 // | 130 // |
| 131 // Note that more than one navigation can be ongoing in the same frame at the | 131 // Note that more than one navigation can be ongoing in the same frame at the |
| 132 // same time (including the main frame). Each will get its own | 132 // same time (including the main frame). Each will get its own |
| 133 // NavigationHandle. | 133 // NavigationHandle. |
| 134 // | 134 // |
| 135 // Note that there is no guarantee that DidFinishNavigation will be called | 135 // Note that there is no guarantee that DidFinishNavigation will be called |
| 136 // for any particular navigation before DidStartNavigation is called on the | 136 // for any particular navigation before DidStartNavigation is called on the |
| 137 // next. | 137 // next. |
| 138 virtual void DidStartNavigation(NavigationHandle* navigation_handle) {} | 138 virtual void DidStartNavigation(NavigationHandle* navigation_handle) {} |
| 139 | 139 |
| 140 // Called when a navigation encountered a server redirect. | 140 // Called when a navigation encountered a server redirect. |
| 141 virtual void DidRedirectNavigation(NavigationHandle* navigation_handle) {} | 141 virtual void DidRedirectNavigation(NavigationHandle* navigation_handle) {} |
| 142 | 142 |
| 143 // PlzNavigate | 143 // PlzNavigate |
| 144 // Called when the navigation is ready to be committed in a renderer. This is | 144 // Called when the navigation is ready to be committed in a renderer. Most |
| 145 // the first point in time where a RenderFrameHost is associated with the | 145 // observers should use DidFinishNavigation instead, which happens right |
| 146 // navigation. Observers that want to initialize any renderer side | 146 // after the navigation commits. This method is for observers that want to |
| 147 // structures/state before the RenderFrame is navigated, should use this | 147 // initialize renderer-side state just before the RenderFrame commits the |
| 148 // method as opposed to DidCommitNavigation, which is after the fact. | 148 // navigation. |
| 149 // | |
| 150 // This is the first point in time where a RenderFrameHost is associated with | |
| 151 // the navigation. | |
| 149 virtual void ReadyToCommitNavigation(NavigationHandle* navigation_handle) {} | 152 virtual void ReadyToCommitNavigation(NavigationHandle* navigation_handle) {} |
| 150 | 153 |
| 151 // Called when a navigation was committed. | 154 // Called when a navigation finished in the WebContents. This happens when a |
| 152 virtual void DidCommitNavigation(NavigationHandle* navigation_handle) {} | 155 // navigation is committed, aborted or replaced by a new one. Note that |
|
Charlie Reis
2015/09/21 16:40:42
Please mention NavigationHandle's HasCommitted and
clamy
2015/09/22 00:38:05
Done.
| |
| 156 // |navigation_handle| will be destroyed at the end of this call, so do not | |
| 157 // keep a reference to it afterward. | |
| 158 // If this is called because the navigation committed, then the document load | |
|
Charlie Reis
2015/09/21 16:40:42
nit: Add an empty comment line above this paragrap
clamy
2015/09/22 00:38:05
Done.
| |
| 159 // will still be ongoing in the RenderFrameHost returned by | |
| 160 // |navigation_handle|. Use the document loads events such as DidStopLoading | |
| 161 // and related methods to listen for continued events from this | |
| 162 // RenderFrameHost. | |
| 163 virtual void DidFinishNavigation(NavigationHandle* navigation_handle) {} | |
| 153 | 164 |
| 154 // Called when a navigation stopped in the WebContents. This happens when a | 165 // Document load events ------------------------------------------------------ |
| 155 // navigation is either aborted, replaced by a new one, or the document load | 166 |
| 156 // finishes. Note that |navigation_handle| will be destroyed at the end of | 167 // These two methods correspond to the points in time when the spinner of the |
| 157 // this call, so do not keep a reference to it afterward. | 168 // tab starts and stops spinning. |
| 158 virtual void DidFinishNavigation(NavigationHandle* navigation_handle) {} | 169 virtual void DidStartLoading() {} |
| 170 virtual void DidStopLoading() {} | |
| 171 | |
| 172 // This method is invoked once the window.document object of the main frame | |
| 173 // was created. | |
| 174 virtual void DocumentAvailableInMainFrame() {} | |
| 175 | |
| 176 // This method is invoked once the onload handler of the main frame has | |
| 177 // completed. | |
| 178 virtual void DocumentOnLoadCompletedInMainFrame() {} | |
| 179 | |
| 180 // This method is invoked when the document in the given frame finished | |
| 181 // loading. At this point, scripts marked as defer were executed, and | |
| 182 // content scripts marked "document_end" get injected into the frame. | |
| 183 virtual void DocumentLoadedInFrame(RenderFrameHost* render_frame_host) {} | |
| 184 | |
| 185 // This method is invoked when the navigation is done, i.e. the spinner of | |
| 186 // the tab will stop spinning, and the onload event was dispatched. | |
| 187 // | |
| 188 // If the WebContents is displaying replacement content, e.g. network error | |
| 189 // pages, DidFinishLoad is invoked for frames that were not sending | |
| 190 // navigational events before. It is safe to ignore these events. | |
| 191 virtual void DidFinishLoad(RenderFrameHost* render_frame_host, | |
| 192 const GURL& validated_url) {} | |
| 193 | |
| 194 // This method is like DidFinishLoad, but when the load failed or was | |
| 195 // cancelled, e.g. window.stop() is invoked. | |
| 196 virtual void DidFailLoad(RenderFrameHost* render_frame_host, | |
| 197 const GURL& validated_url, | |
| 198 int error_code, | |
| 199 const base::string16& error_description, | |
| 200 bool was_ignored_by_handler) {} | |
| 159 | 201 |
| 160 // --------------------------------------------------------------------------- | 202 // --------------------------------------------------------------------------- |
| 161 | 203 |
| 162 // This method is invoked after the WebContents decides which RenderFrameHost | 204 // This method is invoked after the WebContents decides which RenderFrameHost |
| 163 // to use for the next browser-initiated navigation, but before the navigation | 205 // to use for the next browser-initiated navigation, but before the navigation |
| 164 // starts. It is not called for most renderer-initiated navigations, and it | 206 // starts. It is not called for most renderer-initiated navigations, and it |
| 165 // does not guarantee that the navigation will commit (e.g., 204s, downloads). | 207 // does not guarantee that the navigation will commit (e.g., 204s, downloads). |
| 166 // | 208 // |
| 167 // DEPRECATED. This method is difficult to use correctly and should be | 209 // DEPRECATED. This method is difficult to use correctly and should be |
| 168 // removed. TODO(creis): Remove in http://crbug.com/424641. | 210 // removed. TODO(creis): Remove in http://crbug.com/424641. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 const FrameNavigateParams& params) {} | 268 const FrameNavigateParams& params) {} |
| 227 | 269 |
| 228 // This method is invoked when the SecurityStyle of the WebContents changes. | 270 // This method is invoked when the SecurityStyle of the WebContents changes. |
| 229 // |security_style| is the new SecurityStyle. |security_style_explanations| | 271 // |security_style| is the new SecurityStyle. |security_style_explanations| |
| 230 // contains human-readable strings explaining why the SecurityStyle of the | 272 // contains human-readable strings explaining why the SecurityStyle of the |
| 231 // page has been downgraded. | 273 // page has been downgraded. |
| 232 virtual void SecurityStyleChanged( | 274 virtual void SecurityStyleChanged( |
| 233 SecurityStyle security_style, | 275 SecurityStyle security_style, |
| 234 const SecurityStyleExplanations& security_style_explanations) {} | 276 const SecurityStyleExplanations& security_style_explanations) {} |
| 235 | 277 |
| 236 // This method is invoked once the window.document object of the main frame | |
| 237 // was created. | |
| 238 virtual void DocumentAvailableInMainFrame() {} | |
| 239 | |
| 240 // This method is invoked once the onload handler of the main frame has | |
| 241 // completed. | |
| 242 virtual void DocumentOnLoadCompletedInMainFrame() {} | |
| 243 | |
| 244 // This method is invoked when the document in the given frame finished | |
| 245 // loading. At this point, scripts marked as defer were executed, and | |
| 246 // content scripts marked "document_end" get injected into the frame. | |
| 247 virtual void DocumentLoadedInFrame(RenderFrameHost* render_frame_host) {} | |
| 248 | |
| 249 // This method is invoked when the navigation is done, i.e. the spinner of | |
| 250 // the tab will stop spinning, and the onload event was dispatched. | |
| 251 // | |
| 252 // If the WebContents is displaying replacement content, e.g. network error | |
| 253 // pages, DidFinishLoad is invoked for frames that were not sending | |
| 254 // navigational events before. It is safe to ignore these events. | |
| 255 virtual void DidFinishLoad(RenderFrameHost* render_frame_host, | |
| 256 const GURL& validated_url) {} | |
| 257 | |
| 258 // This method is like DidFinishLoad, but when the load failed or was | |
| 259 // cancelled, e.g. window.stop() is invoked. | |
| 260 virtual void DidFailLoad(RenderFrameHost* render_frame_host, | |
| 261 const GURL& validated_url, | |
| 262 int error_code, | |
| 263 const base::string16& error_description, | |
| 264 bool was_ignored_by_handler) {} | |
| 265 | |
| 266 // This method is invoked when content was loaded from an in-memory cache. | 278 // This method is invoked when content was loaded from an in-memory cache. |
| 267 virtual void DidLoadResourceFromMemoryCache( | 279 virtual void DidLoadResourceFromMemoryCache( |
| 268 const LoadFromMemoryCacheDetails& details) {} | 280 const LoadFromMemoryCacheDetails& details) {} |
| 269 | 281 |
| 270 // This method is invoked when a response has been received for a resource | 282 // This method is invoked when a response has been received for a resource |
| 271 // request. | 283 // request. |
| 272 virtual void DidGetResourceResponseStart( | 284 virtual void DidGetResourceResponseStart( |
| 273 const ResourceRequestDetails& details) {} | 285 const ResourceRequestDetails& details) {} |
| 274 | 286 |
| 275 // This method is invoked when a redirect was received while requesting a | 287 // This method is invoked when a redirect was received while requesting a |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 293 RenderFrameHost* source_render_frame_host, | 305 RenderFrameHost* source_render_frame_host, |
| 294 const GURL& url, | 306 const GURL& url, |
| 295 const Referrer& referrer, | 307 const Referrer& referrer, |
| 296 WindowOpenDisposition disposition, | 308 WindowOpenDisposition disposition, |
| 297 ui::PageTransition transition) {} | 309 ui::PageTransition transition) {} |
| 298 | 310 |
| 299 // This method is invoked when the renderer process has completed its first | 311 // This method is invoked when the renderer process has completed its first |
| 300 // paint after a non-empty layout. | 312 // paint after a non-empty layout. |
| 301 virtual void DidFirstVisuallyNonEmptyPaint() {} | 313 virtual void DidFirstVisuallyNonEmptyPaint() {} |
| 302 | 314 |
| 303 // These two methods correspond to the points in time when the spinner of the | |
| 304 // tab starts and stops spinning. | |
| 305 virtual void DidStartLoading() {} | |
| 306 virtual void DidStopLoading() {} | |
| 307 | |
| 308 // When WebContents::Stop() is called, the WebContents stops loading and then | 315 // When WebContents::Stop() is called, the WebContents stops loading and then |
| 309 // invokes this method. If there are ongoing navigations, their respective | 316 // invokes this method. If there are ongoing navigations, their respective |
| 310 // failure methods will also be invoked. | 317 // failure methods will also be invoked. |
| 311 virtual void NavigationStopped() {} | 318 virtual void NavigationStopped() {} |
| 312 | 319 |
| 313 // This indicates that the next navigation was triggered by a user gesture. | 320 // This indicates that the next navigation was triggered by a user gesture. |
| 314 virtual void DidGetUserGesture() {} | 321 virtual void DidGetUserGesture() {} |
| 315 | 322 |
| 316 // This method is invoked when a RenderViewHost of this WebContents was | 323 // This method is invoked when a RenderViewHost of this WebContents was |
| 317 // configured to ignore UI events, and an UI event took place. | 324 // configured to ignore UI events, and an UI event took place. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 void ResetWebContents(); | 460 void ResetWebContents(); |
| 454 | 461 |
| 455 WebContentsImpl* web_contents_; | 462 WebContentsImpl* web_contents_; |
| 456 | 463 |
| 457 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); | 464 DISALLOW_COPY_AND_ASSIGN(WebContentsObserver); |
| 458 }; | 465 }; |
| 459 | 466 |
| 460 } // namespace content | 467 } // namespace content |
| 461 | 468 |
| 462 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ | 469 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |