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

Unified Diff: content/public/browser/navigation_handle.cc

Issue 1269813002: Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: Removed TestNavigationHandle + pointer to WebContents Created 5 years, 3 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/public/browser/navigation_handle.cc
diff --git a/content/public/browser/navigation_handle.cc b/content/public/browser/navigation_handle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..091a2ac624693ae1e2dac32bf0b6b377c271d0f2
--- /dev/null
+++ b/content/public/browser/navigation_handle.cc
@@ -0,0 +1,34 @@
+// Copyright 2015 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/public/browser/navigation_handle.h"
+
+#include "content/browser/frame_host/navigation_handle_impl.h"
+#include "content/browser/frame_host/navigator.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+
+namespace content {
+
+WebContents* NavigationHandle::GetWebContents() {
+ // The NavigationHandleImpl cannot access the WebContentsImpl a it would be a
Charlie Reis 2015/09/18 05:40:02 nit: s/a/as/
clamy 2015/09/18 17:35:39 Done.
+ // layering violation, hence the cast here.
+ return static_cast<WebContentsImpl*>(
+ static_cast<NavigationHandleImpl*>(this)->delegate());
+}
+
+// static
+scoped_ptr<NavigationHandle> NavigationHandle::CreateNavigationHandleForTesting(
+ const GURL& url,
+ bool is_main_frame,
+ WebContents* web_contents) {
+ scoped_ptr<NavigationHandleImpl> handle_impl = NavigationHandleImpl::Create(
+ url, is_main_frame, static_cast<WebContentsImpl*>(web_contents)
+ ->GetMainFrame()
+ ->frame_tree_node()
+ ->navigator()
+ ->GetDelegate());
nasko 2015/09/17 21:10:25 Uh, this is a fairly long chain. Why not use the R
Charlie Reis 2015/09/18 05:40:02 I'm not sure we know the RFH at the time (e.g., in
clamy 2015/09/18 17:35:39 Done.
+ return scoped_ptr<NavigationHandle>(handle_impl.Pass());
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698