OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PAGE_NAVIGATION_THROTTLE_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PAGE_NAVIGATION_THROTTLE_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/public/browser/navigation_throttle.h" |
| 11 |
| 12 namespace content { |
| 13 namespace devtools { |
| 14 namespace page { |
| 15 class PageHandler; |
| 16 } // namespace page |
| 17 |
| 18 // Used to allow the DevTools client to optionally cancel navigations via the |
| 19 // Page.setControlNavigations and Page.processNavigation commands. |
| 20 class PageNavigationThrottle : public content::NavigationThrottle { |
| 21 public: |
| 22 PageNavigationThrottle(base::WeakPtr<page::PageHandler> page_handler, |
| 23 int navigation_id, |
| 24 content::NavigationHandle* navigation_handle); |
| 25 ~PageNavigationThrottle() override; |
| 26 |
| 27 // content::NavigationThrottle implementation: |
| 28 NavigationThrottle::ThrottleCheckResult WillStartRequest() override; |
| 29 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; |
| 30 |
| 31 int navigation_id() const { return navigation_id_; } |
| 32 |
| 33 // Tells the PageNavigationThrottle to not throttle anything! |
| 34 void AlwaysProceed(); |
| 35 |
| 36 // Resumes a deferred navigation request. Does nothing if a response isn't |
| 37 // expected. |
| 38 void Resume(); |
| 39 |
| 40 // Cancels a deferred navigation request. Does nothing if a response isn't |
| 41 // expected. |
| 42 void CancelDeferredNavigation(NavigationThrottle::ThrottleCheckResult result); |
| 43 |
| 44 private: |
| 45 // An opaque ID assigned by the PageHandler, used to allow the protocol client |
| 46 // to refer to this navigation throttle. |
| 47 const int navigation_id_; |
| 48 |
| 49 // The PageHandler that this navigation throttle is associated with. |
| 50 base::WeakPtr<page::PageHandler> page_handler_; |
| 51 |
| 52 // Whether or not a navigation was deferred. If deferred we expect a |
| 53 // subsequent call to AlwaysProceed, Resume or CancelDeferredNavigation. |
| 54 bool navigation_deferred_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(PageNavigationThrottle); |
| 57 }; |
| 58 |
| 59 } // namespace devtools |
| 60 } // namespace content |
| 61 |
| 62 #endif // CONTENT_BROWSER_DEVTOOLS_PAGE_NAVIGATION_THROTTLE_H_ |
OLD | NEW |