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

Unified Diff: content/browser/frame_host/navigation_handle_impl.h

Issue 1363483007: Reland of Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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/browser/frame_host/navigation_handle_impl.h
diff --git a/content/browser/frame_host/navigation_handle_impl.h b/content/browser/frame_host/navigation_handle_impl.h
index 4ea8c1475f7b489673cc9d36b538faaae81f306a..edd7b5552c95227a2980da067c8b71d17ea760ca 100644
--- a/content/browser/frame_host/navigation_handle_impl.h
+++ b/content/browser/frame_host/navigation_handle_impl.h
@@ -9,8 +9,10 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/common/content_export.h"
+#include "content/public/browser/navigation_throttle.h"
#include "url/gurl.h"
namespace content {
@@ -54,19 +56,38 @@ struct NavigationRequestInfo;
class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
public:
static scoped_ptr<NavigationHandleImpl> Create(const GURL& url,
- const bool is_main_frame,
+ bool is_main_frame,
NavigatorDelegate* delegate);
-
~NavigationHandleImpl() override;
// NavigationHandle implementation:
- const GURL& GetURL() const override;
- net::Error GetNetErrorCode() const override;
- bool IsInMainFrame() const override;
+ const GURL& GetURL() override;
+ bool IsInMainFrame() override;
+ bool IsPost() override;
+ const Referrer& GetReferrer() override;
+ bool HasUserGesture() override;
+ ui::PageTransition GetPageTransition() override;
+ bool IsExternalProtocol() override;
+ net::Error GetNetErrorCode() override;
RenderFrameHostImpl* GetRenderFrameHost() override;
bool IsSamePage() override;
bool HasCommitted() override;
bool IsErrorPage() override;
+ void RegisterThrottleForTesting(
+ scoped_ptr<NavigationThrottle> navigation_throttle) override;
+ NavigationThrottle::ThrottleCheckResult CallWillStartRequestForTesting(
+ bool is_post,
+ const Referrer& sanitized_referrer,
+ bool has_user_gesture,
+ ui::PageTransition transition,
+ bool is_external_protocol) override;
+ NavigationThrottle::ThrottleCheckResult CallWillRedirectRequestForTesting(
+ const GURL& new_url,
+ bool new_method_is_post,
+ const GURL& new_referrer_url,
+ bool new_is_external_protocol) override;
+
+ NavigatorDelegate* delegate() const { return delegate_; }
void set_net_error_code(net::Error net_error_code) {
net_error_code_ = net_error_code;
@@ -81,6 +102,21 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
is_transferring_ = is_transferring;
}
+ // Called when the URLRequest will start in the network stack.
+ NavigationThrottle::ThrottleCheckResult WillStartRequest(
+ bool is_post,
+ const Referrer& sanitized_referrer,
+ bool has_user_gesture,
+ ui::PageTransition transition,
+ bool is_external_protocol);
+
+ // Called when the URLRequest will be redirected in the network stack.
+ NavigationThrottle::ThrottleCheckResult WillRedirectRequest(
+ const GURL& new_url,
+ bool new_method_is_post,
+ const GURL& new_referrer_url,
+ bool new_is_external_protocol);
+
// Called when the navigation was redirected. This will update the |url_| and
// inform the delegate.
void DidRedirectNavigation(const GURL& new_url);
@@ -98,7 +134,8 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
private:
// Used to track the state the navigation is currently in.
enum State {
- DID_START = 0,
+ INITIAL = 0,
+ WILL_SEND_REQUEST,
READY_TO_COMMIT,
DID_COMMIT,
DID_COMMIT_ERROR_PAGE,
@@ -110,12 +147,19 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
// See NavigationHandle for a description of those member variables.
GURL url_;
- net::Error net_error_code_;
- State state_;
const bool is_main_frame_;
+ bool is_post_;
+ Referrer sanitized_referrer_;
+ bool has_user_gesture_;
+ ui::PageTransition transition_;
+ bool is_external_protocol_;
+ net::Error net_error_code_;
RenderFrameHostImpl* render_frame_host_;
bool is_same_page_;
+ // The state the navigation is in.
+ State state_;
+
// Whether the navigation is in the middle of a transfer. Set to false when
// the DidStartProvisionalLoad is received from the new renderer.
bool is_transferring_;
@@ -124,6 +168,9 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
// navigation.
NavigatorDelegate* delegate_;
+ // A list of Throttles registered for this navigation.
+ ScopedVector<NavigationThrottle> throttles_;
+
DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl);
};

Powered by Google App Engine
This is Rietveld 408576698