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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.h

Issue 1350913008: Revert of Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
7 7
8 #include "content/public/browser/navigation_handle.h" 8 #include "content/public/browser/navigation_handle.h"
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
13 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
14 #include "content/public/browser/navigation_throttle.h"
15 #include "url/gurl.h" 13 #include "url/gurl.h"
16 14
17 namespace content { 15 namespace content {
18 16
19 class NavigatorDelegate; 17 class NavigatorDelegate;
20 struct NavigationRequestInfo; 18 struct NavigationRequestInfo;
21 19
22 // This class keeps track of a single navigation. It is created upon receipt of 20 // This class keeps track of a single navigation. It is created upon receipt of
23 // a DidStartProvisionalLoad IPC in a RenderFrameHost. The RenderFrameHost owns 21 // a DidStartProvisionalLoad IPC in a RenderFrameHost. The RenderFrameHost owns
24 // the newly created NavigationHandleImpl as long as the navigation is ongoing. 22 // the newly created NavigationHandleImpl as long as the navigation is ongoing.
(...skipping 23 matching lines...) Expand all
48 // navigation is ready to commit. The NavigationHandleImpl ownership is then 46 // navigation is ready to commit. The NavigationHandleImpl ownership is then
49 // transferred to the RenderFrameHost in which the navigation will commit. 47 // transferred to the RenderFrameHost in which the navigation will commit.
50 // 48 //
51 // When PlzNavigate is enabled, the NavigationHandleImpl will never be reset 49 // When PlzNavigate is enabled, the NavigationHandleImpl will never be reset
52 // following the receipt of a DidStartProvisionalLoad IPC. There are also no 50 // following the receipt of a DidStartProvisionalLoad IPC. There are also no
53 // transferring navigations. The other causes of NavigationHandleImpl reset in 51 // transferring navigations. The other causes of NavigationHandleImpl reset in
54 // the RenderFrameHost still apply. 52 // the RenderFrameHost still apply.
55 class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle { 53 class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
56 public: 54 public:
57 static scoped_ptr<NavigationHandleImpl> Create(const GURL& url, 55 static scoped_ptr<NavigationHandleImpl> Create(const GURL& url,
58 bool is_main_frame, 56 const bool is_main_frame,
59 NavigatorDelegate* delegate); 57 NavigatorDelegate* delegate);
58
60 ~NavigationHandleImpl() override; 59 ~NavigationHandleImpl() override;
61 60
62 // NavigationHandle implementation: 61 // NavigationHandle implementation:
63 const GURL& GetURL() override; 62 const GURL& GetURL() const override;
64 bool IsInMainFrame() override; 63 net::Error GetNetErrorCode() const override;
65 bool IsPost() override; 64 bool IsInMainFrame() const override;
66 const Referrer& GetReferrer() override;
67 bool HasUserGesture() override;
68 ui::PageTransition GetPageTransition() override;
69 bool IsExternalProtocol() override;
70 net::Error GetNetErrorCode() override;
71 bool IsSamePage() override; 65 bool IsSamePage() override;
72 bool HasCommittedDocument() override; 66 bool HasCommittedDocument() const override;
73 bool HasCommittedErrorPage() override; 67 bool HasCommittedErrorPage() const override;
74 void RegisterThrottleForTesting(
75 scoped_ptr<NavigationThrottle> navigation_throttle) override;
76 NavigationThrottle::ThrottleCheckResult CallWillStartRequestForTesting(
77 bool is_post,
78 const Referrer& sanitized_referrer,
79 bool has_user_gesture,
80 ui::PageTransition transition,
81 bool is_external_protocol) override;
82 NavigationThrottle::ThrottleCheckResult CallWillRedirectRequestForTesting(
83 const GURL& new_url,
84 bool new_method_is_post,
85 const GURL& new_referrer_url,
86 bool new_is_external_protocol) override;
87
88 NavigatorDelegate* delegate() const { return delegate_; }
89 68
90 void set_net_error_code(net::Error net_error_code) { 69 void set_net_error_code(net::Error net_error_code) {
91 net_error_code_ = net_error_code; 70 net_error_code_ = net_error_code;
92 } 71 }
93 72
94 // Returns whether the navigation is currently being transferred from one 73 // Returns whether the navigation is currently being transferred from one
95 // RenderFrameHost to another. In particular, a DidStartProvisionalLoad IPC 74 // RenderFrameHost to another. In particular, a DidStartProvisionalLoad IPC
96 // for the navigation URL, received in the new RenderFrameHost, should not 75 // for the navigation URL, received in the new RenderFrameHost, should not
97 // indicate the start of a new navigation in that case. 76 // indicate the start of a new navigation in that case.
98 bool is_transferring() const { return is_transferring_; } 77 bool is_transferring() const { return is_transferring_; }
99 void set_is_transferring(bool is_transferring) { 78 void set_is_transferring(bool is_transferring) {
100 is_transferring_ = is_transferring; 79 is_transferring_ = is_transferring;
101 } 80 }
102 81
103 // Called when the URLRequest will start in the network stack.
104 NavigationThrottle::ThrottleCheckResult WillStartRequest(
105 bool is_post,
106 const Referrer& sanitized_referrer,
107 bool has_user_gesture,
108 ui::PageTransition transition,
109 bool is_external_protocol);
110
111 // Called when the URLRequest will be redirected in the network stack.
112 NavigationThrottle::ThrottleCheckResult WillRedirectRequest(
113 const GURL& new_url,
114 bool new_method_is_post,
115 const GURL& new_referrer_url,
116 bool new_is_external_protocol);
117
118 // Called when the navigation was redirected. This will update the |url_| and 82 // Called when the navigation was redirected. This will update the |url_| and
119 // inform the delegate. 83 // inform the delegate.
120 void DidRedirectNavigation(const GURL& new_url); 84 void DidRedirectNavigation(const GURL& new_url);
121 85
122 // Called when the navigation was committed. This will update the |state_| 86 // Called when the navigation was committed. This will update the |state_|
123 // and inform the delegate, 87 // and inform the delegate,
124 void DidCommitNavigation(bool same_page); 88 void DidCommitNavigation(bool same_page);
125 89
126 private: 90 private:
127 // Used to track the state the navigation is currently in. 91 // Used to track the state the navigation is currently in.
128 enum State { 92 enum State {
129 INITIAL = 0, 93 DID_START = 0,
130 WILL_SEND_REQUEST,
131 DID_COMMIT, 94 DID_COMMIT,
132 DID_COMMIT_ERROR_PAGE, 95 DID_COMMIT_ERROR_PAGE,
133 }; 96 };
134 97
135 NavigationHandleImpl(const GURL& url, 98 NavigationHandleImpl(const GURL& url,
136 const bool is_main_frame, 99 const bool is_main_frame,
137 NavigatorDelegate* delegate); 100 NavigatorDelegate* delegate);
138 101
139 // See NavigationHandle for a description of those member variables. 102 // See NavigationHandle for a description of those member variables.
140 GURL url_; 103 GURL url_;
104 net::Error net_error_code_;
105 State state_;
141 const bool is_main_frame_; 106 const bool is_main_frame_;
142 bool is_post_;
143 Referrer sanitized_referrer_;
144 bool has_user_gesture_;
145 ui::PageTransition transition_;
146 bool is_external_protocol_;
147 net::Error net_error_code_;
148 bool is_same_page_; 107 bool is_same_page_;
149 108
150 // The state the navigation is in.
151 State state_;
152
153 // Whether the navigation is in the middle of a transfer. Set to false when 109 // Whether the navigation is in the middle of a transfer. Set to false when
154 // the DidStartProvisionalLoad is received from the new renderer. 110 // the DidStartProvisionalLoad is received from the new renderer.
155 bool is_transferring_; 111 bool is_transferring_;
156 112
157 // The delegate that should be notified about events related to this 113 // The delegate that should be notified about events related to this
158 // navigation. 114 // navigation.
159 NavigatorDelegate* delegate_; 115 NavigatorDelegate* delegate_;
160 116
161 // A list of Throttles registered for this navigation.
162 ScopedVector<NavigationThrottle> throttles_;
163
164 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl); 117 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl);
165 }; 118 };
166 119
167 } // namespace content 120 } // namespace content
168 121
169 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 122 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698