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

Side by Side Diff: content/browser/frame_host/frame_tree_node.cc

Issue 1690633002: Revert of Remove the is_loading_ field from WebContentsImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/frame_host/frame_tree_node.h" 5 #include "content/browser/frame_host/frame_tree_node.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 bool did_change_flags = 280 bool did_change_flags =
281 pending_sandbox_flags_ != replication_state_.sandbox_flags; 281 pending_sandbox_flags_ != replication_state_.sandbox_flags;
282 replication_state_.sandbox_flags = pending_sandbox_flags_; 282 replication_state_.sandbox_flags = pending_sandbox_flags_;
283 return did_change_flags; 283 return did_change_flags;
284 } 284 }
285 285
286 void FrameTreeNode::CreatedNavigationRequest( 286 void FrameTreeNode::CreatedNavigationRequest(
287 scoped_ptr<NavigationRequest> navigation_request) { 287 scoped_ptr<NavigationRequest> navigation_request) {
288 CHECK(IsBrowserSideNavigationEnabled()); 288 CHECK(IsBrowserSideNavigationEnabled());
289 289
290 bool was_previously_loading = frame_tree()->IsLoading();
291
292 // There's no need to reset the state: there's still an ongoing load, and the 290 // There's no need to reset the state: there's still an ongoing load, and the
293 // RenderFrameHostManager will take care of updates to the speculative 291 // RenderFrameHostManager will take care of updates to the speculative
294 // RenderFrameHost in DidCreateNavigationRequest below. 292 // RenderFrameHost in DidCreateNavigationRequest below.
295 if (was_previously_loading) 293 ResetNavigationRequest(true);
296 ResetNavigationRequest(true);
297
298 navigation_request_ = std::move(navigation_request);
299 render_manager()->DidCreateNavigationRequest(*navigation_request_);
300 294
301 // Force the throbber to start to keep it in sync with what is happening in 295 // Force the throbber to start to keep it in sync with what is happening in
302 // the UI. Blink doesn't send throb notifications for JavaScript URLs, so it 296 // the UI. Blink doesn't send throb notifications for JavaScript URLs, so it
303 // is not done here either. 297 // is not done here either.
304 if (!navigation_request_->common_params().url.SchemeIs( 298 if (!navigation_request->common_params().url.SchemeIs(
305 url::kJavaScriptScheme)) { 299 url::kJavaScriptScheme)) {
306 // TODO(fdegans): Check if this is a same-document navigation and set the 300 // TODO(fdegans): Check if this is a same-document navigation and set the
307 // proper argument. 301 // proper argument.
308 DidStartLoading(true, was_previously_loading); 302 DidStartLoading(true);
309 } 303 }
304
305 navigation_request_ = std::move(navigation_request);
306
307 render_manager()->DidCreateNavigationRequest(*navigation_request_);
310 } 308 }
311 309
312 void FrameTreeNode::ResetNavigationRequest(bool keep_state) { 310 void FrameTreeNode::ResetNavigationRequest(bool keep_state) {
313 CHECK(IsBrowserSideNavigationEnabled()); 311 CHECK(IsBrowserSideNavigationEnabled());
314 if (!navigation_request_) 312 if (!navigation_request_)
315 return; 313 return;
316 navigation_request_.reset(); 314 navigation_request_.reset();
317 315
318 if (keep_state) 316 if (keep_state)
319 return; 317 return;
320 318
321 // The RenderFrameHostManager should clean up any speculative RenderFrameHost 319 // The RenderFrameHostManager should clean up any speculative RenderFrameHost
322 // it created for the navigation. Also register that the load stopped. 320 // it created for the navigation. Also register that the load stopped.
323 DidStopLoading(); 321 DidStopLoading();
324 render_manager_.CleanUpNavigation(); 322 render_manager_.CleanUpNavigation();
325 } 323 }
326 324
327 bool FrameTreeNode::has_started_loading() const { 325 bool FrameTreeNode::has_started_loading() const {
328 return loading_progress_ != kLoadingProgressNotStarted; 326 return loading_progress_ != kLoadingProgressNotStarted;
329 } 327 }
330 328
331 void FrameTreeNode::reset_loading_progress() { 329 void FrameTreeNode::reset_loading_progress() {
332 loading_progress_ = kLoadingProgressNotStarted; 330 loading_progress_ = kLoadingProgressNotStarted;
333 } 331 }
334 332
335 void FrameTreeNode::DidStartLoading(bool to_different_document, 333 void FrameTreeNode::DidStartLoading(bool to_different_document) {
336 bool was_previously_loading) {
337 // Any main frame load to a new document should reset the load progress since 334 // Any main frame load to a new document should reset the load progress since
338 // it will replace the current page and any frames. The WebContents will 335 // it will replace the current page and any frames. The WebContents will
339 // be notified when DidChangeLoadProgress is called. 336 // be notified when DidChangeLoadProgress is called.
340 if (to_different_document && IsMainFrame()) 337 if (to_different_document && IsMainFrame())
341 frame_tree_->ResetLoadProgress(); 338 frame_tree_->ResetLoadProgress();
342 339
343 // Notify the WebContents. 340 // Notify the WebContents.
344 if (!was_previously_loading) 341 if (!frame_tree_->IsLoading())
345 navigator()->GetDelegate()->DidStartLoading(this, to_different_document); 342 navigator()->GetDelegate()->DidStartLoading(this, to_different_document);
346 343
347 // Set initial load progress and update overall progress. This will notify 344 // Set initial load progress and update overall progress. This will notify
348 // the WebContents of the load progress change. 345 // the WebContents of the load progress change.
349 DidChangeLoadProgress(kLoadingProgressMinimum); 346 DidChangeLoadProgress(kLoadingProgressMinimum);
350 347
351 // Notify the RenderFrameHostManager of the event. 348 // Notify the RenderFrameHostManager of the event.
352 render_manager()->OnDidStartLoading(); 349 render_manager()->OnDidStartLoading();
353 } 350 }
354 351
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 398
402 render_manager_.Stop(); 399 render_manager_.Stop();
403 return true; 400 return true;
404 } 401 }
405 402
406 void FrameTreeNode::DidFocus() { 403 void FrameTreeNode::DidFocus() {
407 last_focus_time_ = base::TimeTicks::Now(); 404 last_focus_time_ = base::TimeTicks::Now();
408 FOR_EACH_OBSERVER(Observer, observers_, OnFrameTreeNodeFocused(this)); 405 FOR_EACH_OBSERVER(Observer, observers_, OnFrameTreeNodeFocused(this));
409 } 406 }
410 407
411 void FrameTreeNode::BeforeUnloadCanceled() {
412 if (!IsMainFrame())
413 return;
414
415 RenderFrameHostImpl* current_frame_host =
416 render_manager_.current_frame_host();
417 DCHECK(current_frame_host);
418 current_frame_host->ResetLoadingState();
419
420 if (IsBrowserSideNavigationEnabled()) {
421 RenderFrameHostImpl* speculative_frame_host =
422 render_manager_.speculative_frame_host();
423 if (speculative_frame_host)
424 speculative_frame_host->ResetLoadingState();
425 } else {
426 RenderFrameHostImpl* pending_frame_host =
427 render_manager_.pending_frame_host();
428 if (pending_frame_host)
429 pending_frame_host->ResetLoadingState();
430 }
431 }
432
433 } // namespace content 408 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node.h ('k') | content/browser/frame_host/interstitial_page_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698