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

Side by Side Diff: content/browser/devtools/page_navigation_throttle.cc

Issue 2132673002: Adding Navigation Throttles to DevTools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved RegisterNavigationThrottles Created 4 years, 5 months 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
(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 #include "content/browser/devtools/page_navigation_throttle.h"
6
7 #include "base/strings/stringprintf.h"
8 #include "content/browser/devtools/protocol/page_handler.h"
9 #include "content/public/browser/navigation_handle.h"
10 #include "content/public/browser/render_process_host.h"
11 #include "content/public/browser/web_contents.h"
12
13 namespace content {
14 namespace devtools {
15
16 PageNavigationThrottle::PageNavigationThrottle(
17 base::WeakPtr<page::PageHandler> page_handler,
18 int navigation_id,
19 content::NavigationHandle* navigation_handle)
20 : content::NavigationThrottle(navigation_handle),
21 navigation_id_(navigation_id),
22 page_handler_(page_handler),
23 response_pending_(false) {}
24
25 PageNavigationThrottle::~PageNavigationThrottle() {
26 if (page_handler_)
27 page_handler_->OnPageNavigationThrottleDisposed(navigation_id_);
28 }
29
30 NavigationThrottle::ThrottleCheckResult
31 PageNavigationThrottle::WillStartRequest() {
32 if (!page_handler_)
33 return ThrottleCheckResult::PROCEED;
34 response_pending_ = true;
35 page_handler_->NavigationRequested(this);
36 return ThrottleCheckResult::DEFER;
37 }
38
39 NavigationThrottle::ThrottleCheckResult
40 PageNavigationThrottle::WillRedirectRequest() {
41 if (!page_handler_)
42 return ThrottleCheckResult::PROCEED;
43 response_pending_ = true;
44 page_handler_->NavigationRequested(this);
45 return ThrottleCheckResult::DEFER;
46 }
47
48 NavigationThrottle::ThrottleCheckResult
49 PageNavigationThrottle::WillProcessResponse() {
50 return ThrottleCheckResult::PROCEED;
nasko 2016/07/12 18:03:11 Why do you need to override this one? It already h
alex clarke (OOO till 29th) 2016/07/12 20:36:14 Done.
51 }
52
53 void PageNavigationThrottle::AlwaysProceed() {
54 // Makes WillStartRequest and WillRedirectRequest always return
55 // ThrottleCheckResult::PROCEED.
56 page_handler_.reset();
57
58 if (response_pending_)
59 Resume();
60 }
61
62 void PageNavigationThrottle::Resume() {
63 if (!response_pending_)
64 return;
65 navigation_handle()->Resume();
66 response_pending_ = false;
67 }
68
69 void PageNavigationThrottle::CancelDeferredNavigation(
70 NavigationThrottle::ThrottleCheckResult result) {
71 if (!response_pending_)
72 return;
73 navigation_handle()->CancelDeferredNavigation(result);
74 response_pending_ = false;
75 }
76
77 } // namespace devtools
78 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698