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

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

Issue 1269813002: Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: Addressed comments 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.h
diff --git a/content/public/browser/navigation_handle.h b/content/public/browser/navigation_handle.h
index 49d0884de43256e204ad3159903db42e889d1af6..ba2780e9610b4ae54ad642df3ca9228c8f4dbeab 100644
--- a/content/public/browser/navigation_handle.h
+++ b/content/public/browser/navigation_handle.h
@@ -6,33 +6,89 @@
#define CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_
#include "content/common/content_export.h"
+#include "content/public/common/referrer.h"
#include "net/base/net_errors.h"
+#include "ui/base/page_transition_types.h"
class GURL;
namespace content {
+class NavigationThrottle;
+class WebContents;
// A NavigationHandle tracks information related to a single navigation.
class CONTENT_EXPORT NavigationHandle {
public:
virtual ~NavigationHandle() {}
+ // Parameters available at navigation start time -----------------------------
+
+ // These parameters are always available during the navigation. Note that
+ // some may change during navigation (e.g. due to server redirects).
+
// The URL the frame is navigating to. This may change during the navigation
// when encountering a server redirect.
virtual const GURL& GetURL() const = 0;
Charlie Reis 2015/09/11 00:06:49 From http://www.chromium.org/developers/content-mo
clamy 2015/09/16 01:03:22 Done.
- // The net error code if an error happened prior to commit. Otherwise it will
- // be net::OK.
- virtual net::Error GetNetErrorCode() const = 0;
+ // A sanitized version of the URL the frame is navigating to. It may change
+ // during the navigation when encountering a server redirect.
+ virtual const GURL& GetValidatedURL() const = 0;
Charlie Reis 2015/09/11 00:06:48 It's not initially clear to me what this refers to
clamy 2015/09/11 13:30:44 When transitioning the InterceptNavigationResource
nasko 2015/09/14 22:00:04 I am all for only having one accessor, as I've sta
Charlie Reis 2015/09/16 00:09:24 Yes, let's try to have only GetURL which returns a
clamy 2015/09/16 01:03:22 Done.
// Whether the navigation is taking place in the main frame or in a subframe.
+ // This remains constant over the navigation lifetime.
virtual bool IsInMainFrame() const = 0;
+ // The WebContents the navigation is taking place in.
+ virtual WebContents* GetWebContents() const = 0;
+
+ // Parameters available at network request start time ------------------------
+
+ // The following parameters are only available when the network request is
+ // made for the navigation (or at commit time if no network request is made).
+ // This corresponds to NavigationThrottle::WillSendRequest. They should not
+ // be queried before that.
+
+ // Whether the navigation is a POST or not. This may change during the
+ // navigation when encountering a server redirect.
+ virtual bool IsPost() const = 0;
+
+ // Returns a sanitized version of the referrer for this request.
+ virtual const Referrer& GetReferrer() const = 0;
+
+ // Whether the navigation was initiated by a user gesture. Note that this
+ // will return false for browser-initiated navigations.
+ // TODO(clamy): when PlzNavigate launches, this should return true for
+ // browser-initiated navigations.
+ virtual bool HasUserGesture() const = 0;
Charlie Reis 2015/09/11 00:06:49 I'm not sure why many of these are inaccessible un
clamy 2015/09/11 13:30:44 It's for supporting the current architecture witho
+
+ // Returns the page transition type.
+ virtual ui::PageTransition GetPageTransition() const = 0;
+
+ // Whether the target URL cannot be handled by the browser's internal protocol
+ // handlers.
+ virtual bool IsExternalProtocol() const = 0;
+
+ // Navigation control flow --------------------------------------------------
+
+ // The net error code if an error happened prior to commit. Otherwise it will
+ // be net::OK.
+ virtual net::Error GetNetErrorCode() const = 0;
+
// Whether the navigation has successfully committed a document.
virtual bool HasCommittedDocument() const = 0;
// Whether an error page has committed for the navigation.
virtual bool HasCommittedErrorPage() const = 0;
+
+ // Registers a NavigationThrottle for tests. The throttle can
+ // modify the request, pause the request or cancel the request. This will
+ // take ownership of the NavigationThrottle.
+ // Note: in non-test cases, NavigationThrottles should not be added directly
+ // but returned by the implementation of
+ // ContentBrowserClient::AddNavigationThrottles. This ensures proper ordering
Charlie Reis 2015/09/11 00:06:48 Stale name?
clamy 2015/09/16 01:03:22 Done.
+ // of the throttles.
+ virtual void RegisterThrottleForTesting(
Charlie Reis 2015/09/11 00:06:48 Everything so far has been an accessor with no sta
clamy 2015/09/16 01:03:22 Well I did group it with the last 3 accessors in a
+ scoped_ptr<NavigationThrottle> navigation_throttle) = 0;
};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698