Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: components/navigation_interception/intercept_navigation_throttle.h

Issue 1414723008: Add a way to cancel deferred navigations in NavigationHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Nasko's comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ 5 #ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_
6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ 6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 13 matching lines...) Expand all
24 24
25 // This class allows the provider of the Callback to selectively ignore top 25 // This class allows the provider of the Callback to selectively ignore top
26 // level navigations. This is a UI thread class. 26 // level navigations. This is a UI thread class.
27 class InterceptNavigationThrottle : public content::NavigationThrottle { 27 class InterceptNavigationThrottle : public content::NavigationThrottle {
28 public: 28 public:
29 typedef base::Callback<bool(content::WebContents* /* source */, 29 typedef base::Callback<bool(content::WebContents* /* source */,
30 const NavigationParams& /* navigation_params */)> 30 const NavigationParams& /* navigation_params */)>
31 CheckCallback; 31 CheckCallback;
32 32
33 InterceptNavigationThrottle(content::NavigationHandle* navigation_handle, 33 InterceptNavigationThrottle(content::NavigationHandle* navigation_handle,
34 CheckCallback should_ignore_callback); 34 CheckCallback should_ignore_callback,
35 bool run_callback_synchronously);
35 ~InterceptNavigationThrottle() override; 36 ~InterceptNavigationThrottle() override;
36 37
37 // content::NavigationThrottle implementation: 38 // content::NavigationThrottle implementation:
38 ThrottleCheckResult WillStartRequest() override; 39 ThrottleCheckResult WillStartRequest() override;
39 ThrottleCheckResult WillRedirectRequest() override; 40 ThrottleCheckResult WillRedirectRequest() override;
40 41
41 private: 42 private:
42 ThrottleCheckResult CheckIfShouldIgnoreNavigation(bool is_redirect); 43 ThrottleCheckResult CheckIfShouldIgnoreNavigation(bool is_redirect);
43 44
45 // Called to perform the checks asynchronously
46 void RunCallbackAsynchronously(const NavigationParams& navigation_params);
47 void OnAsynchronousChecksPerformed(bool should_ignore_navigation);
48
44 CheckCallback should_ignore_callback_; 49 CheckCallback should_ignore_callback_;
45 50
51 // Whether the callback will be run synchronously or not. If the callback can
52 // lead to the destruction of the WebContents, this should be false.
53 // Otherwise this should be true.
54 const bool run_callback_synchronously_;
55
56 base::WeakPtrFactory<InterceptNavigationThrottle> weak_factory_;
57
46 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationThrottle); 58 DISALLOW_COPY_AND_ASSIGN(InterceptNavigationThrottle);
47 }; 59 };
48 60
49 } // namespace navigation_interception 61 } // namespace navigation_interception
50 62
51 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_ 63 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698