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

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

Issue 958083002: PlzNavigate: Show error pages when the navigation failed before commit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@support-data-urls
Patch Set: Added a browsertest Created 5 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_navigation_observer.h" 5 #include "content/public/test/test_navigation_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ui::PageTransition transition_type) override { 69 ui::PageTransition transition_type) override {
70 parent_->OnDidCommitProvisionalLoadForFrame( 70 parent_->OnDidCommitProvisionalLoadForFrame(
71 render_frame_host, url, transition_type); 71 render_frame_host, url, transition_type);
72 } 72 }
73 73
74 TestNavigationObserver* parent_; 74 TestNavigationObserver* parent_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); 76 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver);
77 }; 77 };
78 78
79 TestNavigationObserver::TestNavigationObserver( 79 TestNavigationObserver::TestNavigationObserver(WebContents* web_contents,
80 WebContents* web_contents, 80 int number_of_navigations)
81 int number_of_navigations)
82 : navigation_started_(false), 81 : navigation_started_(false),
83 navigations_completed_(0), 82 navigations_completed_(0),
84 number_of_navigations_(number_of_navigations), 83 number_of_navigations_(number_of_navigations),
84 navigations_failed_(0),
85 message_loop_runner_(new MessageLoopRunner), 85 message_loop_runner_(new MessageLoopRunner),
86 web_contents_created_callback_( 86 web_contents_created_callback_(
87 base::Bind( 87 base::Bind(&TestNavigationObserver::OnWebContentsCreated,
88 &TestNavigationObserver::OnWebContentsCreated, 88 base::Unretained(this))) {
89 base::Unretained(this))) {
90 if (web_contents) 89 if (web_contents)
91 RegisterAsObserver(web_contents); 90 RegisterAsObserver(web_contents);
92 } 91 }
93 92
94 TestNavigationObserver::TestNavigationObserver( 93 TestNavigationObserver::TestNavigationObserver(WebContents* web_contents)
95 WebContents* web_contents)
96 : navigation_started_(false), 94 : navigation_started_(false),
97 navigations_completed_(0), 95 navigations_completed_(0),
98 number_of_navigations_(1), 96 number_of_navigations_(1),
97 navigations_failed_(0),
99 message_loop_runner_(new MessageLoopRunner), 98 message_loop_runner_(new MessageLoopRunner),
100 web_contents_created_callback_( 99 web_contents_created_callback_(
101 base::Bind( 100 base::Bind(&TestNavigationObserver::OnWebContentsCreated,
102 &TestNavigationObserver::OnWebContentsCreated, 101 base::Unretained(this))) {
103 base::Unretained(this))) {
104 if (web_contents) 102 if (web_contents)
105 RegisterAsObserver(web_contents); 103 RegisterAsObserver(web_contents);
106 } 104 }
107 105
108 TestNavigationObserver::~TestNavigationObserver() { 106 TestNavigationObserver::~TestNavigationObserver() {
109 StopWatchingNewWebContents(); 107 StopWatchingNewWebContents();
110 108
111 STLDeleteContainerPointers(web_contents_observers_.begin(), 109 STLDeleteContainerPointers(web_contents_observers_.begin(),
112 web_contents_observers_.end()); 110 web_contents_observers_.end());
113 } 111 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 last_navigation_succeeded_ = false; 177 last_navigation_succeeded_ = false;
180 } 178 }
181 179
182 void TestNavigationObserver::OnDidFailProvisionalLoad( 180 void TestNavigationObserver::OnDidFailProvisionalLoad(
183 RenderFrameHost* render_frame_host, 181 RenderFrameHost* render_frame_host,
184 const GURL& validated_url, 182 const GURL& validated_url,
185 int error_code, 183 int error_code,
186 const base::string16& error_description) { 184 const base::string16& error_description) {
187 last_navigation_url_ = validated_url; 185 last_navigation_url_ = validated_url;
188 last_navigation_succeeded_ = false; 186 last_navigation_succeeded_ = false;
187 ++navigations_failed_;
189 } 188 }
190 189
191 void TestNavigationObserver::OnDidCommitProvisionalLoadForFrame( 190 void TestNavigationObserver::OnDidCommitProvisionalLoadForFrame(
192 RenderFrameHost* render_frame_host, 191 RenderFrameHost* render_frame_host,
193 const GURL& url, 192 const GURL& url,
194 ui::PageTransition transition_type) { 193 ui::PageTransition transition_type) {
195 last_navigation_url_ = url; 194 last_navigation_url_ = url;
196 last_navigation_succeeded_ = true; 195 last_navigation_succeeded_ = true;
197 } 196 }
198 197
199 } // namespace content 198 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698