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

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

Issue 2741313002: Renamed WasWithinSamePage to WasWithinSameDocument. (Closed)
Patch Set: Addressed review comments Created 3 years, 9 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/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 std::unique_ptr<NavigationHandleImpl> navigation_handle) { 545 std::unique_ptr<NavigationHandleImpl> navigation_handle) {
546 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); 546 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree();
547 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); 547 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible();
548 548
549 bool has_embedded_credentials = 549 bool has_embedded_credentials =
550 params.url.has_username() || params.url.has_password(); 550 params.url.has_username() || params.url.has_password();
551 UMA_HISTOGRAM_BOOLEAN("Navigation.FrameHasEmbeddedCredentials", 551 UMA_HISTOGRAM_BOOLEAN("Navigation.FrameHasEmbeddedCredentials",
552 has_embedded_credentials); 552 has_embedded_credentials);
553 553
554 bool is_navigation_within_page = controller_->IsURLInPageNavigation( 554 bool is_navigation_within_page = controller_->IsURLInPageNavigation(
555 params.url, params.origin, params.was_within_same_page, 555 params.url, params.origin, params.was_within_same_document,
556 render_frame_host); 556 render_frame_host);
557 557
558 // If a frame claims it navigated within page, it must be the current frame, 558 // If a frame claims it navigated within page, it must be the current frame,
559 // not a pending one. 559 // not a pending one.
560 if (is_navigation_within_page && 560 if (is_navigation_within_page &&
561 render_frame_host != 561 render_frame_host !=
562 render_frame_host->frame_tree_node() 562 render_frame_host->frame_tree_node()
563 ->render_manager() 563 ->render_manager()
564 ->current_frame_host()) { 564 ->current_frame_host()) {
565 bad_message::ReceivedBadMessage(render_frame_host->GetProcess(), 565 bad_message::ReceivedBadMessage(render_frame_host->GetProcess(),
566 bad_message::NI_IN_PAGE_NAVIGATION); 566 bad_message::NI_IN_PAGE_NAVIGATION);
567 is_navigation_within_page = false; 567 is_navigation_within_page = false;
568 } 568 }
569 569
570 if (ui::PageTransitionIsMainFrame(params.transition)) { 570 if (ui::PageTransitionIsMainFrame(params.transition)) {
571 if (delegate_) { 571 if (delegate_) {
572 // When overscroll navigation gesture is enabled, a screenshot of the page 572 // When overscroll navigation gesture is enabled, a screenshot of the page
573 // in its current state is taken so that it can be used during the 573 // in its current state is taken so that it can be used during the
574 // nav-gesture. It is necessary to take the screenshot here, before 574 // nav-gesture. It is necessary to take the screenshot here, before
575 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can 575 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can
576 // change WebContents::GetRenderViewHost to return the new host, instead 576 // change WebContents::GetRenderViewHost to return the new host, instead
577 // of the one that may have just been swapped out. 577 // of the one that may have just been swapped out.
578 if (delegate_->CanOverscrollContent()) { 578 if (delegate_->CanOverscrollContent()) {
579 // Don't take screenshots if we are staying on the same page. We want 579 // Don't take screenshots if we are staying on the same document. We
580 // in-page navigations to be super fast, and taking a screenshot 580 // want same-document navigations to be super fast, and taking a
581 // currently blocks GPU for a longer time than we are willing to 581 // screenshot currently blocks GPU for a longer time than we are willing
582 // tolerate in this use case. 582 // to tolerate in this use case.
583 if (!params.was_within_same_page) 583 if (!params.was_within_same_document)
584 controller_->TakeScreenshot(); 584 controller_->TakeScreenshot();
585 } 585 }
586 586
587 // Run tasks that must execute just before the commit. 587 // Run tasks that must execute just before the commit.
588 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); 588 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page);
589 589
590 UMA_HISTOGRAM_BOOLEAN("Navigation.MainFrameHasEmbeddedCredentials", 590 UMA_HISTOGRAM_BOOLEAN("Navigation.MainFrameHasEmbeddedCredentials",
591 has_embedded_credentials); 591 has_embedded_credentials);
592 } 592 }
593 593
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 NavigationEntry* pending_entry = controller_->GetPendingEntry(); 1083 NavigationEntry* pending_entry = controller_->GetPendingEntry();
1084 bool pending_matches_fail_msg = 1084 bool pending_matches_fail_msg =
1085 handle && pending_entry && 1085 handle && pending_entry &&
1086 handle->pending_nav_entry_id() == pending_entry->GetUniqueID(); 1086 handle->pending_nav_entry_id() == pending_entry->GetUniqueID();
1087 if (!pending_matches_fail_msg) 1087 if (!pending_matches_fail_msg)
1088 return; 1088 return;
1089 1089
1090 // We usually clear the pending entry when it fails, so that an arbitrary URL 1090 // We usually clear the pending entry when it fails, so that an arbitrary URL
1091 // isn't left visible above a committed page. This must be enforced when the 1091 // isn't left visible above a committed page. This must be enforced when the
1092 // pending entry isn't visible (e.g., renderer-initiated navigations) to 1092 // pending entry isn't visible (e.g., renderer-initiated navigations) to
1093 // prevent URL spoofs for in-page navigations that don't go through 1093 // prevent URL spoofs for same-document navigations that don't go through
1094 // DidStartProvisionalLoadForFrame. 1094 // DidStartProvisionalLoadForFrame.
1095 // 1095 //
1096 // However, we do preserve the pending entry in some cases, such as on the 1096 // However, we do preserve the pending entry in some cases, such as on the
1097 // initial navigation of an unmodified blank tab. We also allow the delegate 1097 // initial navigation of an unmodified blank tab. We also allow the delegate
1098 // to say when it's safe to leave aborted URLs in the omnibox, to let the 1098 // to say when it's safe to leave aborted URLs in the omnibox, to let the
1099 // user edit the URL and try again. This may be useful in cases that the 1099 // user edit the URL and try again. This may be useful in cases that the
1100 // committed page cannot be attacker-controlled. In these cases, we still 1100 // committed page cannot be attacker-controlled. In these cases, we still
1101 // allow the view to clear the pending entry and typed URL if the user 1101 // allow the view to clear the pending entry and typed URL if the user
1102 // requests (e.g., hitting Escape with focus in the address bar). 1102 // requests (e.g., hitting Escape with focus in the address bar).
1103 // 1103 //
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 if (navigation_handle) 1291 if (navigation_handle)
1292 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1292 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1293 1293
1294 controller_->SetPendingEntry(std::move(entry)); 1294 controller_->SetPendingEntry(std::move(entry));
1295 if (delegate_) 1295 if (delegate_)
1296 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1296 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1297 } 1297 }
1298 } 1298 }
1299 1299
1300 } // namespace content 1300 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.cc ('k') | content/browser/frame_host/navigator_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698