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

Side by Side Diff: content/public/test/navigation_handle_observer.cc

Issue 2889703002: Ensure that all code paths which call FrameTreeNode::ResetNavigationRequest set NavigationHandle::G… (Closed)
Patch Set: review comments Created 3 years, 7 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
« no previous file with comments | « content/public/test/navigation_handle_observer.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/public/test/navigation_handle_observer.h"
6
7 #include "content/public/browser/navigation_handle.h"
8
9 namespace content {
10
11 NavigationHandleObserver::NavigationHandleObserver(
12 WebContents* web_contents,
13 const GURL& expected_start_url)
14 : WebContentsObserver(web_contents),
15 page_transition_(ui::PAGE_TRANSITION_LINK),
16 expected_start_url_(expected_start_url) {}
17
18 void NavigationHandleObserver::DidStartNavigation(
19 NavigationHandle* navigation_handle) {
20 if (handle_ || navigation_handle->GetURL() != expected_start_url_)
21 return;
22
23 handle_ = navigation_handle;
24 has_committed_ = false;
25 is_error_ = false;
26 page_transition_ = ui::PAGE_TRANSITION_LINK;
27 last_committed_url_ = GURL();
28
29 is_main_frame_ = navigation_handle->IsInMainFrame();
30 is_parent_main_frame_ = navigation_handle->IsParentMainFrame();
31 is_renderer_initiated_ = navigation_handle->IsRendererInitiated();
32 is_same_document_ = navigation_handle->IsSameDocument();
33 was_redirected_ = navigation_handle->WasServerRedirect();
34 frame_tree_node_id_ = navigation_handle->GetFrameTreeNodeId();
35 }
36
37 void NavigationHandleObserver::DidFinishNavigation(
38 NavigationHandle* navigation_handle) {
39 if (navigation_handle != handle_)
40 return;
41
42 DCHECK_EQ(is_main_frame_, navigation_handle->IsInMainFrame());
43 DCHECK_EQ(is_parent_main_frame_, navigation_handle->IsParentMainFrame());
44 DCHECK_EQ(is_same_document_, navigation_handle->IsSameDocument());
45 DCHECK_EQ(is_renderer_initiated_, navigation_handle->IsRendererInitiated());
46 DCHECK_EQ(frame_tree_node_id_, navigation_handle->GetFrameTreeNodeId());
47
48 was_redirected_ = navigation_handle->WasServerRedirect();
49 net_error_code_ = navigation_handle->GetNetErrorCode();
50
51 if (navigation_handle->HasCommitted()) {
52 has_committed_ = true;
53 if (!navigation_handle->IsErrorPage()) {
54 page_transition_ = navigation_handle->GetPageTransition();
55 last_committed_url_ = navigation_handle->GetURL();
56 } else {
57 is_error_ = true;
58 }
59 } else {
60 has_committed_ = false;
61 is_error_ = true;
62 }
63
64 handle_ = nullptr;
65 }
66
67 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/navigation_handle_observer.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698