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