| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Implementation of the SafeBrowsingBlockingPage class. | 5 // Implementation of the SafeBrowsingBlockingPage class. |
| 6 | 6 |
| 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // static | 124 // static |
| 125 content::InterstitialPageDelegate::TypeID | 125 content::InterstitialPageDelegate::TypeID |
| 126 SafeBrowsingBlockingPage::kTypeForTesting = | 126 SafeBrowsingBlockingPage::kTypeForTesting = |
| 127 &SafeBrowsingBlockingPage::kTypeForTesting; | 127 &SafeBrowsingBlockingPage::kTypeForTesting; |
| 128 | 128 |
| 129 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( | 129 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( |
| 130 SafeBrowsingUIManager* ui_manager, | 130 SafeBrowsingUIManager* ui_manager, |
| 131 WebContents* web_contents, | 131 WebContents* web_contents, |
| 132 const GURL& main_frame_url, | 132 const GURL& main_frame_url, |
| 133 const UnsafeResourceList& unsafe_resources) | 133 const UnsafeResourceList& unsafe_resources) |
| 134 : SecurityInterstitialPage(web_contents, unsafe_resources[0].url), | 134 : SecurityInterstitialPage( |
| 135 web_contents, |
| 136 unsafe_resources[0].url, |
| 137 CreateMetricsHelper(web_contents, unsafe_resources)), |
| 135 threat_details_proceed_delay_ms_(kThreatDetailsProceedDelayMilliSeconds), | 138 threat_details_proceed_delay_ms_(kThreatDetailsProceedDelayMilliSeconds), |
| 136 ui_manager_(ui_manager), | 139 ui_manager_(ui_manager), |
| 137 is_main_frame_load_blocked_(IsMainPageLoadBlocked(unsafe_resources)), | 140 is_main_frame_load_blocked_(IsMainPageLoadBlocked(unsafe_resources)), |
| 138 main_frame_url_(main_frame_url), | 141 main_frame_url_(main_frame_url), |
| 139 unsafe_resources_(unsafe_resources), | 142 unsafe_resources_(unsafe_resources), |
| 140 proceeded_(false) { | 143 proceeded_(false), |
| 141 bool malware = false; | 144 interstitial_reason_(GetInterstitialReason(unsafe_resources)) { |
| 142 bool harmful = false; | 145 controller()->metrics_helper()->RecordUserDecision( |
| 143 bool phishing = false; | |
| 144 for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin(); | |
| 145 iter != unsafe_resources_.end(); ++iter) { | |
| 146 const UnsafeResource& resource = *iter; | |
| 147 SBThreatType threat_type = resource.threat_type; | |
| 148 if (threat_type == SB_THREAT_TYPE_URL_MALWARE || | |
| 149 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) { | |
| 150 malware = true; | |
| 151 } else if (threat_type == SB_THREAT_TYPE_URL_UNWANTED) { | |
| 152 harmful = true; | |
| 153 } else { | |
| 154 DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING || | |
| 155 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); | |
| 156 phishing = true; | |
| 157 } | |
| 158 } | |
| 159 DCHECK(phishing || malware || harmful); | |
| 160 if (malware) | |
| 161 interstitial_reason_ = SB_REASON_MALWARE; | |
| 162 else if (harmful) | |
| 163 interstitial_reason_ = SB_REASON_HARMFUL; | |
| 164 else | |
| 165 interstitial_reason_ = SB_REASON_PHISHING; | |
| 166 | |
| 167 // This must be done after calculating |interstitial_reason_| above. | |
| 168 security_interstitials::MetricsHelper::ReportDetails reporting_info; | |
| 169 reporting_info.metric_prefix = GetMetricPrefix(); | |
| 170 reporting_info.extra_suffix = GetExtraMetricsSuffix(); | |
| 171 reporting_info.rappor_prefix = GetRapporPrefix(); | |
| 172 reporting_info.deprecated_rappor_prefix = GetDeprecatedRapporPrefix(); | |
| 173 reporting_info.rappor_report_type = | |
| 174 rappor::LOW_FREQUENCY_SAFEBROWSING_RAPPOR_TYPE; | |
| 175 reporting_info.deprecated_rappor_report_type = | |
| 176 rappor::SAFEBROWSING_RAPPOR_TYPE; | |
| 177 set_metrics_helper(base::MakeUnique<ChromeMetricsHelper>( | |
| 178 web_contents, request_url(), reporting_info, GetSamplingEventName())); | |
| 179 metrics_helper()->RecordUserDecision( | |
| 180 security_interstitials::MetricsHelper::SHOW); | 146 security_interstitials::MetricsHelper::SHOW); |
| 181 metrics_helper()->RecordUserInteraction( | 147 controller()->metrics_helper()->RecordUserInteraction( |
| 182 security_interstitials::MetricsHelper::TOTAL_VISITS); | 148 security_interstitials::MetricsHelper::TOTAL_VISITS); |
| 183 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { | 149 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { |
| 184 metrics_helper()->RecordUserDecision( | 150 controller()->metrics_helper()->RecordUserDecision( |
| 185 security_interstitials::MetricsHelper::PROCEEDING_DISABLED); | 151 security_interstitials::MetricsHelper::PROCEEDING_DISABLED); |
| 186 } | 152 } |
| 187 | 153 |
| 188 if (!is_main_frame_load_blocked_) { | 154 if (!is_main_frame_load_blocked_) { |
| 189 navigation_entry_index_to_remove_ = | 155 navigation_entry_index_to_remove_ = |
| 190 web_contents->GetController().GetLastCommittedEntryIndex(); | 156 web_contents->GetController().GetLastCommittedEntryIndex(); |
| 191 } else { | 157 } else { |
| 192 navigation_entry_index_to_remove_ = -1; | 158 navigation_entry_index_to_remove_ = -1; |
| 193 } | 159 } |
| 194 | 160 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 Profile* profile = Profile::FromBrowserContext( | 314 Profile* profile = Profile::FromBrowserContext( |
| 349 web_contents()->GetBrowserContext()); | 315 web_contents()->GetBrowserContext()); |
| 350 renderer_preferences_util::UpdateFromSystemSettings( | 316 renderer_preferences_util::UpdateFromSystemSettings( |
| 351 prefs, profile, web_contents()); | 317 prefs, profile, web_contents()); |
| 352 } | 318 } |
| 353 | 319 |
| 354 void SafeBrowsingBlockingPage::OnProceed() { | 320 void SafeBrowsingBlockingPage::OnProceed() { |
| 355 proceeded_ = true; | 321 proceeded_ = true; |
| 356 // Send the threat details, if we opted to. | 322 // Send the threat details, if we opted to. |
| 357 FinishThreatDetails(threat_details_proceed_delay_ms_, true, /* did_proceed */ | 323 FinishThreatDetails(threat_details_proceed_delay_ms_, true, /* did_proceed */ |
| 358 metrics_helper()->NumVisits()); | 324 controller()->metrics_helper()->NumVisits()); |
| 359 | 325 |
| 360 ui_manager_->OnBlockingPageDone(unsafe_resources_, true); | 326 ui_manager_->OnBlockingPageDone(unsafe_resources_, true); |
| 361 | 327 |
| 362 // Check to see if some new notifications of unsafe resources have been | 328 // Check to see if some new notifications of unsafe resources have been |
| 363 // received while we were showing the interstitial. | 329 // received while we were showing the interstitial. |
| 364 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 330 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
| 365 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents()); | 331 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents()); |
| 366 SafeBrowsingBlockingPage* blocking_page = NULL; | 332 SafeBrowsingBlockingPage* blocking_page = NULL; |
| 367 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { | 333 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { |
| 368 // All queued unsafe resources should be for the same page: | 334 // All queued unsafe resources should be for the same page: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 391 return is_main_frame_load_blocked_; | 357 return is_main_frame_load_blocked_; |
| 392 } | 358 } |
| 393 | 359 |
| 394 void SafeBrowsingBlockingPage::OnDontProceed() { | 360 void SafeBrowsingBlockingPage::OnDontProceed() { |
| 395 // We could have already called Proceed(), in which case we must not notify | 361 // We could have already called Proceed(), in which case we must not notify |
| 396 // the SafeBrowsingUIManager again, as the client has been deleted. | 362 // the SafeBrowsingUIManager again, as the client has been deleted. |
| 397 if (proceeded_) | 363 if (proceeded_) |
| 398 return; | 364 return; |
| 399 | 365 |
| 400 if (!IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { | 366 if (!IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { |
| 401 metrics_helper()->RecordUserDecision( | 367 controller()->metrics_helper()->RecordUserDecision( |
| 402 security_interstitials::MetricsHelper::DONT_PROCEED); | 368 security_interstitials::MetricsHelper::DONT_PROCEED); |
| 403 } | 369 } |
| 404 | 370 |
| 405 // Send the malware details, if we opted to. | 371 // Send the malware details, if we opted to. |
| 406 FinishThreatDetails(0, false /* did_proceed */, | 372 FinishThreatDetails(0, false /* did_proceed */, |
| 407 metrics_helper()->NumVisits()); // No delay | 373 controller()->metrics_helper()->NumVisits()); // No delay |
| 408 | 374 |
| 409 ui_manager_->OnBlockingPageDone(unsafe_resources_, false); | 375 ui_manager_->OnBlockingPageDone(unsafe_resources_, false); |
| 410 | 376 |
| 411 // The user does not want to proceed, clear the queued unsafe resources | 377 // The user does not want to proceed, clear the queued unsafe resources |
| 412 // notifications we received while the interstitial was showing. | 378 // notifications we received while the interstitial was showing. |
| 413 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 379 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
| 414 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents()); | 380 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents()); |
| 415 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { | 381 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { |
| 416 ui_manager_->OnBlockingPageDone(iter->second, false); | 382 ui_manager_->OnBlockingPageDone(iter->second, false); |
| 417 unsafe_resource_map->erase(iter); | 383 unsafe_resource_map->erase(iter); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 438 int num_visits) { | 404 int num_visits) { |
| 439 if (threat_details_.get() == NULL) | 405 if (threat_details_.get() == NULL) |
| 440 return; // Not all interstitials have threat details (eg., incognito mode). | 406 return; // Not all interstitials have threat details (eg., incognito mode). |
| 441 | 407 |
| 442 const bool enabled = | 408 const bool enabled = |
| 443 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled) && | 409 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled) && |
| 444 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingOptInAllowed); | 410 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingOptInAllowed); |
| 445 if (!enabled) | 411 if (!enabled) |
| 446 return; | 412 return; |
| 447 | 413 |
| 448 metrics_helper()->RecordUserInteraction( | 414 controller()->metrics_helper()->RecordUserInteraction( |
| 449 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); | 415 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
| 450 // Finish the malware details collection, send it over. | 416 // Finish the malware details collection, send it over. |
| 451 BrowserThread::PostDelayedTask( | 417 BrowserThread::PostDelayedTask( |
| 452 BrowserThread::IO, FROM_HERE, | 418 BrowserThread::IO, FROM_HERE, |
| 453 base::Bind(&ThreatDetails::FinishCollection, threat_details_, | 419 base::Bind(&ThreatDetails::FinishCollection, threat_details_, |
| 454 did_proceed, num_visits), | 420 did_proceed, num_visits), |
| 455 base::TimeDelta::FromMilliseconds(delay_ms)); | 421 base::TimeDelta::FromMilliseconds(delay_ms)); |
| 456 } | 422 } |
| 457 | 423 |
| 458 // static | 424 // static |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 | 479 |
| 514 // static | 480 // static |
| 515 bool SafeBrowsingBlockingPage::IsMainPageLoadBlocked( | 481 bool SafeBrowsingBlockingPage::IsMainPageLoadBlocked( |
| 516 const UnsafeResourceList& unsafe_resources) { | 482 const UnsafeResourceList& unsafe_resources) { |
| 517 // If there is more than one unsafe resource, the main page load must not be | 483 // If there is more than one unsafe resource, the main page load must not be |
| 518 // blocked. Otherwise, check if the one resource is. | 484 // blocked. Otherwise, check if the one resource is. |
| 519 return unsafe_resources.size() == 1 && | 485 return unsafe_resources.size() == 1 && |
| 520 unsafe_resources[0].IsMainPageLoadBlocked(); | 486 unsafe_resources[0].IsMainPageLoadBlocked(); |
| 521 } | 487 } |
| 522 | 488 |
| 523 std::string SafeBrowsingBlockingPage::GetMetricPrefix() const { | 489 // static |
| 524 bool primary_subresource = unsafe_resources_[0].is_subresource; | 490 std::string SafeBrowsingBlockingPage::GetMetricPrefix( |
| 525 switch (interstitial_reason_) { | 491 const UnsafeResourceList& unsafe_resources, |
| 492 SBInterstitialReason interstitial_reason) { |
| 493 bool primary_subresource = unsafe_resources[0].is_subresource; |
| 494 switch (interstitial_reason) { |
| 526 case SB_REASON_MALWARE: | 495 case SB_REASON_MALWARE: |
| 527 return primary_subresource ? "malware_subresource" : "malware"; | 496 return primary_subresource ? "malware_subresource" : "malware"; |
| 528 case SB_REASON_HARMFUL: | 497 case SB_REASON_HARMFUL: |
| 529 return primary_subresource ? "harmful_subresource" : "harmful"; | 498 return primary_subresource ? "harmful_subresource" : "harmful"; |
| 530 case SB_REASON_PHISHING: | 499 case SB_REASON_PHISHING: |
| 531 ThreatPatternType threat_pattern_type = | 500 ThreatPatternType threat_pattern_type = |
| 532 unsafe_resources_[0].threat_metadata.threat_pattern_type; | 501 unsafe_resources[0].threat_metadata.threat_pattern_type; |
| 533 if (threat_pattern_type == ThreatPatternType::PHISHING || | 502 if (threat_pattern_type == ThreatPatternType::PHISHING || |
| 534 threat_pattern_type == ThreatPatternType::NONE) | 503 threat_pattern_type == ThreatPatternType::NONE) |
| 535 return primary_subresource ? "phishing_subresource" : "phishing"; | 504 return primary_subresource ? "phishing_subresource" : "phishing"; |
| 536 else if (threat_pattern_type == ThreatPatternType::SOCIAL_ENGINEERING_ADS) | 505 else if (threat_pattern_type == ThreatPatternType::SOCIAL_ENGINEERING_ADS) |
| 537 return primary_subresource ? "social_engineering_ads_subresource" | 506 return primary_subresource ? "social_engineering_ads_subresource" |
| 538 : "social_engineering_ads"; | 507 : "social_engineering_ads"; |
| 539 else if (threat_pattern_type == | 508 else if (threat_pattern_type == |
| 540 ThreatPatternType::SOCIAL_ENGINEERING_LANDING) | 509 ThreatPatternType::SOCIAL_ENGINEERING_LANDING) |
| 541 return primary_subresource ? "social_engineering_landing_subresource" | 510 return primary_subresource ? "social_engineering_landing_subresource" |
| 542 : "social_engineering_landing"; | 511 : "social_engineering_landing"; |
| 543 } | 512 } |
| 544 NOTREACHED(); | 513 NOTREACHED(); |
| 545 return "unkown_metric_prefix"; | 514 return "unkown_metric_prefix"; |
| 546 } | 515 } |
| 547 | 516 |
| 548 // We populate a parallel set of metrics to differentiate some threat sources. | 517 // We populate a parallel set of metrics to differentiate some threat sources. |
| 549 std::string SafeBrowsingBlockingPage::GetExtraMetricsSuffix() const { | 518 // static |
| 550 switch (unsafe_resources_[0].threat_source) { | 519 std::string SafeBrowsingBlockingPage::GetExtraMetricsSuffix( |
| 520 const UnsafeResourceList& unsafe_resources) { |
| 521 switch (unsafe_resources[0].threat_source) { |
| 551 case safe_browsing::ThreatSource::DATA_SAVER: | 522 case safe_browsing::ThreatSource::DATA_SAVER: |
| 552 return "from_data_saver"; | 523 return "from_data_saver"; |
| 553 case safe_browsing::ThreatSource::REMOTE: | 524 case safe_browsing::ThreatSource::REMOTE: |
| 554 case safe_browsing::ThreatSource::LOCAL_PVER3: | 525 case safe_browsing::ThreatSource::LOCAL_PVER3: |
| 555 // REMOTE and LOCAL_PVER3 can be distinguished in the logs | 526 // REMOTE and LOCAL_PVER3 can be distinguished in the logs |
| 556 // by platform type: Remote is mobile, local_pver3 is desktop. | 527 // by platform type: Remote is mobile, local_pver3 is desktop. |
| 557 return "from_device"; | 528 return "from_device"; |
| 558 case safe_browsing::ThreatSource::LOCAL_PVER4: | 529 case safe_browsing::ThreatSource::LOCAL_PVER4: |
| 559 return "from_device_v4"; | 530 return "from_device_v4"; |
| 560 case safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION: | 531 case safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION: |
| 561 return "from_client_side_detection"; | 532 return "from_client_side_detection"; |
| 562 case safe_browsing::ThreatSource::UNKNOWN: | 533 case safe_browsing::ThreatSource::UNKNOWN: |
| 563 break; | 534 break; |
| 564 } | 535 } |
| 565 NOTREACHED(); | 536 NOTREACHED(); |
| 566 return std::string(); | 537 return std::string(); |
| 567 } | 538 } |
| 568 | 539 |
| 569 std::string SafeBrowsingBlockingPage::GetRapporPrefix() const { | 540 // static |
| 570 switch (interstitial_reason_) { | 541 std::string SafeBrowsingBlockingPage::GetRapporPrefix( |
| 542 SBInterstitialReason interstitial_reason) { |
| 543 switch (interstitial_reason) { |
| 571 case SB_REASON_MALWARE: | 544 case SB_REASON_MALWARE: |
| 572 return "malware2"; | 545 return "malware2"; |
| 573 case SB_REASON_HARMFUL: | 546 case SB_REASON_HARMFUL: |
| 574 return "harmful2"; | 547 return "harmful2"; |
| 575 case SB_REASON_PHISHING: | 548 case SB_REASON_PHISHING: |
| 576 return "phishing2"; | 549 return "phishing2"; |
| 577 } | 550 } |
| 578 NOTREACHED(); | 551 NOTREACHED(); |
| 579 return std::string(); | 552 return std::string(); |
| 580 } | 553 } |
| 581 | 554 |
| 582 std::string SafeBrowsingBlockingPage::GetDeprecatedRapporPrefix() const { | 555 // static |
| 583 switch (interstitial_reason_) { | 556 std::string SafeBrowsingBlockingPage::GetDeprecatedRapporPrefix( |
| 557 SBInterstitialReason interstitial_reason) { |
| 558 switch (interstitial_reason) { |
| 584 case SB_REASON_MALWARE: | 559 case SB_REASON_MALWARE: |
| 585 return "malware"; | 560 return "malware"; |
| 586 case SB_REASON_HARMFUL: | 561 case SB_REASON_HARMFUL: |
| 587 return "harmful"; | 562 return "harmful"; |
| 588 case SB_REASON_PHISHING: | 563 case SB_REASON_PHISHING: |
| 589 return "phishing"; | 564 return "phishing"; |
| 590 } | 565 } |
| 591 NOTREACHED(); | 566 NOTREACHED(); |
| 592 return std::string(); | 567 return std::string(); |
| 593 } | 568 } |
| 594 | 569 |
| 595 std::string SafeBrowsingBlockingPage::GetSamplingEventName() const { | 570 // static |
| 596 switch (interstitial_reason_) { | 571 std::string SafeBrowsingBlockingPage::GetSamplingEventName( |
| 572 SBInterstitialReason interstitial_reason) { |
| 573 switch (interstitial_reason) { |
| 597 case SB_REASON_MALWARE: | 574 case SB_REASON_MALWARE: |
| 598 return kEventNameMalware; | 575 return kEventNameMalware; |
| 599 case SB_REASON_HARMFUL: | 576 case SB_REASON_HARMFUL: |
| 600 return kEventNameHarmful; | 577 return kEventNameHarmful; |
| 601 case SB_REASON_PHISHING: | 578 case SB_REASON_PHISHING: |
| 602 return kEventNamePhishing; | 579 return kEventNamePhishing; |
| 603 default: | 580 default: |
| 604 return kEventNameOther; | 581 return kEventNameOther; |
| 605 } | 582 } |
| 606 } | 583 } |
| 607 | 584 |
| 585 // static |
| 586 SafeBrowsingBlockingPage::SBInterstitialReason |
| 587 SafeBrowsingBlockingPage::GetInterstitialReason( |
| 588 const UnsafeResourceList& unsafe_resources) { |
| 589 bool malware = false; |
| 590 bool harmful = false; |
| 591 bool phishing = false; |
| 592 for (UnsafeResourceList::const_iterator iter = unsafe_resources.begin(); |
| 593 iter != unsafe_resources.end(); ++iter) { |
| 594 const SafeBrowsingUIManager::UnsafeResource& resource = *iter; |
| 595 safe_browsing::SBThreatType threat_type = resource.threat_type; |
| 596 if (threat_type == SB_THREAT_TYPE_URL_MALWARE || |
| 597 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) { |
| 598 malware = true; |
| 599 } else if (threat_type == SB_THREAT_TYPE_URL_UNWANTED) { |
| 600 harmful = true; |
| 601 } else { |
| 602 DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING || |
| 603 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); |
| 604 phishing = true; |
| 605 } |
| 606 } |
| 607 DCHECK(phishing || malware || harmful); |
| 608 if (malware) |
| 609 return SB_REASON_MALWARE; |
| 610 else if (harmful) |
| 611 return SB_REASON_HARMFUL; |
| 612 return SB_REASON_PHISHING; |
| 613 } |
| 614 |
| 615 // static |
| 616 std::unique_ptr<ChromeMetricsHelper> |
| 617 SafeBrowsingBlockingPage::CreateMetricsHelper( |
| 618 WebContents* web_contents, |
| 619 const UnsafeResourceList& unsafe_resources) { |
| 620 SBInterstitialReason interstitial_reason = |
| 621 GetInterstitialReason(unsafe_resources); |
| 622 GURL request_url(unsafe_resources[0].url); |
| 623 security_interstitials::MetricsHelper::ReportDetails reporting_info; |
| 624 reporting_info.metric_prefix = |
| 625 GetMetricPrefix(unsafe_resources, interstitial_reason); |
| 626 reporting_info.extra_suffix = GetExtraMetricsSuffix(unsafe_resources); |
| 627 reporting_info.rappor_prefix = GetRapporPrefix(interstitial_reason); |
| 628 reporting_info.deprecated_rappor_prefix = |
| 629 GetDeprecatedRapporPrefix(interstitial_reason); |
| 630 reporting_info.rappor_report_type = |
| 631 rappor::LOW_FREQUENCY_SAFEBROWSING_RAPPOR_TYPE; |
| 632 reporting_info.deprecated_rappor_report_type = |
| 633 rappor::SAFEBROWSING_RAPPOR_TYPE; |
| 634 return std::unique_ptr<ChromeMetricsHelper>( |
| 635 new ChromeMetricsHelper(web_contents, request_url, reporting_info, |
| 636 GetSamplingEventName(interstitial_reason))); |
| 637 } |
| 638 |
| 608 void SafeBrowsingBlockingPage::PopulateInterstitialStrings( | 639 void SafeBrowsingBlockingPage::PopulateInterstitialStrings( |
| 609 base::DictionaryValue* load_time_data) { | 640 base::DictionaryValue* load_time_data) { |
| 610 CHECK(load_time_data); | 641 CHECK(load_time_data); |
| 611 CHECK(!unsafe_resources_.empty()); | 642 CHECK(!unsafe_resources_.empty()); |
| 612 | 643 |
| 613 load_time_data->SetString("type", "SAFEBROWSING"); | 644 load_time_data->SetString("type", "SAFEBROWSING"); |
| 614 load_time_data->SetString( | 645 load_time_data->SetString( |
| 615 "tabTitle", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE)); | 646 "tabTitle", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE)); |
| 616 load_time_data->SetString( | 647 load_time_data->SetString( |
| 617 "openDetails", | 648 "openDetails", |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 l10n_util::GetStringFUTF16(IDS_PHISHING_V4_EXPLANATION_PARAGRAPH, | 756 l10n_util::GetStringFUTF16(IDS_PHISHING_V4_EXPLANATION_PARAGRAPH, |
| 726 GetFormattedHostName())); | 757 GetFormattedHostName())); |
| 727 load_time_data->SetString( | 758 load_time_data->SetString( |
| 728 "finalParagraph", | 759 "finalParagraph", |
| 729 l10n_util::GetStringUTF16(IDS_PHISHING_V4_PROCEED_AND_REPORT_PARAGRAPH)); | 760 l10n_util::GetStringUTF16(IDS_PHISHING_V4_PROCEED_AND_REPORT_PARAGRAPH)); |
| 730 | 761 |
| 731 PopulateExtendedReportingOption(load_time_data); | 762 PopulateExtendedReportingOption(load_time_data); |
| 732 } | 763 } |
| 733 | 764 |
| 734 } // namespace safe_browsing | 765 } // namespace safe_browsing |
| OLD | NEW |