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

Unified 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: Add missing files 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/devtools/page_navigation_throttle.cc
diff --git a/content/browser/devtools/page_navigation_throttle.cc b/content/browser/devtools/page_navigation_throttle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eb72cae761f760b436981a796d12eab92937c794
--- /dev/null
+++ b/content/browser/devtools/page_navigation_throttle.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/devtools/page_navigation_throttle.h"
+
+#include "base/strings/stringprintf.h"
+#include "content/browser/devtools/protocol/page_handler.h"
+#include "content/public/browser/navigation_handle.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/web_contents.h"
+
+namespace content {
+namespace devtools {
+
+PageNavigationThrottle::PageNavigationThrottle(
+ base::WeakPtr<page::PageHandler> page_handler,
+ int navigation_id,
+ content::NavigationHandle* navigation_handle)
+ : content::NavigationThrottle(navigation_handle),
+ navigation_id_(navigation_id),
+ page_handler_(page_handler) {}
+
+PageNavigationThrottle::~PageNavigationThrottle() {
+ if (page_handler_)
+ page_handler_->OnPageNavigationThrottleDisposed(navigation_id_);
+}
+
+NavigationThrottle::ThrottleCheckResult
+PageNavigationThrottle::WillStartRequest() {
+ if (!page_handler_)
+ return ThrottleCheckResult::PROCEED;
+ page_handler_->ShouldAllowNavigation(this);
+ return ThrottleCheckResult::DEFER;
+}
+
+NavigationThrottle::ThrottleCheckResult
+PageNavigationThrottle::WillRedirectRequest() {
+ if (!page_handler_)
+ return ThrottleCheckResult::PROCEED;
+ page_handler_->ShouldAllowRedirect(this);
+ return ThrottleCheckResult::DEFER;
+}
+
+NavigationThrottle::ThrottleCheckResult
+PageNavigationThrottle::WillProcessResponse() {
+ return ThrottleCheckResult::PROCEED;
+}
+
+std::string PageNavigationThrottle::GetFrameId() const {
+ WebContents* web_contents = navigation_handle()->GetWebContents();
+ // NOTE keep in sync with BlinkPlatformImpl::getUniqueIdForProcess.
+ return base::StringPrintf(
+ "%d.%d",
+ base::GetProcId(web_contents->GetRenderProcessHost()->GetHandle()),
+ 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
+}
+
+} // namespace devtools
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698