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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.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
Index: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index e4f71f1600b84c0669fe7a2dc0fabb5196d2ebad..a4d2f7e49a80d1bb1589eada7c92d2847848eb60 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -37,6 +37,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/renderer_preferences.h"
@@ -109,10 +110,11 @@ class SafeBrowsingBlockingPageFactoryImpl
SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
SafeBrowsingUIManager* ui_manager,
WebContents* web_contents,
+ const GURL& main_frame_url,
const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources)
override {
return new SafeBrowsingBlockingPage(ui_manager, web_contents,
- unsafe_resources);
+ main_frame_url, unsafe_resources);
}
private:
@@ -135,12 +137,14 @@ content::InterstitialPageDelegate::TypeID
SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
SafeBrowsingUIManager* ui_manager,
WebContents* web_contents,
+ const GURL& main_frame_url,
const UnsafeResourceList& unsafe_resources)
: SecurityInterstitialPage(web_contents, unsafe_resources[0].url),
malware_details_proceed_delay_ms_(
kMalwareDetailsProceedDelayMilliSeconds),
ui_manager_(ui_manager),
is_main_frame_load_blocked_(IsMainPageLoadBlocked(unsafe_resources)),
+ main_frame_url_(main_frame_url),
unsafe_resources_(unsafe_resources),
proceeded_(false) {
bool malware = false;
@@ -220,7 +224,7 @@ bool SafeBrowsingBlockingPage::ShouldReportThreatDetails(
bool SafeBrowsingBlockingPage::CanShowThreatDetailsOption() {
return (!web_contents()->GetBrowserContext()->IsOffTheRecord() &&
- web_contents()->GetURL().SchemeIs(url::kHttpScheme) &&
+ main_frame_url_.SchemeIs(url::kHttpScheme) &&
IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingOptInAllowed));
}
@@ -372,12 +376,15 @@ void SafeBrowsingBlockingPage::OnProceed() {
UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents());
SafeBrowsingBlockingPage* blocking_page = NULL;
if (iter != unsafe_resource_map->end() && !iter->second.empty()) {
+ // All queued unsafe resources should be for the same page:
+ content::NavigationEntry* entry =
+ iter->second[0].GetNavigationEntryForResource();
// Build an interstitial for all the unsafe resources notifications.
// Don't show it now as showing an interstitial while an interstitial is
// already showing would cause DontProceed() to be invoked.
- blocking_page = factory_->CreateSafeBrowsingPage(ui_manager_,
- web_contents(),
- iter->second);
+ blocking_page = factory_->CreateSafeBrowsingPage(
+ ui_manager_, web_contents(), entry ? entry->GetURL() : GURL(),
+ iter->second);
unsafe_resource_map->erase(iter);
}
@@ -469,6 +476,7 @@ SafeBrowsingBlockingPage::UnsafeResourceMap*
SafeBrowsingBlockingPage* SafeBrowsingBlockingPage::CreateBlockingPage(
SafeBrowsingUIManager* ui_manager,
WebContents* web_contents,
+ const GURL& main_frame_url,
const UnsafeResource& unsafe_resource) {
std::vector<UnsafeResource> resources;
resources.push_back(unsafe_resource);
@@ -476,7 +484,8 @@ SafeBrowsingBlockingPage* SafeBrowsingBlockingPage::CreateBlockingPage(
// before this method is called).
if (!factory_)
factory_ = g_safe_browsing_blocking_page_factory_impl.Pointer();
- return factory_->CreateSafeBrowsingPage(ui_manager, web_contents, resources);
+ return factory_->CreateSafeBrowsingPage(ui_manager, web_contents,
+ main_frame_url, resources);
}
// static
@@ -500,8 +509,11 @@ void SafeBrowsingBlockingPage::ShowBlockingPage(
if (!interstitial) {
// There are no interstitial currently showing in that tab, go ahead and
// show this interstitial.
+ content::NavigationEntry* entry =
+ unsafe_resource.GetNavigationEntryForResource();
SafeBrowsingBlockingPage* blocking_page =
- CreateBlockingPage(ui_manager, web_contents, unsafe_resource);
+ CreateBlockingPage(ui_manager, web_contents,
+ entry ? entry->GetURL() : GURL(), unsafe_resource);
blocking_page->Show();
return;
}
@@ -652,7 +664,7 @@ void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData(
GetFormattedHostName()) :
l10n_util::GetStringFUTF16(
IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_SUBRESOURCE,
- base::UTF8ToUTF16(web_contents()->GetURL().host()),
+ base::UTF8ToUTF16(main_frame_url_.host()),
GetFormattedHostName()));
load_time_data->SetString(
"finalParagraph",

Powered by Google App Engine
This is Rietveld 408576698