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

Unified Diff: chrome/browser/safe_browsing/client_side_detection_host.cc

Issue 1509073002: Fixes for Safe Browsing with unrelated pending navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes for comment #13-15 Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/client_side_detection_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/client_side_detection_host.cc
diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc
index ef73fb4f7265b6025066d1d1a4cf19a19d84220b..5e5476b19cf31ed1cdd02ad5eea58ee7971a2ae6 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host.cc
@@ -405,7 +405,7 @@ void ClientSideDetectionHost::DidNavigateMainFrame(
void ClientSideDetectionHost::OnSafeBrowsingHit(
const SafeBrowsingUIManager::UnsafeResource& resource) {
- if (!web_contents() || !web_contents()->GetController().GetActiveEntry())
+ if (!web_contents())
return;
// Check that the hit is either malware or phishing.
@@ -420,9 +420,12 @@ void ClientSideDetectionHost::OnSafeBrowsingHit(
web_contents() != content::WebContents::FromRenderViewHost(hit_rvh))
return;
+ NavigationEntry *entry = resource.GetNavigationEntryForResource();
+ if (!entry)
+ return;
+
// Store the unique page ID for later.
- unsafe_unique_page_id_ =
- web_contents()->GetController().GetActiveEntry()->GetUniqueID();
+ unsafe_unique_page_id_ = entry->GetUniqueID();
// We also keep the resource around in order to be able to send the
// malicious URL to the server.
@@ -673,8 +676,14 @@ bool ClientSideDetectionHost::DidShowSBInterstitial() const {
if (unsafe_unique_page_id_ <= 0 || !web_contents()) {
return false;
}
+ // DidShowSBInterstitial is called after client side detection is finished to
+ // see if a SB interstitial was shown on the same page. Client Side Detection
+ // only runs on the currently committed page, so an unconditional
+ // GetLastCommittedEntry is correct here. GetNavigationEntryForResource cannot
+ // be used since it may no longer be valid (eg, if the UnsafeResource was for
+ // a blocking main page load which was then proceeded through).
const NavigationEntry* nav_entry =
- web_contents()->GetController().GetActiveEntry();
+ web_contents()->GetController().GetLastCommittedEntry();
return (nav_entry && nav_entry->GetUniqueID() == unsafe_unique_page_id_);
}
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/client_side_detection_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698