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

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

Issue 1545973002: Remove the is_loading_ field from WebContentsImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + addressed Nasko's nits 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
290 // There's no need to reset the state: there's still an ongoing load, and the 292 // There's no need to reset the state: there's still an ongoing load, and the
291 // RenderFrameHostManager will take care of updates to the speculative 293 // RenderFrameHostManager will take care of updates to the speculative
292 // RenderFrameHost in DidCreateNavigationRequest below. 294 // RenderFrameHost in DidCreateNavigationRequest below.
293 ResetNavigationRequest(true); 295 if (was_previously_loading)
296 ResetNavigationRequest(true);
297
298 navigation_request_ = std::move(navigation_request);
299 render_manager()->DidCreateNavigationRequest(*navigation_request_);
294 300
295 // Force the throbber to start to keep it in sync with what is happening in 301 // Force the throbber to start to keep it in sync with what is happening in
296 // the UI. Blink doesn't send throb notifications for JavaScript URLs, so it 302 // the UI. Blink doesn't send throb notifications for JavaScript URLs, so it
297 // is not done here either. 303 // is not done here either.
298 if (!navigation_request->common_params().url.SchemeIs( 304 if (!navigation_request_->common_params().url.SchemeIs(
299 url::kJavaScriptScheme)) { 305 url::kJavaScriptScheme)) {
300 // TODO(fdegans): Check if this is a same-document navigation and set the 306 // TODO(fdegans): Check if this is a same-document navigation and set the
301 // proper argument. 307 // proper argument.
302 DidStartLoading(true); 308 DidStartLoading(true, was_previously_loading);
303 } 309 }
304
305 navigation_request_ = std::move(navigation_request);
306
307 render_manager()->DidCreateNavigationRequest(*navigation_request_);
308 } 310 }
309 311
310 void FrameTreeNode::ResetNavigationRequest(bool keep_state) { 312 void FrameTreeNode::ResetNavigationRequest(bool keep_state) {
311 CHECK(IsBrowserSideNavigationEnabled()); 313 CHECK(IsBrowserSideNavigationEnabled());
312 if (!navigation_request_) 314 if (!navigation_request_)
313 return; 315 return;
314 navigation_request_.reset(); 316 navigation_request_.reset();
315 317
316 if (keep_state) 318 if (keep_state)
317 return; 319 return;
318 320
319 // The RenderFrameHostManager should clean up any speculative RenderFrameHost 321 // The RenderFrameHostManager should clean up any speculative RenderFrameHost
320 // it created for the navigation. Also register that the load stopped. 322 // it created for the navigation. Also register that the load stopped.
321 DidStopLoading(); 323 DidStopLoading();
322 render_manager_.CleanUpNavigation(); 324 render_manager_.CleanUpNavigation();
323 } 325 }
324 326
325 bool FrameTreeNode::has_started_loading() const { 327 bool FrameTreeNode::has_started_loading() const {
326 return loading_progress_ != kLoadingProgressNotStarted; 328 return loading_progress_ != kLoadingProgressNotStarted;
327 } 329 }
328 330
329 void FrameTreeNode::reset_loading_progress() { 331 void FrameTreeNode::reset_loading_progress() {
330 loading_progress_ = kLoadingProgressNotStarted; 332 loading_progress_ = kLoadingProgressNotStarted;
331 } 333 }
332 334
333 void FrameTreeNode::DidStartLoading(bool to_different_document) { 335 void FrameTreeNode::DidStartLoading(bool to_different_document,
336 bool was_previously_loading) {
334 // Any main frame load to a new document should reset the load progress since 337 // Any main frame load to a new document should reset the load progress since
335 // it will replace the current page and any frames. The WebContents will 338 // it will replace the current page and any frames. The WebContents will
336 // be notified when DidChangeLoadProgress is called. 339 // be notified when DidChangeLoadProgress is called.
337 if (to_different_document && IsMainFrame()) 340 if (to_different_document && IsMainFrame())
338 frame_tree_->ResetLoadProgress(); 341 frame_tree_->ResetLoadProgress();
339 342
340 // Notify the WebContents. 343 // Notify the WebContents.
341 if (!frame_tree_->IsLoading()) 344 if (!was_previously_loading)
342 navigator()->GetDelegate()->DidStartLoading(this, to_different_document); 345 navigator()->GetDelegate()->DidStartLoading(this, to_different_document);
343 346
344 // Set initial load progress and update overall progress. This will notify 347 // Set initial load progress and update overall progress. This will notify
345 // the WebContents of the load progress change. 348 // the WebContents of the load progress change.
346 DidChangeLoadProgress(kLoadingProgressMinimum); 349 DidChangeLoadProgress(kLoadingProgressMinimum);
347 350
348 // Notify the RenderFrameHostManager of the event. 351 // Notify the RenderFrameHostManager of the event.
349 render_manager()->OnDidStartLoading(); 352 render_manager()->OnDidStartLoading();
350 } 353 }
351 354
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 401
399 render_manager_.Stop(); 402 render_manager_.Stop();
400 return true; 403 return true;
401 } 404 }
402 405
403 void FrameTreeNode::DidFocus() { 406 void FrameTreeNode::DidFocus() {
404 last_focus_time_ = base::TimeTicks::Now(); 407 last_focus_time_ = base::TimeTicks::Now();
405 FOR_EACH_OBSERVER(Observer, observers_, OnFrameTreeNodeFocused(this)); 408 FOR_EACH_OBSERVER(Observer, observers_, OnFrameTreeNodeFocused(this));
406 } 409 }
407 410
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
408 } // namespace content 433 } // 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