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

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

Issue 2655893004: Convert TestFrameNavigationObserver to use the new navigation callbacks. (Closed)
Patch Set: Created 3 years, 11 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/test_frame_navigation_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/public/test/test_frame_navigation_observer.h" 5 #include "content/public/test/test_frame_navigation_observer.h"
6 6
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h"
10 #include "base/stl_util.h"
11 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
12 #include "content/browser/frame_host/render_frame_host_impl.h" 8 #include "content/browser/frame_host/render_frame_host_impl.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h" 9 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/navigation_handle.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 12
18 namespace content { 13 namespace content {
19 14
20 namespace { 15 namespace {
21 16
22 RenderFrameHostImpl* ToRenderFrameHostImpl(const ToRenderFrameHost& frame) { 17 RenderFrameHostImpl* ToRenderFrameHostImpl(const ToRenderFrameHost& frame) {
23 return static_cast<RenderFrameHostImpl*>(frame.render_frame_host()); 18 return static_cast<RenderFrameHostImpl*>(frame.render_frame_host());
24 } 19 }
25 20
26 } // namespace 21 } // namespace
(...skipping 20 matching lines...) Expand all
47 void TestFrameNavigationObserver::WaitForCommit() { 42 void TestFrameNavigationObserver::WaitForCommit() {
48 DCHECK_CURRENTLY_ON(BrowserThread::UI); 43 DCHECK_CURRENTLY_ON(BrowserThread::UI);
49 44
50 if (has_committed_) 45 if (has_committed_)
51 return; 46 return;
52 47
53 wait_for_commit_ = true; 48 wait_for_commit_ = true;
54 run_loop_.Run(); 49 run_loop_.Run();
55 } 50 }
56 51
57 void TestFrameNavigationObserver::DidStartProvisionalLoadForFrame( 52 void TestFrameNavigationObserver::DidStartNavigation(
58 RenderFrameHost* render_frame_host, 53 NavigationHandle* navigation_handle) {
59 const GURL& validated_url, 54 if (!navigation_handle->IsSamePage() &&
60 bool is_error_page) { 55 navigation_handle->GetFrameTreeNodeId() == frame_tree_node_id_) {
61 RenderFrameHostImpl* rfh =
62 static_cast<RenderFrameHostImpl*>(render_frame_host);
63 if (rfh->frame_tree_node()->frame_tree_node_id() == frame_tree_node_id_) {
64 navigation_started_ = true; 56 navigation_started_ = true;
65 has_committed_ = false; 57 has_committed_ = false;
66 } 58 }
67 } 59 }
68 60
69 void TestFrameNavigationObserver::DidCommitProvisionalLoadForFrame( 61 void TestFrameNavigationObserver::DidFinishNavigation(
70 RenderFrameHost* render_frame_host, 62 NavigationHandle* navigation_handle) {
71 const GURL& url,
72 ui::PageTransition transition_type) {
73 if (!navigation_started_) 63 if (!navigation_started_)
74 return; 64 return;
75 65
76 RenderFrameHostImpl* rfh = 66 if (!navigation_handle->HasCommitted() ||
77 static_cast<RenderFrameHostImpl*>(render_frame_host); 67 navigation_handle->IsErrorPage() ||
nasko 2017/01/26 14:51:20 I think DidCommitProvisionalLoadForFrame is gettin
jam 2017/01/26 16:04:12 Yeah we get a didfailprovisionalload for the URL a
78 if (rfh->frame_tree_node()->frame_tree_node_id() != frame_tree_node_id_) 68 navigation_handle->GetFrameTreeNodeId() != frame_tree_node_id_) {
79 return; 69 return;
70 }
80 71
81 has_committed_ = true; 72 has_committed_ = true;
82 if (wait_for_commit_) 73 if (wait_for_commit_)
83 run_loop_.Quit(); 74 run_loop_.Quit();
84 } 75 }
85 76
86 void TestFrameNavigationObserver::DidStopLoading() { 77 void TestFrameNavigationObserver::DidStopLoading() {
87 if (!navigation_started_) 78 if (!navigation_started_)
88 return; 79 return;
89 80
90 navigation_started_ = false; 81 navigation_started_ = false;
91 run_loop_.Quit(); 82 run_loop_.Quit();
92 } 83 }
93 84
94 } // namespace content 85 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_frame_navigation_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698