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 proceeds uninterrupted. | |
20 PROCEED, | 21 PROCEED, |
22 | |
23 // Defers the navigation until the NavigationThrottle calls | |
24 // NavigationHandle::Resume or NavigationHandle::CancelDeferredRequest. | |
25 // If the NavigationHandle is destroyed while the navigation is deferred, | |
26 // the navigation will be canceled in the network stack. | |
21 DEFER, | 27 DEFER, |
28 | |
29 // Cancels the navigation. | |
30 CANCEL, | |
31 | |
32 // Cancels the navigation and makes the requester of the navigation acts | |
33 // like the request was never made. | |
22 CANCEL_AND_IGNORE, | 34 CANCEL_AND_IGNORE, |
23 }; | 35 }; |
24 | 36 |
25 NavigationThrottle(NavigationHandle* navigation_handle); | 37 NavigationThrottle(NavigationHandle* navigation_handle); |
26 virtual ~NavigationThrottle(); | 38 virtual ~NavigationThrottle(); |
27 | 39 |
28 // Called when a network request is about to be made for this navigation. | 40 // Called when a network request is about to be made for this navigation. |
41 // | |
42 // The implementer is responsible for ensuring that the WebContents remain | |
43 // alive during teh duration of this method. Failing to do so will result in | |
mnaganov (inactive)
2015/11/09 17:42:41
typo: the
clamy
2015/11/10 11:58:53
Done.
| |
44 // use-after-free bugs. Should the implementer need to destroy the | |
45 // WebContents, it should return CANCEL, CANCEL_AND_IGNORE or DEFER and | |
nasko
2015/11/09 17:31:18
Should we encourage the usage of DEFER if they wil
clamy
2015/11/10 11:58:53
I think it's more of a special case for when the c
| |
46 // perform the destrutction asynchronously. | |
mnaganov (inactive)
2015/11/09 17:42:41
typo: destruction
clamy
2015/11/10 11:58:53
Done.
| |
29 virtual ThrottleCheckResult WillStartRequest(); | 47 virtual ThrottleCheckResult WillStartRequest(); |
30 | 48 |
31 // Called when a server redirect is received by the navigation. | 49 // Called when a server redirect is received by the navigation. |
50 // | |
51 // The implementer is responsible for ensuring that the WebContents remain | |
52 // alive during teh duration of this method. Failing to do so will result in | |
mnaganov (inactive)
2015/11/09 17:42:41
typo: the
clamy
2015/11/10 11:58:53
Done.
| |
53 // use-after-free bugs. Should the implementer need to destroy the | |
54 // WebContents, it should return CANCEL, CANCEL_AND_IGNORE or DEFER and | |
55 // perform the destrutction asynchronously. | |
mnaganov (inactive)
2015/11/09 17:42:41
typo: destruction
clamy
2015/11/10 11:58:53
Done.
| |
32 virtual ThrottleCheckResult WillRedirectRequest(); | 56 virtual ThrottleCheckResult WillRedirectRequest(); |
33 | 57 |
34 // The NavigationHandle that is tracking the information related to this | 58 // The NavigationHandle that is tracking the information related to this |
35 // navigation. | 59 // navigation. |
36 NavigationHandle* navigation_handle() const { return navigation_handle_; } | 60 NavigationHandle* navigation_handle() const { return navigation_handle_; } |
37 | 61 |
38 private: | 62 private: |
39 NavigationHandle* navigation_handle_; | 63 NavigationHandle* navigation_handle_; |
40 }; | 64 }; |
41 | 65 |
42 } // namespace content | 66 } // namespace content |
43 | 67 |
44 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ | 68 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_THROTTLE_H_ |
OLD | NEW |