Chromium Code Reviews| 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..87300799b08241b540ecdaf6c81f41205f473d53 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,10 @@ class SafeBrowsingBlockingPageFactoryImpl |
| SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| SafeBrowsingUIManager* ui_manager, |
| WebContents* web_contents, |
| - const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| - override { |
| + const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources, |
| + const GURL& main_frame_url) override { |
| return new SafeBrowsingBlockingPage(ui_manager, web_contents, |
| - unsafe_resources); |
| + unsafe_resources, main_frame_url); |
| } |
| private: |
| @@ -135,12 +136,14 @@ content::InterstitialPageDelegate::TypeID |
| SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( |
| SafeBrowsingUIManager* ui_manager, |
| WebContents* web_contents, |
| - const UnsafeResourceList& unsafe_resources) |
| + const UnsafeResourceList& unsafe_resources, |
| + const GURL& main_frame_url) |
| : 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), |
|
Charlie Reis
2015/12/11 05:39:24
Any reason main_frame_url_ is listed before unsafe
mattm
2015/12/15 01:42:25
Not particularly. I wanted to keep main_frame_url_
|
| unsafe_resources_(unsafe_resources), |
| proceeded_(false) { |
| bool malware = false; |
| @@ -220,7 +223,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)); |
| } |
| @@ -375,9 +378,10 @@ void SafeBrowsingBlockingPage::OnProceed() { |
| // 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(), iter->second, |
| + // All queued unsafe resources should be for the same page: |
| + iter->second[0].GetNavigationEntryForResource()->GetURL()); |
| unsafe_resource_map->erase(iter); |
| } |
| @@ -469,14 +473,16 @@ SafeBrowsingBlockingPage::UnsafeResourceMap* |
| SafeBrowsingBlockingPage* SafeBrowsingBlockingPage::CreateBlockingPage( |
| SafeBrowsingUIManager* ui_manager, |
| WebContents* web_contents, |
| - const UnsafeResource& unsafe_resource) { |
| + const UnsafeResource& unsafe_resource, |
| + const GURL& main_frame_url) { |
| std::vector<UnsafeResource> resources; |
| resources.push_back(unsafe_resource); |
| // Set up the factory if this has not been done already (tests do that |
| // 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, resources, |
| + main_frame_url); |
| } |
| // static |
| @@ -500,8 +506,9 @@ void SafeBrowsingBlockingPage::ShowBlockingPage( |
| if (!interstitial) { |
| // There are no interstitial currently showing in that tab, go ahead and |
| // show this interstitial. |
| - SafeBrowsingBlockingPage* blocking_page = |
| - CreateBlockingPage(ui_manager, web_contents, unsafe_resource); |
| + SafeBrowsingBlockingPage* blocking_page = CreateBlockingPage( |
| + ui_manager, web_contents, unsafe_resource, |
| + unsafe_resource.GetNavigationEntryForResource()->GetURL()); |
| blocking_page->Show(); |
| return; |
| } |
| @@ -652,7 +659,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", |