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 #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 | |
24 PageNavigationThrottle::~PageNavigationThrottle() { | |
25 if (page_handler_) | |
26 page_handler_->OnPageNavigationThrottleDisposed(navigation_id_); | |
27 } | |
28 | |
29 NavigationThrottle::ThrottleCheckResult | |
30 PageNavigationThrottle::WillStartRequest() { | |
31 if (!page_handler_) | |
32 return ThrottleCheckResult::PROCEED; | |
33 page_handler_->ShouldAllowNavigation(this); | |
34 return ThrottleCheckResult::DEFER; | |
35 } | |
36 | |
37 NavigationThrottle::ThrottleCheckResult | |
38 PageNavigationThrottle::WillRedirectRequest() { | |
39 if (!page_handler_) | |
40 return ThrottleCheckResult::PROCEED; | |
41 page_handler_->ShouldAllowRedirect(this); | |
42 return ThrottleCheckResult::DEFER; | |
43 } | |
44 | |
45 NavigationThrottle::ThrottleCheckResult | |
46 PageNavigationThrottle::WillProcessResponse() { | |
47 return ThrottleCheckResult::PROCEED; | |
48 } | |
49 | |
50 std::string PageNavigationThrottle::GetFrameId() const { | |
51 WebContents* web_contents = navigation_handle()->GetWebContents(); | |
52 // NOTE keep in sync with BlinkPlatformImpl::getUniqueIdForProcess. | |
53 return base::StringPrintf( | |
54 "%d.%d", | |
55 base::GetProcId(web_contents->GetRenderProcessHost()->GetHandle()), | |
56 navigation_handle()->GetFrameTreeNodeId()); | |
pfeldman
2016/07/07 17:26:18
The rest of the code uses IdentifiersFactory::fram
alex clarke (OOO till 29th)
2016/07/08 10:37:57
FWIW I'm under the impression this gives the same
pfeldman
2016/07/08 15:33:14
Are you still under that impression, even after my
alex clarke (OOO till 29th)
2016/07/08 17:15:40
Looking at some of the use cases we had in mind we
| |
57 } | |
58 | |
59 } // namespace devtools | |
60 } // namespace content | |
OLD | NEW |