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

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

Issue 14582021: Only enable malware IP matching feature for canary and dev channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git pull patch Created 7 years, 7 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) 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 #include "chrome/browser/safe_browsing/client_side_detection_host.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/sequenced_task_runner_helpers.h" 14 #include "base/sequenced_task_runner_helpers.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" 17 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
18 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 18 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
19 #include "chrome/browser/safe_browsing/database_manager.h" 19 #include "chrome/browser/safe_browsing/database_manager.h"
20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/chrome_version_info.h"
22 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
23 #include "chrome/common/safe_browsing/csd.pb.h" 24 #include "chrome/common/safe_browsing/csd.pb.h"
24 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 25 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
25 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/navigation_controller.h" 27 #include "content/public/browser/navigation_controller.h"
27 #include "content/public/browser/navigation_details.h" 28 #include "content/public/browser/navigation_details.h"
28 #include "content/public/browser/navigation_entry.h" 29 #include "content/public/browser/navigation_entry.h"
29 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
30 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
31 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // static 243 // static
243 ClientSideDetectionHost* ClientSideDetectionHost::Create( 244 ClientSideDetectionHost* ClientSideDetectionHost::Create(
244 WebContents* tab) { 245 WebContents* tab) {
245 return new ClientSideDetectionHost(tab); 246 return new ClientSideDetectionHost(tab);
246 } 247 }
247 248
248 ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab) 249 ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab)
249 : content::WebContentsObserver(tab), 250 : content::WebContentsObserver(tab),
250 csd_service_(NULL), 251 csd_service_(NULL),
251 weak_factory_(this), 252 weak_factory_(this),
252 unsafe_unique_page_id_(-1) { 253 unsafe_unique_page_id_(-1),
254 malware_report_enabled_(false) {
253 DCHECK(tab); 255 DCHECK(tab);
254 // Note: csd_service_ and sb_service will be NULL here in testing. 256 // Note: csd_service_ and sb_service will be NULL here in testing.
255 csd_service_ = g_browser_process->safe_browsing_detection_service(); 257 csd_service_ = g_browser_process->safe_browsing_detection_service();
256 feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_)); 258 feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_));
257 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, 259 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED,
258 content::Source<WebContents>(tab)); 260 content::Source<WebContents>(tab));
259 261
260 scoped_refptr<SafeBrowsingService> sb_service = 262 scoped_refptr<SafeBrowsingService> sb_service =
261 g_browser_process->safe_browsing_service(); 263 g_browser_process->safe_browsing_service();
262 if (sb_service) { 264 if (sb_service) {
263 ui_manager_ = sb_service->ui_manager(); 265 ui_manager_ = sb_service->ui_manager();
264 database_manager_ = sb_service->database_manager(); 266 database_manager_ = sb_service->database_manager();
265 ui_manager_->AddObserver(this); 267 ui_manager_->AddObserver(this);
266 } 268 }
269
270 // Only enable the malware bad IP matching and report feature for canary
271 // and dev channel.
272 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
273 malware_report_enabled_ = (
274 channel == chrome::VersionInfo::CHANNEL_DEV ||
275 channel == chrome::VersionInfo::CHANNEL_CANARY);
267 } 276 }
268 277
269 ClientSideDetectionHost::~ClientSideDetectionHost() { 278 ClientSideDetectionHost::~ClientSideDetectionHost() {
270 if (ui_manager_) 279 if (ui_manager_)
271 ui_manager_->RemoveObserver(this); 280 ui_manager_->RemoveObserver(this);
272 } 281 }
273 282
274 bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) { 283 bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) {
275 bool handled = true; 284 bool handled = true;
276 IPC_BEGIN_MESSAGE_MAP(ClientSideDetectionHost, message) 285 IPC_BEGIN_MESSAGE_MAP(ClientSideDetectionHost, message)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 DCHECK(browse_info_.get()); 382 DCHECK(browse_info_.get());
374 383
375 // We parse the protocol buffer here. If we're unable to parse it we won't 384 // We parse the protocol buffer here. If we're unable to parse it we won't
376 // send the verdict further. 385 // send the verdict further.
377 scoped_ptr<ClientPhishingRequest> verdict(new ClientPhishingRequest); 386 scoped_ptr<ClientPhishingRequest> verdict(new ClientPhishingRequest);
378 if (csd_service_ && 387 if (csd_service_ &&
379 !weak_factory_.HasWeakPtrs() && 388 !weak_factory_.HasWeakPtrs() &&
380 browse_info_.get() && 389 browse_info_.get() &&
381 verdict->ParseFromString(verdict_str) && 390 verdict->ParseFromString(verdict_str) &&
382 verdict->IsInitialized()) { 391 verdict->IsInitialized()) {
383 scoped_ptr<ClientMalwareRequest> malware_verdict(new ClientMalwareRequest); 392 if (malware_report_enabled_) {
384 // Start browser-side malware feature extraction. Once we're done it will 393 scoped_ptr<ClientMalwareRequest> malware_verdict(
385 // send the malware client verdict request. 394 new ClientMalwareRequest);
386 malware_verdict->set_url(verdict->url()); 395 // Start browser-side malware feature extraction. Once we're done it will
387 feature_extractor_->ExtractMalwareFeatures( 396 // send the malware client verdict request.
388 browse_info_.get(), 397 malware_verdict->set_url(verdict->url());
389 malware_verdict.get()); 398 feature_extractor_->ExtractMalwareFeatures(
390 MalwareFeatureExtractionDone(malware_verdict.Pass()); 399 browse_info_.get(),
400 malware_verdict.get());
401 MalwareFeatureExtractionDone(malware_verdict.Pass());
402 }
391 403
392 // We only send phishing verdict to the server if the verdict is phishing or 404 // We only send phishing verdict to the server if the verdict is phishing or
393 // if a SafeBrowsing interstitial was already shown for this site. E.g., a 405 // if a SafeBrowsing interstitial was already shown for this site. E.g., a
394 // malware or phishing interstitial was shown but the user clicked 406 // malware or phishing interstitial was shown but the user clicked
395 // through. 407 // through.
396 if (verdict->is_phishing() || DidShowSBInterstitial()) { 408 if (verdict->is_phishing() || DidShowSBInterstitial()) {
397 if (DidShowSBInterstitial()) { 409 if (DidShowSBInterstitial()) {
398 browse_info_->unsafe_resource.reset(unsafe_resource_.release()); 410 browse_info_->unsafe_resource.reset(unsafe_resource_.release());
399 } 411 }
400 // Start browser-side feature extraction. Once we're done it will send 412 // Start browser-side feature extraction. Once we're done it will send
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 ui_manager_->RemoveObserver(this); 542 ui_manager_->RemoveObserver(this);
531 543
532 ui_manager_ = ui_manager; 544 ui_manager_ = ui_manager;
533 if (ui_manager) 545 if (ui_manager)
534 ui_manager_->AddObserver(this); 546 ui_manager_->AddObserver(this);
535 547
536 database_manager_ = database_manager; 548 database_manager_ = database_manager;
537 } 549 }
538 550
539 } // namespace safe_browsing 551 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698