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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc

Issue 6611023: The optional Malware Details also collects HTTP cache information. See design... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Start computing malware details. They will be sent only 140 // Start computing malware details. They will be sent only
141 // if the user opts-in on the blocking page later. 141 // if the user opts-in on the blocking page later.
142 // If there's more than one malicious resources, it means the user 142 // If there's more than one malicious resources, it means the user
143 // clicked through the first warning, so we don't prepare additional 143 // clicked through the first warning, so we don't prepare additional
144 // reports. 144 // reports.
145 if (unsafe_resources.size() == 1 && 145 if (unsafe_resources.size() == 1 &&
146 unsafe_resources[0].threat_type == SafeBrowsingService::URL_MALWARE && 146 unsafe_resources[0].threat_type == SafeBrowsingService::URL_MALWARE &&
147 malware_details_ == NULL && 147 malware_details_ == NULL &&
148 CanShowMalwareDetailsOption()) { 148 CanShowMalwareDetailsOption()) {
149 malware_details_ = MalwareDetails::NewMalwareDetails( 149 malware_details_ = MalwareDetails::NewMalwareDetails(
150 tab(), unsafe_resources[0]); 150 sb_service_, tab(), unsafe_resources[0]);
151 } 151 }
152 } 152 }
153 153
154 bool SafeBrowsingBlockingPage::CanShowMalwareDetailsOption() { 154 bool SafeBrowsingBlockingPage::CanShowMalwareDetailsOption() {
155 return (!tab()->profile()->IsOffTheRecord() && 155 return (!tab()->profile()->IsOffTheRecord() &&
156 tab()->GetURL().SchemeIs(chrome::kHttpScheme)); 156 tab()->GetURL().SchemeIs(chrome::kHttpScheme));
157 } 157 }
158 158
159 SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() { 159 SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() {
160 } 160 }
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 void SafeBrowsingBlockingPage::FinishMalwareDetails() { 598 void SafeBrowsingBlockingPage::FinishMalwareDetails() {
599 if (malware_details_ == NULL) 599 if (malware_details_ == NULL)
600 return; // Not all interstitials have malware details (eg phishing). 600 return; // Not all interstitials have malware details (eg phishing).
601 601
602 const PrefService::Preference* pref = 602 const PrefService::Preference* pref =
603 tab()->profile()->GetPrefs()->FindPreference( 603 tab()->profile()->GetPrefs()->FindPreference(
604 prefs::kSafeBrowsingReportingEnabled); 604 prefs::kSafeBrowsingReportingEnabled);
605 605
606 bool value; 606 bool value;
607 if (pref && pref->GetValue()->GetAsBoolean(&value) && value) { 607 if (pref && pref->GetValue()->GetAsBoolean(&value) && value) {
608 // Give the details object to the service class, so it can send it. 608 // Finish the malware details collection, send it over.
609 BrowserThread::PostTask( 609 BrowserThread::PostTask(
610 BrowserThread::IO, FROM_HERE, 610 BrowserThread::IO, FROM_HERE,
611 NewRunnableMethod( 611 NewRunnableMethod(
612 sb_service_, &SafeBrowsingService::ReportMalwareDetails, 612 malware_details_.get(), &MalwareDetails::FinishCollection));
613 malware_details_));
614 } 613 }
615 } 614 }
616 615
617 // static 616 // static
618 void SafeBrowsingBlockingPage::NotifySafeBrowsingService( 617 void SafeBrowsingBlockingPage::NotifySafeBrowsingService(
619 SafeBrowsingService* sb_service, 618 SafeBrowsingService* sb_service,
620 const UnsafeResourceList& unsafe_resources, 619 const UnsafeResourceList& unsafe_resources,
621 bool proceed) { 620 bool proceed) {
622 BrowserThread::PostTask( 621 BrowserThread::PostTask(
623 BrowserThread::IO, FROM_HERE, 622 BrowserThread::IO, FROM_HERE,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 668 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
670 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource); 669 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource);
671 } 670 }
672 671
673 // static 672 // static
674 bool SafeBrowsingBlockingPage::IsMainPage( 673 bool SafeBrowsingBlockingPage::IsMainPage(
675 const UnsafeResourceList& unsafe_resources) { 674 const UnsafeResourceList& unsafe_resources) {
676 return unsafe_resources.size() == 1 && 675 return unsafe_resources.size() == 1 &&
677 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME; 676 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME;
678 } 677 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698