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

Side by Side Diff: content/test/test_web_contents.cc

Issue 1545973002: Remove the is_loading_ field from WebContentsImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Nasko's comments Created 4 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
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/test/test_web_contents.h" 5 #include "content/test/test_web_contents.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/browser/browser_url_handler_impl.h" 9 #include "content/browser/browser_url_handler_impl.h"
10 #include "content/browser/frame_host/cross_process_frame_connector.h" 10 #include "content/browser/frame_host/cross_process_frame_connector.h"
11 #include "content/browser/frame_host/navigation_entry_impl.h" 11 #include "content/browser/frame_host/navigation_entry_impl.h"
12 #include "content/browser/frame_host/navigator.h" 12 #include "content/browser/frame_host/navigator.h"
13 #include "content/browser/frame_host/navigator_impl.h" 13 #include "content/browser/frame_host/navigator_impl.h"
14 #include "content/browser/renderer_host/render_view_host_impl.h" 14 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/browser/site_instance_impl.h" 15 #include "content/browser/site_instance_impl.h"
16 #include "content/common/frame_messages.h" 16 #include "content/common/frame_messages.h"
17 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
20 #include "content/public/browser/notification_types.h" 20 #include "content/public/browser/notification_types.h"
21 #include "content/public/common/browser_side_navigation_policy.h" 21 #include "content/public/common/browser_side_navigation_policy.h"
22 #include "content/public/common/page_state.h" 22 #include "content/public/common/page_state.h"
23 #include "content/public/test/mock_render_process_host.h" 23 #include "content/public/test/mock_render_process_host.h"
24 #include "content/test/test_render_view_host.h" 24 #include "content/test/test_render_view_host.h"
25 #include "ui/base/page_transition_types.h" 25 #include "ui/base/page_transition_types.h"
26 26
27 namespace content { 27 namespace content {
28 28
29 namespace {
30
31 bool UnsetLoadStateForTest(FrameTreeNode* node) {
32 RenderFrameHostImpl* current_frame_host =
33 node->render_manager()->current_frame_host();
34 DCHECK(current_frame_host);
35 current_frame_host->ResetLoadingState();
36
37 RenderFrameHostImpl* pending_frame_host =
38 node->render_manager()->pending_frame_host();
39 if (pending_frame_host)
40 pending_frame_host->ResetLoadingState();
41
42 if (IsBrowserSideNavigationEnabled()) {
carlosk 2016/01/15 17:24:04 nit: same as the other case.
clamy 2016/01/19 13:31:19 Done.
43 RenderFrameHostImpl* speculative_frame_host =
44 node->render_manager()->speculative_frame_host();
45 if (speculative_frame_host)
46 speculative_frame_host->ResetLoadingState();
47 }
48 return true;
49 }
50
51 }
52
29 TestWebContents::TestWebContents(BrowserContext* browser_context) 53 TestWebContents::TestWebContents(BrowserContext* browser_context)
30 : WebContentsImpl(browser_context), 54 : WebContentsImpl(browser_context),
31 delegate_view_override_(NULL), 55 delegate_view_override_(NULL),
32 expect_set_history_offset_and_length_(false), 56 expect_set_history_offset_and_length_(false),
33 expect_set_history_offset_and_length_history_length_(0) { 57 expect_set_history_offset_and_length_history_length_(0) {
34 } 58 }
35 59
36 TestWebContents* TestWebContents::Create(BrowserContext* browser_context, 60 TestWebContents* TestWebContents::Create(BrowserContext* browser_context,
37 SiteInstance* instance) { 61 SiteInstance* instance) {
38 TestWebContents* test_web_contents = new TestWebContents(browser_context); 62 TestWebContents* test_web_contents = new TestWebContents(browser_context);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 GURL loaded_url(url); 206 GURL loaded_url(url);
183 bool reverse_on_redirect = false; 207 bool reverse_on_redirect = false;
184 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary( 208 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary(
185 &loaded_url, GetBrowserContext(), &reverse_on_redirect); 209 &loaded_url, GetBrowserContext(), &reverse_on_redirect);
186 // LoadURL created a navigation entry, now simulate the RenderView sending 210 // LoadURL created a navigation entry, now simulate the RenderView sending
187 // a notification that it actually navigated. 211 // a notification that it actually navigated.
188 CommitPendingNavigation(); 212 CommitPendingNavigation();
189 } 213 }
190 214
191 void TestWebContents::TestSetIsLoading(bool value) { 215 void TestWebContents::TestSetIsLoading(bool value) {
192 SetIsLoading(value, true, nullptr); 216 if (value)
217 DidStartLoading(GetMainFrame()->frame_tree_node(), true);
218 else
219 frame_tree_.ForEach(base::Bind(&UnsetLoadStateForTest));
193 } 220 }
194 221
195 void TestWebContents::CommitPendingNavigation() { 222 void TestWebContents::CommitPendingNavigation() {
196 const NavigationEntry* entry = GetController().GetPendingEntry(); 223 const NavigationEntry* entry = GetController().GetPendingEntry();
197 DCHECK(entry); 224 DCHECK(entry);
198 225
199 // If we are doing a cross-site navigation, this simulates the current RFH 226 // If we are doing a cross-site navigation, this simulates the current RFH
200 // notifying that it has unloaded so the pending RFH is resumed and can 227 // notifying that it has unloaded so the pending RFH is resumed and can
201 // navigate. 228 // navigate.
202 // PlzNavigate: the pending RFH is not created before the navigation commit, 229 // PlzNavigate: the pending RFH is not created before the navigation commit,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { 349 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) {
323 } 350 }
324 351
325 void TestWebContents::SaveFrameWithHeaders(const GURL& url, 352 void TestWebContents::SaveFrameWithHeaders(const GURL& url,
326 const Referrer& referrer, 353 const Referrer& referrer,
327 const std::string& headers) { 354 const std::string& headers) {
328 save_frame_headers_ = headers; 355 save_frame_headers_ = headers;
329 } 356 }
330 357
331 } // namespace content 358 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698