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

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

Issue 2682313002: Introduce NavigationSimulator to use in unit tests (Closed)
Patch Set: Added same-page navigation simulation Created 3 years, 10 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 <stddef.h> 10 #include <stddef.h>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const GURL& url, 87 const GURL& url,
88 const std::vector<GURL>& redirect_chain, 88 const std::vector<GURL>& redirect_chain,
89 FrameTreeNode* frame_tree_node, 89 FrameTreeNode* frame_tree_node,
90 bool is_renderer_initiated, 90 bool is_renderer_initiated,
91 bool is_same_page, 91 bool is_same_page,
92 const base::TimeTicks& navigation_start, 92 const base::TimeTicks& navigation_start,
93 int pending_nav_entry_id, 93 int pending_nav_entry_id,
94 bool started_from_context_menu); 94 bool started_from_context_menu);
95 ~NavigationHandleImpl() override; 95 ~NavigationHandleImpl() override;
96 96
97 // Used to track the state the navigation is currently in.
98 enum State {
99 INITIAL = 0,
100 WILL_SEND_REQUEST,
101 DEFERRING_START,
102 WILL_REDIRECT_REQUEST,
103 DEFERRING_REDIRECT,
104 CANCELING,
105 WILL_PROCESS_RESPONSE,
106 DEFERRING_RESPONSE,
107 READY_TO_COMMIT,
108 DID_COMMIT,
109 DID_COMMIT_ERROR_PAGE,
110 };
111
97 // NavigationHandle implementation: 112 // NavigationHandle implementation:
98 const GURL& GetURL() override; 113 const GURL& GetURL() override;
99 SiteInstance* GetStartingSiteInstance() override; 114 SiteInstance* GetStartingSiteInstance() override;
100 bool IsInMainFrame() override; 115 bool IsInMainFrame() override;
101 bool IsParentMainFrame() override; 116 bool IsParentMainFrame() override;
102 bool IsRendererInitiated() override; 117 bool IsRendererInitiated() override;
103 bool WasServerRedirect() override; 118 bool WasServerRedirect() override;
104 const std::vector<GURL>& GetRedirectChain() override; 119 const std::vector<GURL>& GetRedirectChain() override;
105 int GetFrameTreeNodeId() override; 120 int GetFrameTreeNodeId() override;
106 int GetParentFrameTreeNodeId() override; 121 int GetParentFrameTreeNodeId() override;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const std::string& raw_response_header) override; 157 const std::string& raw_response_header) override;
143 void CallDidCommitNavigationForTesting(const GURL& url) override; 158 void CallDidCommitNavigationForTesting(const GURL& url) override;
144 bool WasStartedFromContextMenu() const override; 159 bool WasStartedFromContextMenu() const override;
145 const GURL& GetSearchableFormURL() override; 160 const GURL& GetSearchableFormURL() override;
146 const std::string& GetSearchableFormEncoding() override; 161 const std::string& GetSearchableFormEncoding() override;
147 ReloadType GetReloadType() override; 162 ReloadType GetReloadType() override;
148 const GlobalRequestID& GetGlobalRequestID() override; 163 const GlobalRequestID& GetGlobalRequestID() override;
149 164
150 NavigationData* GetNavigationData() override; 165 NavigationData* GetNavigationData() override;
151 166
167 // Used in tests.
168 State state_for_testing() const { return state_; }
169
152 // The NavigatorDelegate to notify/query for various navigation events. 170 // The NavigatorDelegate to notify/query for various navigation events.
153 // Normally this is the WebContents, except if this NavigationHandle was 171 // Normally this is the WebContents, except if this NavigationHandle was
154 // created during a navigation to an interstitial page. In this case it will 172 // created during a navigation to an interstitial page. In this case it will
155 // be the InterstitialPage itself. 173 // be the InterstitialPage itself.
156 // 174 //
157 // Note: due to the interstitial navigation case, all calls that can possibly 175 // Note: due to the interstitial navigation case, all calls that can possibly
158 // expose the NavigationHandle to code outside of content/ MUST go though the 176 // expose the NavigationHandle to code outside of content/ MUST go though the
159 // NavigatorDelegate. In particular, the ContentBrowserClient should not be 177 // NavigatorDelegate. In particular, the ContentBrowserClient should not be
160 // called directly form the NavigationHandle code. Thus, these calls will not 178 // called directly form the NavigationHandle code. Thus, these calls will not
161 // expose the NavigationHandle when navigating to an InterstialPage. 179 // expose the NavigationHandle when navigating to an InterstialPage.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 340 }
323 341
324 void set_response_headers_for_testing( 342 void set_response_headers_for_testing(
325 scoped_refptr<net::HttpResponseHeaders> response_headers) { 343 scoped_refptr<net::HttpResponseHeaders> response_headers) {
326 response_headers_ = response_headers; 344 response_headers_ = response_headers;
327 } 345 }
328 346
329 private: 347 private:
330 friend class NavigationHandleImplTest; 348 friend class NavigationHandleImplTest;
331 349
332 // Used to track the state the navigation is currently in.
333 enum State {
334 INITIAL = 0,
335 WILL_SEND_REQUEST,
336 DEFERRING_START,
337 WILL_REDIRECT_REQUEST,
338 DEFERRING_REDIRECT,
339 CANCELING,
340 WILL_PROCESS_RESPONSE,
341 DEFERRING_RESPONSE,
342 READY_TO_COMMIT,
343 DID_COMMIT,
344 DID_COMMIT_ERROR_PAGE,
345 };
346
347 NavigationHandleImpl(const GURL& url, 350 NavigationHandleImpl(const GURL& url,
348 const std::vector<GURL>& redirect_chain, 351 const std::vector<GURL>& redirect_chain,
349 FrameTreeNode* frame_tree_node, 352 FrameTreeNode* frame_tree_node,
350 bool is_renderer_initiated, 353 bool is_renderer_initiated,
351 bool is_same_page, 354 bool is_same_page,
352 const base::TimeTicks& navigation_start, 355 const base::TimeTicks& navigation_start,
353 int pending_nav_entry_id, 356 int pending_nav_entry_id,
354 bool started_from_context_menu); 357 bool started_from_context_menu);
355 358
356 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest(); 359 NavigationThrottle::ThrottleCheckResult CheckWillStartRequest();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 NavigationType navigation_type_; 494 NavigationType navigation_type_;
492 495
493 base::WeakPtrFactory<NavigationHandleImpl> weak_factory_; 496 base::WeakPtrFactory<NavigationHandleImpl> weak_factory_;
494 497
495 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl); 498 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl);
496 }; 499 };
497 500
498 } // namespace content 501 } // namespace content
499 502
500 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 503 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698