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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/navigation_handle_observer.cc
diff --git a/content/public/test/navigation_handle_observer.cc b/content/public/test/navigation_handle_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2f3f5a8366318462226c15099c99def9cbfc9282
--- /dev/null
+++ b/content/public/test/navigation_handle_observer.cc
@@ -0,0 +1,67 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/test/navigation_handle_observer.h"
+
+#include "content/public/browser/navigation_handle.h"
+
+namespace content {
+
+NavigationHandleObserver::NavigationHandleObserver(
+ WebContents* web_contents,
+ const GURL& expected_start_url)
+ : WebContentsObserver(web_contents),
+ page_transition_(ui::PAGE_TRANSITION_LINK),
+ expected_start_url_(expected_start_url) {}
+
+void NavigationHandleObserver::DidStartNavigation(
+ NavigationHandle* navigation_handle) {
+ if (handle_ || navigation_handle->GetURL() != expected_start_url_)
+ return;
+
+ handle_ = navigation_handle;
+ has_committed_ = false;
+ is_error_ = false;
+ page_transition_ = ui::PAGE_TRANSITION_LINK;
+ last_committed_url_ = GURL();
+
+ is_main_frame_ = navigation_handle->IsInMainFrame();
+ is_parent_main_frame_ = navigation_handle->IsParentMainFrame();
+ is_renderer_initiated_ = navigation_handle->IsRendererInitiated();
+ is_same_document_ = navigation_handle->IsSameDocument();
+ was_redirected_ = navigation_handle->WasServerRedirect();
+ frame_tree_node_id_ = navigation_handle->GetFrameTreeNodeId();
+}
+
+void NavigationHandleObserver::DidFinishNavigation(
+ NavigationHandle* navigation_handle) {
+ if (navigation_handle != handle_)
+ return;
+
+ DCHECK_EQ(is_main_frame_, navigation_handle->IsInMainFrame());
+ DCHECK_EQ(is_parent_main_frame_, navigation_handle->IsParentMainFrame());
+ DCHECK_EQ(is_same_document_, navigation_handle->IsSameDocument());
+ DCHECK_EQ(is_renderer_initiated_, navigation_handle->IsRendererInitiated());
+ DCHECK_EQ(frame_tree_node_id_, navigation_handle->GetFrameTreeNodeId());
+
+ was_redirected_ = navigation_handle->WasServerRedirect();
+ net_error_code_ = navigation_handle->GetNetErrorCode();
+
+ if (navigation_handle->HasCommitted()) {
+ has_committed_ = true;
+ if (!navigation_handle->IsErrorPage()) {
+ page_transition_ = navigation_handle->GetPageTransition();
+ last_committed_url_ = navigation_handle->GetURL();
+ } else {
+ is_error_ = true;
+ }
+ } else {
+ has_committed_ = false;
+ is_error_ = true;
+ }
+
+ handle_ = nullptr;
+}
+
+} // namespace content
« 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