Commit b8be36d1 authored by kewang@google.com's avatar kewang@google.com

Only enable malware IP matching feature for canary and dev channel.

BUG=176647

Review URL: https://chromiumcodereview.appspot.com/14582021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203099 0039d316-1c4b-4281-b951-d872f2087c98
parent f17047c2
......@@ -19,6 +19,7 @@
#include "chrome/browser/safe_browsing/database_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/safe_browsing/csd.pb.h"
#include "chrome/common/safe_browsing/safebrowsing_messages.h"
......@@ -249,7 +250,8 @@ ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab)
: content::WebContentsObserver(tab),
csd_service_(NULL),
weak_factory_(this),
unsafe_unique_page_id_(-1) {
unsafe_unique_page_id_(-1),
malware_report_enabled_(false) {
DCHECK(tab);
// Note: csd_service_ and sb_service will be NULL here in testing.
csd_service_ = g_browser_process->safe_browsing_detection_service();
......@@ -264,6 +266,13 @@ ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab)
database_manager_ = sb_service->database_manager();
ui_manager_->AddObserver(this);
}
// Only enable the malware bad IP matching and report feature for canary
// and dev channel.
chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
malware_report_enabled_ = (
channel == chrome::VersionInfo::CHANNEL_DEV ||
channel == chrome::VersionInfo::CHANNEL_CANARY);
}
ClientSideDetectionHost::~ClientSideDetectionHost() {
......@@ -380,7 +389,9 @@ void ClientSideDetectionHost::OnPhishingDetectionDone(
browse_info_.get() &&
verdict->ParseFromString(verdict_str) &&
verdict->IsInitialized()) {
scoped_ptr<ClientMalwareRequest> malware_verdict(new ClientMalwareRequest);
if (malware_report_enabled_) {
scoped_ptr<ClientMalwareRequest> malware_verdict(
new ClientMalwareRequest);
// Start browser-side malware feature extraction. Once we're done it will
// send the malware client verdict request.
malware_verdict->set_url(verdict->url());
......@@ -388,6 +399,7 @@ void ClientSideDetectionHost::OnPhishingDetectionDone(
browse_info_.get(),
malware_verdict.get());
MalwareFeatureExtractionDone(malware_verdict.Pass());
}
// We only send phishing verdict to the server if the verdict is phishing or
// if a SafeBrowsing interstitial was already shown for this site. E.g., a
......
......@@ -137,6 +137,8 @@ class ClientSideDetectionHost : public content::WebContentsObserver,
int unsafe_unique_page_id_;
scoped_ptr<SafeBrowsingUIManager::UnsafeResource> unsafe_resource_;
// Whether the malware bad ip matching and report feature is enabled.
bool malware_report_enabled_;
DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost);
};
......
......@@ -219,6 +219,10 @@ class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness {
// We need to create this here since we don't call
// DidNavigateMainFramePostCommit in this test.
csd_host_->browse_info_.reset(new BrowseInfo);
// By default this is set to false. Turn it on as if we are in canary or
// dev channel
csd_host_->malware_report_enabled_ = true;
}
static void RunAllPendingOnIO(base::WaitableEvent* event) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment