OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_NAVIGATION_THROTTLE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ |
7 | 7 |
8 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 class NavigationHandle; | 11 class NavigationHandle; |
12 | 12 |
13 // A NavigationThrottle tracks and allows interaction with a navigation on the | 13 // A NavigationThrottle tracks and allows interaction with a navigation on the |
14 // UI thread. | 14 // UI thread. |
15 class CONTENT_EXPORT NavigationThrottle { | 15 class CONTENT_EXPORT NavigationThrottle { |
16 public: | 16 public: |
17 // This is returned to the NavigationHandle to allow the navigation to | 17 // This is returned to the NavigationHandle to allow the navigation to |
18 // proceed, or to cancel it. | 18 // proceed, or to cancel it. |
19 enum ThrottleCheckResult { | 19 enum ThrottleCheckResult { |
| 20 // The navigation can proceed. |
20 PROCEED, | 21 PROCEED, |
| 22 |
| 23 // The navigation is deferred until NavigationHandle::Resume is |
| 24 // called. |
21 DEFER, | 25 DEFER, |
| 26 |
| 27 // The navigation is cancelled and the requester of the resource acts |
| 28 // like the request was never made. |
22 CANCEL_AND_IGNORE, | 29 CANCEL_AND_IGNORE, |
| 30 |
| 31 // The NavigationRequest was destroyed during the call to WillStartRequest |
| 32 // or the call to WillRedirectRequest. |
| 33 DESTROYED, |
23 }; | 34 }; |
24 | 35 |
25 NavigationThrottle(NavigationHandle* navigation_handle); | 36 NavigationThrottle(NavigationHandle* navigation_handle); |
26 virtual ~NavigationThrottle(); | 37 virtual ~NavigationThrottle(); |
27 | 38 |
28 // Called when a network request is about to be made for this navigation. | 39 // Called when a network request is about to be made for this navigation. |
| 40 // Note: unless they return DESTROYED, NavigationThrottles must ensure that |
| 41 // the WebContents is not destroyed during the execution of this function. |
| 42 // Failing to do so will result in security-critical |
| 43 // use-after-free bugs. |
29 virtual ThrottleCheckResult WillStartRequest(); | 44 virtual ThrottleCheckResult WillStartRequest(); |
30 | 45 |
31 // Called when a server redirect is received by the navigation. | 46 // Called when a server redirect is received by the navigation. |
| 47 // Note: unless they return DESTROYED, NavigationThrottles must ensure that |
| 48 // the WebContents is not destroyed during the execution of this function. |
| 49 // Failing to do so will result in security-critical |
| 50 // use-after-free bugs. |
32 virtual ThrottleCheckResult WillRedirectRequest(); | 51 virtual ThrottleCheckResult WillRedirectRequest(); |
33 | 52 |
34 // The NavigationHandle that is tracking the information related to this | 53 // The NavigationHandle that is tracking the information related to this |
35 // navigation. | 54 // navigation. |
36 NavigationHandle* navigation_handle() const { return navigation_handle_; } | 55 NavigationHandle* navigation_handle() const { return navigation_handle_; } |
37 | 56 |
38 private: | 57 private: |
39 NavigationHandle* navigation_handle_; | 58 NavigationHandle* navigation_handle_; |
40 }; | 59 }; |
41 | 60 |
42 } // namespace content | 61 } // namespace content |
43 | 62 |
44 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ | 63 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ |
OLD | NEW |